Showing 4,939 of 4,939 total issues

FlagVisitorImplementation has 74 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class FlagVisitorImplementation implements FlagVisitor
{

    /**
     * This is called to analyze nodes in FlagVisitorImplementation subclasses
Severity: Major
Found in src/Phan/AST/Visitor/FlagVisitorImplementation.php - About 1 day to fix

    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

    File LanguageServer.php has 595 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      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 ASTSimplifier.php has 583 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace Phan\AST;
          Severity: Major
          Found in src/Phan/AST/ASTSimplifier.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 PrintfCheckerPlugin.php has 573 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare(strict_types=1);
                
                namespace Phan\Plugin\PrintfCheckerPlugin;
                Severity: Major
                Found in .phan/plugins/PrintfCheckerPlugin.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

                      Method getAnalyzeFunctionCallClosuresStatic has 242 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static function getAnalyzeFunctionCallClosuresStatic(): array
                          {
                              /**
                               * @param Closure(UnionType):int $checker returns _IS_IMPOSSIBLE/_IS_REDUNDANT/_IS_REASONABLE_CONDITION
                               * @param string $expected_type
                      Severity: Major
                      Found in src/Phan/Plugin/Internal/RedundantConditionCallPlugin.php - About 1 day to fix

                        File Context.php has 569 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

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