edsonmedina/php_testability

View on GitHub

Showing 17 of 17 total issues

Function iterate has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function iterate (ContextInterface $parent)
    {
        $path = $parent->getName();
        if (is_dir($path)) {
            foreach (new \DirectoryIterator ($path) as $fileInfo)
Severity: Minor
Found in src/FileIterator.php - About 4 hrs 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 getName has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function getName() 
    {    
        $name      = '';
        $separator = '';

Severity: Minor
Found in src/NodeWrapper.php - About 3 hrs 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

Method getName has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getName() 
    {    
        $name      = '';
        $separator = '';

Severity: Major
Found in src/NodeWrapper.php - About 2 hrs to fix

    Method iterate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function iterate (ContextInterface $parent)
        {
            $path = $parent->getName();
            if (is_dir($path)) {
                foreach (new \DirectoryIterator ($path) as $fileInfo)
    Severity: Minor
    Found in src/FileIterator.php - About 1 hr to fix

      Method generateIndexFile has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generateIndexFile (ContextInterface $path)
          {
              // list directory
              $files = [];
              $dirs  = [];
      Severity: Minor
      Found in src/HTMLReport.php - About 1 hr to fix

        Function getContextsNumberOfIssues has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getContextsNumberOfIssues()
            {
                $list = [];
        
                foreach ($this->getChildren() as $child)
        Severity: Minor
        Found in src/Contexts/FileContext.php - About 1 hr 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

        Method methodMan has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function methodMan ($x, $y, $z)
            {
                // globals, over multiple lines
                global $boom,
                       $bass;
        Severity: Minor
        Found in testFile.php - About 1 hr to fix

          Method getContextsNumberOfIssues has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getContextsNumberOfIssues()
              {
                  $list = [];
          
                  foreach ($this->getChildren() as $child)
          Severity: Minor
          Found in src/Contexts/FileContext.php - About 1 hr to fix

            Function leaveNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function leaveNode (PhpParser\Node $node) 
                {
                    // check for "new" statements
                    if ($node instanceof Expr\New_ && !$this->inGlobalScope() && !$this->insideThrow) 
                    {
            Severity: Minor
            Found in src/NodeVisitors/NewVisitor.php - About 55 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 leaveNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function leaveNode (PhpParser\Node $node) 
                {
                    if ($node instanceof Expr\ClassConstFetch && !$this->inGlobalScope())
                    {
                        $parentClass = $this->stack->findContextOfType(new CollectionSpecification);
            Severity: Minor
            Found in src/NodeVisitors/ClassConstantFetchVisitor.php - About 45 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 enterNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function enterNode (PhpParser\Node $node) 
                {
                    if ($this->isClass($node)) 
                    {
                        // create new context, keep parent
            Severity: Minor
            Found in src/NodeVisitors/ClassVisitor.php - About 35 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

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in src/Dictionary.php - About 30 mins to fix

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

                  public function getIssues ($recursive = false, ContextSpecificationInterface $filter = null)
                  {
                      $list = $this->issues;
              
                      if ($recursive === true)
              Severity: Minor
              Found in src/AbstractContext.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 isDirExcluded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function isDirExcluded ($path)
                  {
                      foreach ($this->excludedDirs as $needle)
                      {
                          if (empty($needle)) {
              Severity: Minor
              Found in src/FileIterator.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 leaveNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function leaveNode (PhpParser\Node $node) 
                  {
                      // check for empty catch statements
                      if ($node instanceof Stmt\Catch_)
                      {
              Severity: Minor
              Found in src/NodeVisitors/CatchVisitor.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 hasIssues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function hasIssues ($recursive = false, ContextSpecificationInterface $filter = null)
                  {
                      if ($recursive === true)
                      {
                          foreach ($this->getChildrenRecursively($filter) as $child)
              Severity: Minor
              Found in src/AbstractContext.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 enterNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function enterNode (PhpParser\Node $node) 
                  {
                      if ($node instanceof Stmt\ClassMethod) 
                      {
                          // create new context, keep parent
              Severity: Minor
              Found in src/NodeVisitors/MethodVisitor.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