src/Phan/AST/Visitor/Element.php

Summary

Maintainability
D
2 days
Test Coverage

The class Element has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
Open

class Element
{
    use \Phan\Profile;

    /**
Severity: Minor
Found in src/Phan/AST/Visitor/Element.php by phpmd

The class Element has 11 public methods. Consider refactoring Element to keep number of public methods under 10.
Open

class Element
{
    use \Phan\Profile;

    /**
Severity: Minor
Found in src/Phan/AST/Visitor/Element.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

File Element.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\AST\Visitor;
Severity: Minor
Found in src/Phan/AST/Visitor/Element.php - About 3 hrs to fix

    Avoid too many return statements within this method.
    Open

                    return $visitor->visitMagicTrait($this->node);
    Severity: Major
    Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $visitor->visitMagicNamespace($this->node);
      Severity: Major
      Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return $visitor->visitUnionTypeString($this->node);
        Severity: Major
        Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $visitor->visitUnionTypeFalse($this->node);
          Severity: Major
          Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $visitor->visitUnionTypeNull($this->node);
            Severity: Major
            Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $visitor->visitClassAnonymous($this->node);
              Severity: Major
              Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $visitor->visitUnionTypeLong($this->node);
                Severity: Major
                Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return $visitor->visitExecRequireOnce($this->node);
                  Severity: Major
                  Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $visitor->visitMagicLine($this->node);
                    Severity: Major
                    Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $visitor->visitUnionTypeObject($this->node);
                      Severity: Major
                      Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $visitor->visitMagicMethod($this->node);
                        Severity: Major
                        Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $visitor->visitUnionTypeStatic($this->node);
                          Severity: Major
                          Found in src/Phan/AST/Visitor/Element.php - About 30 mins to fix

                            The method acceptTypeFlagVisitor() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                            Open

                                public function acceptTypeFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\TYPE_ARRAY:
                                            return $visitor->visitUnionTypeArray($this->node);
                            Severity: Minor
                            Found in src/Phan/AST/Visitor/Element.php by phpmd

                            CyclomaticComplexity

                            Since: 0.1

                            Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                            Example

                            // Cyclomatic Complexity = 11
                            class Foo {
                            1   public function example() {
                            2       if ($a == $b) {
                            3           if ($a1 == $b1) {
                                            fiddle();
                            4           } elseif ($a2 == $b2) {
                                            fiddle();
                                        } else {
                                            fiddle();
                                        }
                            5       } elseif ($c == $d) {
                            6           while ($c == $d) {
                                            fiddle();
                                        }
                            7        } elseif ($e == $f) {
                            8           for ($n = 0; $n < $h; $n++) {
                                            fiddle();
                                        }
                                    } else {
                                        switch ($z) {
                            9               case 1:
                                                fiddle();
                                                break;
                            10              case 2:
                                                fiddle();
                                                break;
                            11              case 3:
                                                fiddle();
                                                break;
                                            default:
                                                fiddle();
                                                break;
                                        }
                                    }
                                }
                            }

                            Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

                                public function acceptClassFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\CLASS_ABSTRACT:
                                            return $visitor->visitClassAbstract($this->node);
                            Severity: Major
                            Found in src/Phan/AST/Visitor/Element.php and 1 other location - About 2 hrs to fix
                            src/Phan/AST/Visitor/Element.php on lines 328..344

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

                            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 acceptExecFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\EXEC_EVAL:
                                            return $visitor->visitExecEval($this->node);
                            Severity: Major
                            Found in src/Phan/AST/Visitor/Element.php and 1 other location - About 2 hrs to fix
                            src/Phan/AST/Visitor/Element.php on lines 226..242

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function acceptUseFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\USE_CONST:
                                            return $visitor->visitUseConst($this->node);
                            Severity: Major
                            Found in src/Phan/AST/Visitor/Element.php and 2 other locations - About 55 mins to fix
                            src/Phan/AST/Visitor/Element.php on lines 251..263
                            src/Phan/AST/Visitor/Element.php on lines 307..319

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function acceptUnaryFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\UNARY_BITWISE_NOT:
                                            return $visitor->visitUnaryBitwiseNot($this->node);
                            Severity: Major
                            Found in src/Phan/AST/Visitor/Element.php and 2 other locations - About 55 mins to fix
                            src/Phan/AST/Visitor/Element.php on lines 251..263
                            src/Phan/AST/Visitor/Element.php on lines 384..396

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

                            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 3 locations. Consider refactoring.
                            Open

                                public function acceptNameFlagVisitor(FlagVisitor $visitor)
                                {
                                    switch ($this->node->flags) {
                                        case flags\NAME_FQ:
                                            return $visitor->visitNameFq($this->node);
                            Severity: Major
                            Found in src/Phan/AST/Visitor/Element.php and 2 other locations - About 55 mins to fix
                            src/Phan/AST/Visitor/Element.php on lines 307..319
                            src/Phan/AST/Visitor/Element.php on lines 384..396

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status