Showing 4,886 of 4,939 total issues

Method getReturnTypeOverridesStatic has 297 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getReturnTypeOverridesStatic(CodeBase $code_base): array
    {
        $string_union_type = StringType::instance(false)->asPHPDocUnionType();
        $string_union_type_real = StringType::instance(false)->asRealUnionType();
        $string_union_type_with_false_in_real = UnionType::fromFullyQualifiedPHPDocAndRealString('string', 'string|false');
Severity: Major
Found in src/Phan/Plugin/Internal/DependentReturnTypeOverridePlugin.php - About 1 day to fix

    Function analyzeReturnTypesInner has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
    Open

        private function analyzeReturnTypesInner(CodeBase $code_base): void
        {
            if ($this->isPHPInternal()) {
                // nothing to do, no known Node
                return;
    Severity: Minor
    Found in src/Phan/Language/Element/FunctionTrait.php - About 1 day 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 analyzeParameterTypesInner has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function analyzeParameterTypesInner(
            CodeBase $code_base,
            FunctionInterface $method
        ): void {
            if (Config::getValue('check_docblock_signature_param_type_match')) {
    Severity: Minor
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 day 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 addProperty has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
    Open

        private function addProperty(Clazz $class, string $property_name, $default_node, UnionType $real_union_type, ?Comment\Parameter $variable, int $lineno, int $flags, ?string $doc_comment, Comment $property_comment): ?Property
        {
            $variable_has_literals = $variable && $variable->getUnionType()->hasLiterals();
    
            // If something goes wrong will getting the type of
    Severity: Minor
    Found in src/Phan/Parse/ParseVisitor.php - About 1 day 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

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

        protected function getAvailableMethodPHPDocSummaries(): array
        {
            return $this->memoize(__METHOD__, /** @return array<string,string> */ function (): array {
                $code_base = $this->code_base;
                $function_name_map = [];
    Severity: Major
    Found in internal/lib/IncompatibleStubsSignatureDetector.php and 1 other location - About 1 day to fix
    internal/lib/IncompatibleRealStubsSignatureDetector.php on lines 435..473

    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 312.

    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

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

        protected function getAvailableMethodPHPDocSummaries(): array
        {
            return $this->memoize(__METHOD__, /** @return array<string,string> */ function (): array {
                $code_base = $this->code_base;
                $function_name_map = [];
    Severity: Major
    Found in internal/lib/IncompatibleRealStubsSignatureDetector.php and 1 other location - About 1 day to fix
    internal/lib/IncompatibleStubsSignatureDetector.php on lines 416..454

    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 312.

    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 canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
        {
            // Fast-track most common cases first
            $type_set = $this->type_set;
            // If either type is unknown, we can't call it
    Severity: Major
    Found in src/Phan/Language/UnionType.php and 1 other location - About 1 day to fix
    src/Phan/Language/UnionType.php on lines 2645..2703

    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 305.

    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 isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
        {
            // Fast-track most common cases first
            $type_set = $this->type_set;
            // If either type is unknown, we can't call it
    Severity: Major
    Found in src/Phan/Language/UnionType.php and 1 other location - About 1 day to fix
    src/Phan/Language/UnionType.php on lines 2573..2631

    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 305.

    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 warnAboutVariableGraph has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

        private function warnAboutVariableGraph(
            Node $method_node,
            VariableGraph $graph,
            array $issue_overrides_for_definition_ids
        ): void {
    Severity: Minor
    Found in src/Phan/Plugin/Internal/VariableTrackerPlugin.php - About 1 day 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 loadMethodPlugins has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function loadMethodPlugins(CodeBase $code_base): void
        {
            $plugin_set = ConfigPluginSet::instance();
            $return_type_overrides = $plugin_set->getReturnTypeOverrides($code_base);
            $return_type_override_fqsen_strings = [];
    Severity: Minor
    Found in src/Phan/Analysis.php - About 1 day 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 analyzeParameterListForCallback has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function analyzeParameterListForCallback(
            CodeBase $code_base,
            FunctionInterface $method,
            array $arg_nodes,
            Context $context,
    Severity: Minor
    Found in src/Phan/Analysis/ArgumentType.php - About 1 day 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 resolveDocCommentForClosure has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function resolveDocCommentForClosure(PhpParser\Node\Expression $node): ?string
        {
            $doc_comment = $node->getDocCommentText();
            if (\Phan\Library\StringUtil::isNonZeroLengthString($doc_comment)) {
                return $doc_comment;
    Severity: Minor
    Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 1 day 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 fromStringInContext has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromStringInContext(
            string $string,
            Context $context,
            int $source,
            CodeBase $code_base = null
    Severity: Minor
    Found in src/Phan/Language/Type.php - About 1 day 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

    InferPureVisitor has 69 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class InferPureVisitor extends AnalysisVisitor
    {
        /** @var string the function fqsen being visited */
        protected $function_fqsen_label;
    
    
    Severity: Major
    Found in src/Phan/AST/InferPureVisitor.php - About 1 day to fix

      File AssignOperatorAnalysisVisitor.php has 583 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace Phan\Analysis;
      Severity: Major
      Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 1 day to fix

        File GenericArrayType.php has 582 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace Phan\Language\Type;
        Severity: Major
        Found in src/Phan/Language/Type/GenericArrayType.php - About 1 day to fix

          Function analyzeOverrideSignatureForOverriddenMethod has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function analyzeOverrideSignatureForOverriddenMethod(
                  CodeBase $code_base,
                  Method $method,
                  Clazz $class,
                  Method $o_method
          Severity: Minor
          Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 day 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

          File ArrayReturnTypeOverridePlugin.php has 573 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace Phan\Plugin\Internal;
          Severity: Major
          Found in src/Phan/Plugin/Internal/ArrayReturnTypeOverridePlugin.php - About 1 day to fix

            File IssueFixSuggester.php has 571 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            declare(strict_types=1);
            
            namespace Phan;
            Severity: Major
            Found in src/Phan/IssueFixSuggester.php - About 1 day to fix

              File DependencyGraphPlugin.php has 570 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              declare(strict_types=1);
              
              namespace Phan\Plugin\Internal;
              Severity: Major
              Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 1 day to fix
                Severity
                Category
                Status
                Source
                Language