Dhii/simple-test-abstract

View on GitHub

Showing 160 of 160 total issues

AbstractStatefulTester has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class AbstractStatefulTester extends AbstractTester
{
    /** @var Writer\WriterInterface */
    protected $writer;
    /** @var Stats\AggregatorInterface */
Severity: Minor
Found in src/Tester/AbstractStatefulTester.php - About 2 hrs to fix

    Method _runTest has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _runTest(Test\TestBaseInterface $test)
        {
            $assertionMaker  = $this->_getAssertionMaker();
            $countAssertions = $assertionMaker instanceof Assertion\AccountableInterface;
            if ($countAssertions) {
    Severity: Major
    Found in src/Runner/AbstractRunner.php - About 2 hrs to fix

      Method _resolvePathSpec has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function _resolvePathSpec($paths)
          {
              $resolved = array();
      
              // Strings treaded as file patterns, but existing file paths treated literally
      Severity: Minor
      Found in src/Locator/AbstractFilePathLocator.php - About 1 hr to fix

        Method _getCalculators has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _getCalculators()
            {
                return array(
                    'assertion_count' => function ($totals, $code, $source) {
                        if ($source instanceof Assertion\AccountableInterface) {
        Severity: Minor
        Found in src/Test/AbstractAggregator.php - About 1 hr to fix

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

              protected function _resolvePathSpec($paths)
              {
                  $resolved = array();
          
                  // Strings treaded as file patterns, but existing file paths treated literally
          Severity: Minor
          Found in src/Locator/AbstractFilePathLocator.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

          Method _createResultFromTest has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              abstract protected function _createResultFromTest(Test\TestBaseInterface $test, $message, $status, $assertionCount, $runnerCode, $time, $memory);
          Severity: Major
          Found in src/Runner/AbstractRunner.php - About 50 mins to fix

            Method _processTestResult has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                protected function _processTestResult(Test\TestBaseInterface $test, $status, $message, $assertionCount, $time, $memory)
            Severity: Minor
            Found in src/Runner/AbstractRunner.php - About 45 mins to fix

              The class AbstractStatefulTester has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
              Open

              abstract class AbstractStatefulTester extends AbstractTester
              {
                  /** @var Writer\WriterInterface */
                  protected $writer;
                  /** @var Stats\AggregatorInterface */
              Severity: Minor
              Found in src/Tester/AbstractStatefulTester.php by phpmd

              CouplingBetweenObjects

              Since: 1.1.0

              A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

              Example

              class Foo {
                  /**
                   * @var \foo\bar\X
                   */
                  private $x = null;
              
                  /**
                   * @var \foo\bar\Y
                   */
                  private $y = null;
              
                  /**
                   * @var \foo\bar\Z
                   */
                  private $z = null;
              
                  public function setFoo(\Foo $foo) {}
                  public function setBar(\Bar $bar) {}
                  public function setBaz(\Baz $baz) {}
              
                  /**
                   * @return \SplObjectStorage
                   * @throws \OutOfRangeException
                   * @throws \InvalidArgumentException
                   * @throws \ErrorException
                   */
                  public function process(\Iterator $it) {}
              
                  // ...
              }

              Source https://phpmd.org/rules/design.html#couplingbetweenobjects

              The class AbstractRunner has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13.
              Open

              abstract class AbstractRunner implements RunnerInterface
              {
                  protected $coordinator;
                  protected $assertionMaker;
                  protected $statAggregator;
              Severity: Minor
              Found in src/Runner/AbstractRunner.php by phpmd

              CouplingBetweenObjects

              Since: 1.1.0

              A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

              Example

              class Foo {
                  /**
                   * @var \foo\bar\X
                   */
                  private $x = null;
              
                  /**
                   * @var \foo\bar\Y
                   */
                  private $y = null;
              
                  /**
                   * @var \foo\bar\Z
                   */
                  private $z = null;
              
                  public function setFoo(\Foo $foo) {}
                  public function setBar(\Bar $bar) {}
                  public function setBaz(\Baz $baz) {}
              
                  /**
                   * @return \SplObjectStorage
                   * @throws \OutOfRangeException
                   * @throws \InvalidArgumentException
                   * @throws \ErrorException
                   */
                  public function process(\Iterator $it) {}
              
                  // ...
              }

              Source https://phpmd.org/rules/design.html#couplingbetweenobjects

              Missing class import via use statement (line '76', column '23').
              Open

                          throw new \InvalidArgumentException(sprintf('Could not add test "%3$s" to suite "%1$s": test already belongs to suite "%2$s"', $this->getCode(), $test->getSuiteCode(), $test->getKey()));
              Severity: Minor
              Found in src/Suite/AbstractSuite.php by phpmd

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

              Missing class import via use statement (line '163', column '23').
              Open

                          throw new \RuntimeException(sprintf('Could not retrieve class name: cannot read file "%1$s"', $path));

              MissingImport

              Since: 2.7.0

              Importing all external classes in a file through use statements makes them clearly visible.

              Example

              function make() {
                  return new \stdClass();
              }

              Source http://phpmd.org/rules/cleancode.html#MissingImport

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

                  protected function _getCalculators()
                  {
                      return array(
                          'assertion_count' => function ($totals, $code, $source) {
                              if ($source instanceof Assertion\AccountableInterface) {
              Severity: Minor
              Found in src/Test/AbstractAggregator.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 _getFilePaths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function _getFilePaths()
                  {
                      $results = array();
                      foreach ($this->_getPathsSpecs() as $_pathExpr) {
                          $paths = $this->_resolvePathSpec($_pathExpr);
              Severity: Minor
              Found in src/Locator/AbstractFilePathLocator.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

              Avoid unused local variables such as '$iterator'.
              Open

                      if (is_null($iterator = $this->_getInnerIterator())) {

              UnusedLocalVariable

              Since: 0.2

              Detects when a local variable is declared and/or assigned, but not used.

              Example

              class Foo {
                  public function doSomething()
                  {
                      $i = 5; // Unused
                  }
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

              Avoid unused local variables such as '$_misc'.
              Open

                      foreach ($paths as $_path => $_misc) {

              UnusedLocalVariable

              Since: 0.2

              Detects when a local variable is declared and/or assigned, but not used.

              Example

              class Foo {
                  public function doSomething()
                  {
                      $i = 5; // Unused
                  }
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

              Avoid assigning values to variables in if clauses and the like (line '31', column '21').
              Open

                  public function getInnerIterator()
                  {
                      if (is_null($iterator = $this->_getInnerIterator())) {
                          $this->_setInnerIterator($this->_createInnerIterator());
                      }

              IfStatementAssignment

              Since: 2.7.0

              Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($foo = 'bar') { // possible typo
                          // ...
                      }
                      if ($baz = 0) { // always false
                          // ...
                      }
                  }
              }

              Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

              Avoid assigning values to variables in if clauses and the like (line '28', column '15').
              Open

                  public function locate()
                  {
                      if (!($class = $this->_getClass())) {
                          throw new RuntimeException(sprintf('Could not locate tests from class: Class must be specified'));
                      }
              Severity: Minor
              Found in src/Locator/AbstractClassLocator.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

              Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($foo = 'bar') { // possible typo
                          // ...
                      }
                      if ($baz = 0) { // always false
                          // ...
                      }
                  }
              }

              Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

              Avoid unused parameters such as '$source'.
              Open

                  protected function _any($target, $data = null, $source = null)

              UnusedFormalParameter

              Since: 0.2

              Avoid passing parameters to methods or constructors and then not using those parameters.

              Example

              class Foo
              {
                  private function bar($howdy)
                  {
                      // $howdy is not used
                  }
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

              Avoid assigning values to variables in if clauses and the like (line '134', column '15').
              Open

                  protected function _getFileTests($path)
                  {
                      if (!($className = $this->_retrieveFileClassName($path))) {
                          return array();
                      }

              IfStatementAssignment

              Since: 2.7.0

              Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

              Example

              class Foo
              {
                  public function bar($flag)
                  {
                      if ($foo = 'bar') { // possible typo
                          // ...
                      }
                      if ($baz = 0) { // always false
                          // ...
                      }
                  }
              }

              Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

              Avoid unused local variables such as '$status'.
              Open

                      $status = $result->getStatus();
              Severity: Minor
              Found in src/Runner/AbstractRunner.php by phpmd

              UnusedLocalVariable

              Since: 0.2

              Detects when a local variable is declared and/or assigned, but not used.

              Example

              class Foo {
                  public function doSomething()
                  {
                      $i = 5; // Unused
                  }
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

              Severity
              Category
              Status
              Source
              Language