Showing 4,939 of 4,939 total issues

The method analyzeOverrideSignatureForOverriddenMethod() has 278 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    private static function analyzeOverrideSignatureForOverriddenMethod(
        CodeBase $code_base,
        Method $method,
        Clazz $class,
        Method $o_method

The method adaptInheritedMethodFromTrait() has an NPath complexity of 300. The configured NPath complexity threshold is 200.
Open

    private function adaptInheritedMethodFromTrait(Method $method): Method
    {
        $method_flags = $method->getFlags();
        if (Flags::bitVectorHasState($method_flags, \ast\flags\MODIFIER_PRIVATE)) {
            $method = $method->createUseAlias($this, $method->getName(), \ast\flags\MODIFIER_PRIVATE);
Severity: Minor
Found in src/Phan/Language/Element/Clazz.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The class ArgumentType has 1427 lines of code. Current threshold is 1000. Avoid really long classes.
Open

final class ArgumentType
{

    /**
     * @param FunctionInterface $method
Severity: Minor
Found in src/Phan/Analysis/ArgumentType.php by phpmd

The method visitBinaryAdd() has 103 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function visitBinaryAdd(Node $node): Context
    {
        return $this->updateTargetWithType($node, function (UnionType $left) use ($node): UnionType {
            $code_base = $this->code_base;
            $context = $this->context;

The class BinaryOperatorFlagVisitor has 1023 lines of code. Current threshold is 1000. Avoid really long classes.
Open

final class BinaryOperatorFlagVisitor extends FlagVisitorImplementation
{

    /**
     * @var CodeBase The code base within which we're operating

The method analyzeParameterTypesInner() has an NPath complexity of 508416. The configured NPath complexity threshold is 200.
Open

    private static function analyzeParameterTypesInner(
        CodeBase $code_base,
        FunctionInterface $method
    ): void {
        if (Config::getValue('check_docblock_signature_param_type_match')) {

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method run() contains an exit expression.
Open

            exit(0);
Severity: Minor
Found in src/Phan/Daemon.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

The method readResultsFromChildren() contains an exit expression.
Open

                exit(EXIT_FAILURE);
Severity: Minor
Found in src/Phan/ForkPool.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

The method getPropertyByNameInContext() has 171 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function getPropertyByNameInContext(
        CodeBase $code_base,
        string $name,
        Context $context,
        bool $is_static,
Severity: Minor
Found in src/Phan/Language/Element/Clazz.php by phpmd

The method maybeParsePhanCustomAnnotation() has 146 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    private function maybeParsePhanCustomAnnotation(int $i, string $line, string $type, string $case_sensitive_type): void
    {
        switch ($type) {
            case 'phan-forbid-undeclared-magic-properties':
                if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS], $i)) {

The method warnInvalidArgumentType() has 160 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    private static function warnInvalidArgumentType(
        CodeBase $code_base,
        Context $context,
        FunctionInterface $method,
        Parameter $alternate_parameter,
Severity: Minor
Found in src/Phan/Analysis/ArgumentType.php by phpmd

The method visitCall() has an NPath complexity of 2400. The configured NPath complexity threshold is 200.
Open

    public function visitCall(Node $node): Context
    {
        // Analyze the call to the node, in case it modifies any variables (e.g. count($x = new_value()), if (preg_match(..., $matches), etc.
        // TODO: Limit this to nodes which actually contain variables or properties?
        // TODO: Only call this if the caller is also a ConditionVisitor, since BlockAnalysisVisitor would call this for ternaries and if statements already.

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

Avoid using empty try-catch blocks in analyzeParameterTypes.
Open

        } catch (RecursionDepthException $_) {
        }

EmptyCatchBlock

Since: 2.7.0

Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

Example

class Foo {

  public function bar()
  {
      try {
          // ...
      } catch (Exception $e) {} // empty catch block
  }
}

Source https://phpmd.org/rules/design.html#emptycatchblock

Avoid using empty try-catch blocks in checkCanAccessProtectedElement.
Open

        } catch (RecursionDepthException $_) {
        }

EmptyCatchBlock

Since: 2.7.0

Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

Example

class Foo {

  public function bar()
  {
      try {
          // ...
      } catch (Exception $e) {} // empty catch block
  }
}

Source https://phpmd.org/rules/design.html#emptycatchblock

The class Builder has 1492 lines of code. Current threshold is 1000. Avoid really long classes.
Open

final class Builder
{
    /** @var string the original raw comment */
    public $comment;
    /** @var list<string> the list of lines of the doc comment */

The method warnInvalidArgumentType has 11 parameters. Consider reducing the number of parameters to less than 10.
Open

    private static function warnInvalidArgumentType(
        CodeBase $code_base,
        Context $context,
        FunctionInterface $method,
        Parameter $alternate_parameter,
Severity: Minor
Found in src/Phan/Analysis/ArgumentType.php by phpmd

The method combineTypesAfterWeakEqualityCheck() has an NPath complexity of 568. The configured NPath complexity threshold is 200.
Open

    protected function combineTypesAfterWeakEqualityCheck(UnionType $old_union_type, UnionType $new_union_type): UnionType
    {
        // TODO: Be more precise about these checks - e.g. forbid anything such as stdClass == false in the new type
        if (!$old_union_type->hasRealTypeSet()) {
            // This is a weak check of equality. We aren't sure of the real types

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method analyzeParameterTypesInner() has 164 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    private static function analyzeParameterTypesInner(
        CodeBase $code_base,
        FunctionInterface $method
    ): void {
        if (Config::getValue('check_docblock_signature_param_type_match')) {

Avoid using empty try-catch blocks in visitMethod.
Open

        } catch (Exception $_) {
        }

EmptyCatchBlock

Since: 2.7.0

Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

Example

class Foo {

  public function bar()
  {
      try {
          // ...
      } catch (Exception $e) {} // empty catch block
  }
}

Source https://phpmd.org/rules/design.html#emptycatchblock

The method updateParameterTypeByArgument() has an NPath complexity of 6240. The configured NPath complexity threshold is 200.
Open

    private function updateParameterTypeByArgument(
        FunctionInterface $method,
        Parameter $parameter,
        $argument,
        array $argument_types,

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

Severity
Category
Status
Source
Language