kahlan/kahlan

View on GitHub
src/Reporter/Coverage/Collector.php

Summary

Maintainability
C
1 day
Test Coverage

Function _coverage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _coverage($file, $coverage)
    {
        $result = [];
        $root = $this->parse($file);
        foreach ($root->lines['content'] as $num => $content) {
Severity: Minor
Found in src/Reporter/Coverage/Collector.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

File Collector.php has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Kahlan\Reporter\Coverage;

use Kahlan\Jit\Parser;
use Kahlan\Dir\Dir;
Severity: Minor
Found in src/Reporter/Coverage/Collector.php - About 2 hrs to fix

    Method _coverage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _coverage($file, $coverage)
        {
            $result = [];
            $root = $this->parse($file);
            foreach ($root->lines['content'] as $num => $content) {
    Severity: Minor
    Found in src/Reporter/Coverage/Collector.php - About 1 hr to fix

      Method __construct has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct($config = [])
          {
              $defaults = [
                  'driver'         => null,
                  'path'           => [],
      Severity: Minor
      Found in src/Reporter/Coverage/Collector.php - About 1 hr to fix

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

            public function addFile($file, $coverage)
            {
                $file = $this->realpath($file);
                if (!$this->collectable($file)) {
                    return;
        Severity: Minor
        Found in src/Reporter/Coverage/Collector.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 _processMetrics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _processMetrics($file, $node, $coverage)
            {
                $metrics = [
                    'loc'      => 0,
                    'nlloc'    => 0,
        Severity: Minor
        Found in src/Reporter/Coverage/Collector.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

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

            protected function _processNode($file, $node, $coverage, $path)
            {
                if ($node->type === 'namespace') {
                    $path = "{$path}" . $node->name . '\\';
                    $this->_processTree($file, $node->tree, $coverage, $path);
        Severity: Minor
        Found in src/Reporter/Coverage/Collector.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

        There are no issues that match your filters.

        Category
        Status