Showing 4,886 of 4,939 total issues

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

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

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

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

      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 getAvailablePropertyPHPDocSummaries(): array
          {
              return $this->memoize(__METHOD__, /** @return array<string,string> */ function (): array {
                  $code_base = $this->code_base;
                  $map = [];
      Severity: Major
      Found in internal/lib/IncompatibleRealStubsSignatureDetector.php and 1 other location - About 1 day to fix
      internal/lib/IncompatibleStubsSignatureDetector.php on lines 284..318

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

      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

          public function parseMethodSignature(string $class_name, string $method_name): ?array
          {
              $this->initStubs();
              if ($class_name[0] !== '\\') {
                  $class_name = '\\' . $class_name;
      Severity: Major
      Found in internal/lib/IncompatibleRealStubsSignatureDetector.php and 1 other location - About 1 day to fix
      internal/lib/IncompatibleStubsSignatureDetector.php on lines 172..208

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

      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

          public function parseMethodSignature(string $class_name, string $method_name): ?array
          {
              $this->initStubs();
              if ($class_name[0] !== '\\') {
                  $class_name = '\\' . $class_name;
      Severity: Major
      Found in internal/lib/IncompatibleStubsSignatureDetector.php and 1 other location - About 1 day to fix
      internal/lib/IncompatibleRealStubsSignatureDetector.php on lines 186..221

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

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

          public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
          {
              // Expand it to include all parent types up the chain
              try {
                  $argument_type_expanded_resolved =
      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

      File Parameter.php has 555 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

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

            protected function canCastToNonNullableType(Type $type): bool
            {
                if ($type instanceof ArrayType) {
                    if ($type instanceof GenericArrayType) {
                        return $this->canCastToGenericArrayKeys($type) &&
        Severity: Major
        Found in src/Phan/Language/Type/ArrayShapeType.php and 1 other location - About 1 day to fix
        src/Phan/Language/Type/ArrayShapeType.php on lines 340..386

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

        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

            protected function canCastToNonNullableTypeWithoutConfig(Type $type): bool
            {
                if ($type instanceof ArrayType) {
                    if ($type instanceof GenericArrayType) {
                        // TODO: WithoutConfig here as well?
        Severity: Major
        Found in src/Phan/Language/Type/ArrayShapeType.php and 1 other location - About 1 day to fix
        src/Phan/Language/Type/ArrayShapeType.php on lines 288..333

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

        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 getReturnTypeOverridesStatic has a Cognitive Complexity of 57 (exceeds 5 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: Minor
        Found in src/Phan/Plugin/Internal/DependentReturnTypeOverridePlugin.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 shouldWarnAboutImpossibleArrayKeyExists has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function shouldWarnAboutImpossibleArrayKeyExists(CodeBase $code_base, Context $context, array $args, ?UnionType $key_type = null, ?UnionType $array_type = null): bool
            {
                $array_type = $array_type ?? UnionTypeVisitor::unionTypeFromNode($code_base, $context, $args[1]);
                if (!$array_type->hasRealTypeSet()) {
                    return false;
        Severity: Minor
        Found in src/Phan/Plugin/Internal/MiscParamPlugin.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

        CLI has 61 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class CLI
        {
            /**
             * This should be updated to x.y.z-dev after every release, and x.y.z before a release.
             */
        Severity: Major
        Found in src/Phan/CLI.php - About 1 day to fix

          Method fromStringInContext has 218 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function fromStringInContext(
                  string $string,
                  Context $context,
                  int $source,
                  CodeBase $code_base = null
          Severity: Major
          Found in src/Phan/Language/Type.php - About 1 day to fix

            File Phan.php has 528 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

              Function analyzeClassConstantTypes has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function analyzeClassConstantTypes(CodeBase $code_base, Clazz $clazz): void
                  {
                      foreach ($clazz->getConstantMap($code_base) as $constant) {
                          // This phase is done before the analysis phase, so there aren't any dynamic properties to filter out.
              
              
              Severity: Minor
              Found in src/Phan/Analysis/ClassConstantTypesAnalyzer.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 RedundantConditionVisitor.php has 524 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/RedundantConditionVisitor.php - About 1 day to fix

                File PropertyDocumentationMap.php has 522 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php // phpcs:ignoreFile
                namespace Phan\Language\Internal;
                
                /**
                 * This contains descriptions used by Phan for hover text of internal properties in the language server mode.
                Severity: Major
                Found in src/Phan/Language/Internal/PropertyDocumentationMap.php - About 1 day to fix

                  Method getProperty has 213 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getProperty(
                          bool $is_static,
                          bool $is_known_assignment = false
                      ): Property {
                          $node = $this->node;
                  Severity: Major
                  Found in src/Phan/AST/ContextNode.php - About 1 day to fix

                    Method analyzePrintfPattern has 211 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function analyzePrintfPattern(CodeBase $code_base, Context $context, FunctionInterface $function, $pattern_node, $arg_nodes): void
                        {
                            // Given a node, extract the printf directive and whether or not it could be translated
                            $primitive_for_fmtstr = $this->astNodeToPrimitive($code_base, $context, $pattern_node);
                            /**
                    Severity: Major
                    Found in .phan/plugins/PrintfCheckerPlugin.php - About 1 day to fix
                      Severity
                      Category
                      Status
                      Source
                      Language