Showing 3,272 of 4,939 total issues

Function checkVarKindOfAssign has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkVarKindOfAssign(Node $var): void
    {
        if ($var->kind === ast\AST_VAR) {
            return;
        } elseif ($var->kind === ast\AST_PROP) {
Severity: Minor
Found in src/Phan/AST/InferPureVisitor.php - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getOrCreateVariableForReferenceParameter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getOrCreateVariableForReferenceParameter(Parameter $parameter, ?Parameter $real_parameter): Variable
    {
        // Return the original variable if it existed
        try {
            $variable = $this->getVariable();
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getFunctionFromNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFunctionFromNode(bool $return_placeholder_for_undefined = false): iterable
    {
        $expression = $this->node;
        if (!($expression instanceof Node)) {
            if (!\is_string($expression)) {
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                        if ($dim_type->containsNullable() && $dim_type->nonNullableClone()->canCastToUnionType($expected_key_type)) {
                            $issue_type = Issue::TypeMismatchDimFetchNullable;
                        }
Severity: Major
Found in src/Phan/AST/UnionTypeVisitor.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ($this->should_catch_issue_exception) {
                                $this->emitIssue(
                                    $issue_type,
                                    $node->lineno,
                                    (string)$union_type,
    Severity: Major
    Found in src/Phan/AST/UnionTypeVisitor.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ($union_type->isType(NullType::instance(false))) {
                                  $custom_issue_type = Issue::TypeExpectedObjectPropAccessButGotNull;
                              }
      Severity: Major
      Found in src/Phan/AST/ContextNode.php - About 45 mins to fix

        Function parseMethodSignature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function parseMethodSignature(string $class_name, string $method_name): ?array
            {
                $this->initStubs();
                if ($class_name[0] !== '\\') {
                    $class_name = '\\' . $class_name;
        Severity: Minor
        Found in internal/lib/IncompatibleRealStubsSignatureDetector.php - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function processVariable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function processVariable(File $phpcs_file, $stack_ptr)
            {
                if ($this->isExcluded($phpcs_file)) {
                    return;
                }
        Severity: Minor
        Found in internal/PHP_CodeSniffer/Sniffs/ValidUnderscoreVariableNameSniff.php - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function finalizeProcess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function finalizeProcess(CodeBase $code_base): void
            {
                foreach (self::$method_return_types as $type_info) {
                    $function = $type_info->function;
                    $function_context = $function->getContext();
        Severity: Minor
        Found in .phan/plugins/MoreSpecificElementTypePlugin.php - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function extractMethodParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function extractMethodParams(SimpleXMLElement $param): array
            {
                if ($param->count() === 0) {
                    return [];
                }
        Severity: Minor
        Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                Issue $issue,
                string $file,
                int $line,
                array $template_parameters,
                Suggestion $suggestion = null,
        Severity: Minor
        Found in src/Phan/IssueInstance.php - About 45 mins to fix

          Function parseMethodSignature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parseMethodSignature(string $class_name, string $method_name): ?array
              {
                  $this->initStubs();
                  if ($class_name[0] !== '\\') {
                      $class_name = '\\' . $class_name;
          Severity: Minor
          Found in internal/lib/IncompatibleStubsSignatureDetector.php - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function getAnalyzeFunctionCallClosures has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
              {
                  /**
                   * Analyzes a printf-like function with a format directive in the first position.
                   * @param list<Node|string|int|float> $args the nodes for the arguments to the invocation
          Severity: Minor
          Found in .phan/plugins/PrintfCheckerPlugin.php - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function main()
              {
                  self::$basename = dirname(realpath(__DIR__));
                  $file_contents = array_merge(
                      self::readFileContents(self::$basename . '/tests/files/src'),
          Severity: Minor
          Found in internal/fuzz_test.php - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function computeKnownEntities has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function computeKnownEntities(): array
              {
                  $this->known_entities = [];
                  foreach (['doc-base/entities/global.ent', 'en/contributors.ent', 'en/extensions.ent', 'en/language-defs.ent', 'en/language-snippets.ent'] as $sub_path) {
                      $abs_path = "$this->doc_base_directory/$sub_path";
          Severity: Minor
          Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function analyzeAddressableElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function analyzeAddressableElement(
                  CodeBase $code_base,
                  AddressableElement $element
              ): void {
                  // Get the set of suppressed issues on the element
          Severity: Minor
          Found in .phan/plugins/UnusedSuppressionPlugin.php - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method parseFile has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function parseFile(CodeBase $code_base, string $file_path, bool $suppress_parse_errors = false, string $override_contents = null, bool $is_php_internal_stub = false, ?Request $request = null): Context
          Severity: Minor
          Found in src/Phan/Analysis.php - About 45 mins to fix

            Function extractUnionType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function extractUnionType(array $flags): UnionType
                {
                    static $type_lookup = null;
                    if ($type_lookup === null) {
                        $type_lookup = [
            Severity: Minor
            Found in internal/extract_arg_info.php - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function parseNodeInContext has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function parseNodeInContext(CodeBase $code_base, Context $context, Node $node)
                {
                    $kind = $node->kind;
                    $context->setLineNumberStart($node->lineno);
            
            
            Severity: Minor
            Found in src/Phan/Analysis.php - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method emitIssueAndSuggestion has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    CodeBase $code_base,
                    Context $context,
                    string $issue_type,
                    string $message,
                    array $args,
            Severity: Minor
            Found in .phan/plugins/UnknownElementTypePlugin.php - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language