Giter Site home page Giter Site logo

codeclimate / codeclimate-phpmd Goto Github PK

View Code? Open in Web Editor NEW
9.0 24.0 12.0 143 KB

Code Climate PHPMD Engine

License: MIT License

PHP 75.63% Shell 0.46% Ruby 9.92% Makefile 5.47% Dockerfile 8.51%
phpmd codeclimate codeclimate-engine quality code-quality static-analysis metrics

codeclimate-phpmd's Introduction

Code Climate CLI

Code Climate CircleCI

Overview

codeclimate is a command line interface for the Code Climate analysis platform. It allows you to run Code Climate engines on your local machine inside of Docker containers.

Prerequisites

The Code Climate CLI is distributed and run as a Docker image. The engines that perform the actual analyses are also Docker images. To support this, you must have Docker installed and running locally. We also require that the Docker daemon supports connections on the default Unix socket /var/run/docker.sock.

On macOS, we recommend using Docker for Mac.

Installation

macOS

brew tap codeclimate/formulae
brew install codeclimate

To update the brew package, use brew update first:

brew update
brew upgrade codeclimate

Anywhere

curl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz
cd codeclimate-* && sudo make install

To upgrade to a newer version, just run those steps again.

Manual Docker invocation

The above packages pull the docker image and install a shell script wrapper. In some cases you may want to run the docker image directly.

To pull the docker image:

docker pull codeclimate/codeclimate

To invoke the CLI via Docker:

docker run \
  --interactive --tty --rm \
  --env CODECLIMATE_CODE="$PWD" \
  --volume "$PWD":/code \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/cc:/tmp/cc \
  codeclimate/codeclimate help

Project setup

Configuration

No explicit configuration is needed: by default codeclimate analyze will evaluate supported source files in your repository using our maintainability checks. To change default configuration to customize how the maintainability checks are evaluated, or to turn on open source plugins, see our documentation on advanced configuration.

Plugin installation

Plugins, or "engines", are the docker images that run analysis tools. We support many different plugins, and will only install the ones necessary to run analysis. As part of setting up your project, we recommend running codeclimate engines:install from within your repository before running codeclimate analyze, and after adding any new plugins to your configuration file.

Running analysis

Once you've installed plugins and made any necessary changes to your configuration, run codeclimate analyze to run analysis and see a report on any issues in your repository.

Commands

A list of available commands is accessible by running codeclimate or codeclimate help.

$ codeclimate help

Available commands:
    analyze [-f format] [-e engine[:channel]] [--dev] [path]
    console
    engines:install
    engines:list
    help [command]
    prepare [--allow-internal-ips]
    validate-config
    version

The following is a brief explanation of each available command.

  • analyze Analyze all relevant files in the current working directory. All engines that are enabled in your .codeclimate.yml file will run, one after another. The -f (or format) argument allows you to set the output format of the analysis (using json, text, or html). The --dev flag lets you run engines not known to the CLI, for example if you're an engine author developing your own, unreleased image.

    You can optionally provide a specific path to analyze. If not provided, the CLI will analyze your entire repository, except for your configured exclude_paths. When you do provide an explicit path to analyze, your configured exclude_paths are ignored, and normally excluded files will be analyzed.

    You can also pipe in source in combination with a path to analyze code that is not yet written to disk. This is useful when you want to check if your source code style matches the project's. This is also a good way to implement integration with an editor to check style on the fly.

  • console start an interactive session providing access to the classes within the CLI. Useful for engine developers and maintainers.

  • engines:install Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines and checks for new images available for existing engines.

  • engines:list Lists all available engines in the Code Climate Docker Hub .

  • help Displays a list of commands that can be passed to the Code Climate CLI.

  • validate-config Validates the .codeclimate.yml file in the current working directory.

  • version Displays the current version of the Code Climate CLI.

Environment Variables

  • To run codeclimate in debug mode:

    CODECLIMATE_DEBUG=1 codeclimate analyze
    

    Prints additional information about the analysis steps, including any stderr produced by engines.

  • To increase the amount of time each engine container may run (default 15 min):

    # 30 minutes
    CONTAINER_TIMEOUT_SECONDS=1800 codeclimate analyze
    
  • You can also configure the default alotted memory with which each engine runs (default is 1,024,000,000 bytes):

    # 2,000,000,000 bytes
    ENGINE_MEMORY_LIMIT_BYTES=2000000000 codeclimate analyze
    

Releasing a new version

CLI's new versions are released automatically when updating VERSION on master.

The releasing process includes;

  1. Push new version to rubygems.
  2. Create a new release on Github and an associated tag.
  3. Update docker images:
  • Push new latest image.
  • Push new image with latest version as tag.

Ideally someone will open a pull request against master updating only VERSION.

There is script in place, which assumes hub is installed, to facilitate that. Check the current VERSION (cat VERSION) and upgrade accordingly running:

./bin/prep-release <VERSION>

Copyright

See LICENSE

codeclimate-phpmd's People

Contributors

ablyler avatar blakewilliams avatar brynary avatar dantevvp avatar dblandin avatar dbudwin avatar fede-moya avatar filipesperandio avatar gdiggs avatar josephdpurcell avatar jpignata avatar landrok avatar maxjacobson avatar mik-laj avatar mxie avatar noahd1 avatar pbrisbin avatar pointlessone avatar wfleming avatar wilson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeclimate-phpmd's Issues

all error in output

I've got errors on every build:

PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Undefined variable: type in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php on line 5521
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PDepend\Source\AST\AbstractASTCallable::addChild() must implement interface PDepend\Source\AST\ASTNode, null given, called in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php on line 97 and defined in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTCallable.php:143
Stack trace:
#0 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php(97): PDepend\Source\AST\AbstractASTCallable->addChild(NULL)
#1 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1228): PDepend\Source\Language\PHP\PHPParserVersion70->parseCallableDeclarationAddition(Object(PDepend\Source\AST\ASTMethod))
#2 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1185): PDepend\Source\Language\PHP\AbstractPHPParser->parseCallableDeclaration(Object(PDepend\Source\AST\ASTMethod))
#3 /usr/src/ in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTCallable.php on line 143
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Only variables should be passed by reference in /usr/src/app/Category.php on line 70
PHP Notice:  Undefined variable: type in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php on line 5521
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PDepend\Source\AST\AbstractASTCallable::addChild() must implement interface PDepend\Source\AST\ASTNode, null given, called in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php on line 97 and defined in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTCallable.php:143
Stack trace:
#0 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php(97): PDepend\Source\AST\AbstractASTCallable->addChild(NULL)
#1 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1228): PDepend\Source\Language\PHP\PHPParserVersion70->parseCallableDeclarationAddition(Object(PDepend\Source\AST\ASTMethod))
#2 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1185): PDepend\Source\Language\PHP\AbstractPHPParser->parseCallableDeclaration(Object(PDepend\Source\AST\ASTMethod))
#3 /usr/src/ in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTCallable.php on line 143

oss repo - error with PDepend, parser issue?

https://github.com/FrailmoonEnterprises/AlivarAPI

OSS repo erroring with:

engine phpmd failed with status 1 and stderr 
Exception: Argument 1 passed to PDepend\Source\Parser\TokenStack::add() must be an instance of PDepend\Source\Tokenizer\Token, integer given, called in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php on line 6842 in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Parser/TokenStack.php
#0 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6842): PDepend\Source\Parser\TokenStack->add(-1)
#1 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2587): PDepend\Source\Language\PHP\AbstractPHPParser->consumeToken(-1)
#2 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(5039): PDepend\Source\Language\PHP\AbstractPHPParser->parseExpression()
#3 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4996): PDepend\Source\Language\PHP\AbstractPHPParser->parseArrayElement(false)
#4 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion53.php(91): PDepend\Source\Language\PHP\AbstractPHPParser->parseArrayElements(Object(PDepend\Source\AST\ASTArray), 7, false)
#5 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion54.php(216): PDepend\Source\Language\PHP\PHPParserVersion53->parseArray(Object(PDepend\Source\AST\ASTArray), false)
#6 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4957): PDepend\Source\Language\PHP\PHPParserVersion54->parseArray(Object(PDepend\Source\AST\ASTArray), false)
#7 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2653): PDepend\Source\Language\PHP\AbstractPHPParser->doParseArray()
#8 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2586): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalExpression()
#9 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(5049): PDepend\Source\Language\PHP\AbstractPHPParser->parseExpression()
#10 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4996): PDepend\Source\Language\PHP\AbstractPHPParser->parseArrayElement(false)
#11 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion53.php(91): PDepend\Source\Language\PHP\AbstractPHPParser->parseArrayElements(Object(PDepend\Source\AST\ASTArray), 7, false)
#12 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion54.php(216): PDepend\Source\Language\PHP\PHPParserVersion53->parseArray(Object(PDepend\Source\AST\ASTArray), false)
#13 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4957): PDepend\Source\Language\PHP\PHPParserVersion54->parseArray(Object(PDepend\Source\AST\ASTArray), false)
#14 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2653): PDepend\Source\Language\PHP\AbstractPHPParser->doParseArray()
#15 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4354): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalExpression()
#16 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2774): PDepend\Source\Language\PHP\AbstractPHPParser->parseAssignmentExpression(Object(PDepend\Source\AST\ASTArrayIndexExpression))
#17 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(5725): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalExpression()
#18 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(388): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalStatement()
#19 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(575): PDepend\Source\Language\PHP\AbstractPHPParser->parse()
#20 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(323): PDepend\Engine->performParseProcess()
#21 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php(123): PDepend\Engine->analyze()
#22 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(222): PHPMD\Parser->parse(Object(PHPMD\Report))
#23 /usr/src/app/Runner.php(116): PHPMD\PHPMD->processFiles('/code/user/inst...', 'cleancode,codes...', Array, Object(PHPMD\RuleSetFactory))
#24 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1852): CodeClimate\PHPMD\Runner->run(Array)
#25 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1772): fork_daemon->invoke_callback(Array, Array, false)
#26 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1673): fork_daemon->fork_work_unit(Array, '', -1)
#27 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1423): fork_daemon->process_work_unit(-1)
#28 /usr/src/app/engine.php(37): fork_daemon->process_work(true)
#29 {main}
  • Happens with Code Climate CLI and .com analysis.
  • checking with @powelljf3 to see if he can reproduce with PHPMD itself, locally

Improve default PHPMD checks

Problem

By default, PHPMD has the following two checks which I believe are problematic:

  • The camelCase variable names apply to Zend and Symfony but not Drupal and Wordpress.
  • Avoiding "else" statements is controversial: I don't believe there is consensus that the use of else statements correlates with poor code. And it is a little redundant in that it would be caught by Cyclomatic Complexity and NPath Complexity metrics.

Proposed Resolution

  • Turn off the CamelCaseClassName, CamelCasePropertyName, CamelCaseMethodName, CamelCaseParameterName, CamelCaseVariableName checks by default.
  • Turn off the ElseExpression check by default.

Exception error: Call to a member function getPriority() on null

Repo getting exception errors when DuplicatedArrayKey and MissingImport checks added.

Customer reports:

It seems that we have activated some checks, that were added to phpmd in version 2.7.0 (DuplicatedArrayKey and MissingImport). If I remove the two checks, everything seems to be working.

I have also tested with an older version (2.6.1) of phpmd against my local version (2.7.0) and with the older version I get the same error as I get on CodeClimate.


The errors don't fail the build, but produces logs like:

Exception: Call to a member function getPriority() on null in /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php
#0 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(288): PHPMD\RuleSetFactory->parseRuleReferenceNode(Object(PHPMD\RuleSet), Object(SimpleXMLElement))
#1 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(265): PHPMD\RuleSetFactory->parseRuleNode(Object(PHPMD\RuleSet), Object(SimpleXMLElement))
#2 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(141): PHPMD\RuleSetFactory->parseRuleSetNode('/code/./codesiz...')
#3 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(125): PHPMD\RuleSetFactory->createSingleRuleSet('/code/./codesiz...')
#4 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(217): PHPMD\RuleSetFactory->createRuleSets('/code/./codesiz...')
#5 /usr/src/app/Runner.php(116): PHPMD\PHPMD->processFiles('/code/artisan', '/code/./codesiz...', Array, Object(PHPMD\RuleSetFactory))
#6 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1852): CodeClimate\PHPMD\Runner->run(Array)
#7 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1772): fork_daemon->invoke_callback(Array, Array, false)
#8 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1673): fork_daemon->fork_work_unit(Array, '', -1)
#9 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1445): fork_daemon->process_work_unit(-1)
#10 /usr/src/app/Runner.php(31): fork_daemon->process_work(false)
#11 /usr/src/app/engine.php(35): CodeClimate\PHPMD\Runner->queueDirectory('/code')
#12 {main}Exception: Call to a member function getPriority() on null in /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php
#0 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(288): PHPMD\RuleSetFactory->parseRuleReferenceNode(Object(PHPMD\RuleSet), Object(SimpleXMLElement))
#1 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(265): PHPMD\RuleSetFactory->parseRuleNode(Object(PHPMD\RuleSet), Object(SimpleXMLElement))
#2 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(141): PHPMD\RuleSetFactory->parseRuleSetNode('/code/./codesiz...')
#3 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/RuleSetFactory.php(125): PHPMD\RuleSetFactory->createSingleRuleSet('/code/./codesiz...')
#4 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(217): PHPMD\RuleSetFactory->createRuleSets('/code/./codesiz...')
#5 /usr/src/app/Runner.php(116): PHPMD\PHPMD->processFiles('/code/app/Http/...', '/code/./codesiz...', Array, Object(PHPMD\RuleSetFactory))
#6 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1852): CodeClimate\PHPMD\Runner->run(Array)
#7 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1772): fork_daemon->invoke_callback(Array, Array, false)
#8 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1673): fork_daemon->fork_work_unit(Array, '', -1)
#9 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1445): fork_daemon->process_work_unit(-1)
#10 /usr/src/app/Runner.php(31): fork_daemon->process_work(false)
#11 /usr/src/app/engine.php(35): CodeClimate\PHPMD\Runner->queueDirectory('/code')
#12 {main}

PDepend - Uncaught Error: Call to a member function restoreClass() on null

Customer's repo erroring with:

engine phpmd failed with status 255 and stderr 
Exception: Argument 1 passed to PDepend\Source\AST\ASTConstantDeclarator::setValue() must be an instance of PDepend\Source\AST\ASTValue, null given, called in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php on line 6205 in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/ASTConstantDeclarator.php
#0 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6205): PDepend\Source\AST\ASTConstantDeclarator->setValue(NULL)
#1 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6135): PDepend\Source\Language\PHP\AbstractPHPParser->parseConstantDeclarator()
#2 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(886): PDepend\Source\Language\PHP\AbstractPHPParser->parseConstantDefinition()
#3 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(713): PDepend\Source\Language\PHP\AbstractPHPParser->parseTypeBody(Object(PDepend\Source\AST\ASTClass))
#4 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(5712): PDepend\Source\Language\PHP\AbstractPHPParser->parseClassDeclaration()
#5 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(388): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalStatement()
#6 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(575): PDepend\Source\Language\PHP\AbstractPHPParser->parse()
#7 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(323): PDepend\Engine->performParseProcess()
#8 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php(123): PDepend\Engine->analyze()
#9 /usr/src/app/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(222): PHPMD\Parser->parse(Object(PHPMD\Report))
#10 /usr/src/app/Runner.php(116): PHPMD\PHPMD->processFiles('/code/magento/a...', 'cleancode,codes...', Array, Object(PHPMD\RuleSetFactory))
#11 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1852): CodeClimate\PHPMD\Runner->run(Array)
#12 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1772): fork_daemon->invoke_callback(Array, Array, false)
#13 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1673): fork_daemon->fork_work_unit(Array, '', -1)
#14 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1423): fork_daemon->process_work_unit(-1)
#15 /usr/src/app/engine.php(37): fork_daemon->process_work(true)
#16 {main}
PHP Fatal error:  Uncaught Error: Call to a member function restoreClass() on null in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Builder/BuilderContext/GlobalBuilderContext.php:116
Stack trace:
#0 /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/ASTClass.php(212): PDepend\Source\Builder\BuilderContext\GlobalBuilderContext->registerClass(Object(PDepend\Source\AST\ASTClass))
#1 [internal function]: PDepend\Source\AST\ASTClass->__wakeup()
#2 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1973): unserialize('O:9:"TypeError"...')
#3 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1570): fork_daemon->socket_receive(Resource id #2691)
#4 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1622): fork_daemon->fetch_results(false, 0, -1)
#5 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(841): fork_daemon->post_results(-1)
#6 /usr/src/app/vendor/barracudanetworks/forkdaemon-php/fork_daemon.php(1420): fork_daemon->sig in /usr/src/app/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Builder/BuilderContext/GlobalBuilderContext.php on line 116

Outdated PHPMD version

PHPMD version that currently locked in composer.lock results in different results of PHP Mess Detector. 2.3 has a weird bug in the coupling between objects rule that was fixed in 2.6, but codeclimate still uses outdated version.

PHPMD times out on Code Climate

Problem

Here is the error:

An engine timed out
E11

The phpmd engine failed to complete in time.

Engine timeouts are generally caused by either an abnormally large number of files under analysis or from attempting to analyze a file not typically intended for static analysis. We recommend excluding:

    Third party libraries
    Production assets, such as minimized or cross-compiled files
    Automated test suites

For more information, see our documentation on file and path exclusions.

I experienced this on these repos:

I expect this will be a common problem for other large PHP projects.

Proposed Solution

I see at least two options:

  1. Investigate to see why PHPMD takes longer than PHPCS or other engines.
  2. Set the default timeout limit just for the PHPMD engine to 30 mins instead of 15 mins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.