Showing 4,939 of 4,939 total issues

Avoid too many return statements within this method.
Open

                return;
Severity: Major
Found in .phan/plugins/RemoveDebugStatementPlugin.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return;
    Severity: Major
    Found in .phan/plugins/NotFullyQualifiedUsagePlugin.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $node;
      Severity: Major
      Found in .phan/plugins/DuplicateExpressionPlugin.php - About 30 mins to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            public function visitClosure(Node $node): UnionType
            {
                // The type of a closure is the fqsen pointing
                // at its definition
                $closure_fqsen =
        Severity: Minor
        Found in src/Phan/AST/UnionTypeVisitor.php and 1 other location - About 30 mins to fix
        src/Phan/AST/FallbackUnionTypeVisitor.php on lines 481..501

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 90.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Avoid too many return statements within this method.
        Open

                        return;
        Severity: Major
        Found in .phan/plugins/PregRegexCheckerPlugin.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return true;
          Severity: Major
          Found in .phan/plugins/PossiblyStaticMethodPlugin.php - About 30 mins to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        'Microsoft\PhpParser\Node\Expression\ExitIntrinsicExpression' => static function (PhpParser\Node\Expression\ExitIntrinsicExpression $n, int $start_line): ast\Node {
                            $expression = $n->expression;
                            $expr_node = $expression !== null ? static::phpParserNodeToAstNode($expression) : null;
                            return new ast\Node(ast\AST_EXIT, 0, ['expr' => $expr_node], $start_line);
                        },
            Severity: Minor
            Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php and 1 other location - About 30 mins to fix
            src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php on lines 1502..1506

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 90.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public function getParentClass(CodeBase $code_base): Clazz
                {
                    if (!$this->parent_type) {
                        throw new LogicException("Class $this has no parent");
                    }
            Severity: Minor
            Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 30 mins to fix
            src/Phan/Language/Element/Clazz.php on lines 580..596

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 90.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                private function getParentClassWithoutHydrating(CodeBase $code_base): Clazz
                {
                    if (!$this->parent_type) {
                        throw new LogicException("Class $this has no parent");
                    }
            Severity: Minor
            Found in src/Phan/Language/Element/Clazz.php and 1 other location - About 30 mins to fix
            src/Phan/Language/Element/Clazz.php on lines 555..571

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 90.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        'Microsoft\PhpParser\Node\Statement\ReturnStatement' => static function (PhpParser\Node\Statement\ReturnStatement $n, int $start_line): ast\Node {
                            $e = $n->expression;
                            $expr_node = $e !== null ? static::phpParserNodeToAstNode($e) : null;
                            return new ast\Node(ast\AST_RETURN, 0, ['expr' => $expr_node], $start_line);
                        },
            Severity: Minor
            Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php and 1 other location - About 30 mins to fix
            src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php on lines 850..854

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 90.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function shouldParse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function shouldParse(string $file_path): bool
                {
                    $exclude_file_regex = Config::getValue('exclude_file_regex');
                    if ($exclude_file_regex && self::isPathMatchedByRegex($exclude_file_regex, $file_path)) {
                        return false;
            Severity: Minor
            Found in src/Phan/CLI.php - About 25 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 debugProgress has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function debugProgress(string $msg, float $p, $details): void
                {
                    $pct = \sprintf("%d%%", (int)(100 * self::boundPercentage($p)));
            
                    if ($details === null) {
            Severity: Minor
            Found in src/Phan/CLI.php - About 25 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 detectAndConfigureColorSupport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function detectAndConfigureColorSupport(array $opts): void
                {
                    if (is_string($opts['color-scheme'] ?? false)) {
                        \putenv('PHAN_COLOR_SCHEME=' . $opts['color-scheme']);
                    }
            Severity: Minor
            Found in src/Phan/CLI.php - About 25 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 renderInnerProgressBar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function renderInnerProgressBar(int $length, float $p): string
                {
                    $current_float = $p * $length;
                    $current = (int)$current_float;
                    $rest = \max($length - $current, 0);
            Severity: Minor
            Found in src/Phan/CLI.php - About 25 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 suggestSimilarNewInAnyNamespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function suggestSimilarNewInAnyNamespace(
                    string $namespace,
                    string $name,
                    Context $context,
                    bool $suggest_in_global_namespace
            Severity: Minor
            Found in src/Phan/CodeBase.php - About 25 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 labelForElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function labelForElement(TypedElementInterface $element): string
                {
                    if (self::useVSCodeCompletion()) {
                        $name = $element->getName();
                        if ($element instanceof Variable) {
            Severity: Minor
            Found in src/Phan/LanguageServer/CompletionRequest.php - About 25 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 recomputeFileList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function recomputeFileList(): void
                {
                    $this->file_list = $this->file_list_in_config;
            
                    if (!$this->file_list_only) {
            Severity: Minor
            Found in src/Phan/CLI.php - About 25 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 setLogFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function setLogFile($new_file): void
                {
                    if (!\is_resource($new_file)) {
                        throw new \TypeError("Expected newFile to be a resource, got " . \gettype($new_file));
                    }
            Severity: Minor
            Found in src/Phan/LanguageServer/Logger.php - About 25 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 createCompletionItem has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function createCompletionItem(
                    CodeBase $code_base,
                    TypedElementInterface $element,
                    ?string $prefix = null
                ): CompletionItem {
            Severity: Minor
            Found in src/Phan/LanguageServer/CompletionRequest.php - About 25 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 suggestSimilarClassInSameNamespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function suggestSimilarClassInSameNamespace(
                    FullyQualifiedClassName $missing_class,
                    Context $context,
                    int $class_suggest_type = IssueFixSuggester::CLASS_SUGGEST_ONLY_CLASSES
                ): array {
            Severity: Minor
            Found in src/Phan/CodeBase.php - About 25 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

            Severity
            Category
            Status
            Source
            Language