eugene-matvejev/battleship-game-api

View on GitHub

Showing 153 of 153 total issues

Avoid excessively long variable names like $coordinatesCollection. Keep variable name length under 20.
Open

    private function assertProcessCPUTurnResult(array $coordinatesCollection, array $expectedFlags)

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Method AdjacentCellsProvider has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function AdjacentCellsProvider() : array
    {

        $battlefield = MockFactory::getBattlefieldMock();
        $battlefield->getCellByCoordinate('A2')->setFlags(CellModel::FLAG_DEAD);

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

        public function successfulInitAction_XML()
        {
            $client = static::$client;
            $client->request(
                Request::METHOD_POST,
    Severity: Minor
    Found in tests/phpunit/GameBundle/Controller/GameControllerTest.php - About 1 hr to fix

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

          public function successfulInitAction_JSON()
          {
              $client = static::$client;
              $client->request(
                  Request::METHOD_POST,
      Severity: Minor
      Found in tests/phpunit/GameBundle/Controller/GameControllerTest.php - About 1 hr to fix

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

            public function processPathsComplete()
            {
                $battlefield = MockFactory::getBattlefieldMock();
                $battlefield->getCellByCoordinate('B2')->setFlags(CellModel::FLAG_DEAD_SHIP);
        
        
        Severity: Minor
        Found in tests/phpunit/GameBundle/Service/AI/AIStrategyProcessorTest.php - About 1 hr to fix

          Each class must be in a namespace of at least one level (a top-level vendor name)
          Open

          class AppKernel extends Kernel
          Severity: Minor
          Found in app/AppKernel.php by phpcodesniffer

          Each class must be in a namespace of at least one level (a top-level vendor name)
          Open

          class AppCache extends HttpCache
          Severity: Minor
          Found in app/AppCache.php by phpcodesniffer

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

              public function successfulTurnAction(array $response)
              {
                  foreach ($response as $battlefield) {
                      if ($battlefield->player->flags !== PlayerModel::FLAG_AI_CONTROLLED) {
                          continue;
          Severity: Minor
          Found in tests/phpunit/GameBundle/Controller/GameControllerTest.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

          Avoid variables with short names like $om. Configured minimum length is 3.
          Open

              protected static $om;

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $om. Configured minimum length is 3.
          Open

                  $om   = $this->getDoctrine()->getManager();

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $ai. Configured minimum length is 3.
          Open

              private $ai;

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $ai. Configured minimum length is 3.
          Open

              public function __construct(AIService $ai)

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $om. Configured minimum length is 3.
          Open

                  $om = $this->getDoctrine()->getManager();

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $ai. Configured minimum length is 3.
          Open

              private static $ai;

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $om. Configured minimum length is 3.
          Open

              public function load(ObjectManager $om)

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

          Avoid variables with short names like $id. Configured minimum length is 3.
          Open

              protected $id;

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#shortvariable

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

              public function getAdjacentCells(string $initCoordinate, array $expectedCoordinates, Battlefield $battlefield, int $levels, int $onlyFlag, int $excludeFlag)
          Severity: Minor
          Found in tests/phpunit/GameBundle/Service/CoordinateSystem/PathProcessorTest.php - About 45 mins to fix

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

            class AppKernel extends Kernel
            {
                public function registerBundles() : array
                {
                    $bundles = [
            Severity: Minor
            Found in app/AppKernel.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

            Method name "PathProcessorTest::AdjacentCellsProvider" is not in camel caps format
            Open

                public function AdjacentCellsProvider() : array

            Function processPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function processPath(Battlefield $battlefield, int $path, string $coordinate) : Cell
                {
                    $processor = (new PathProcessor($coordinate))->setPath($path);
            
                    while (null !== $cell = $battlefield->getCellByCoordinate($processor->calculateNextCoordinate())) {
            Severity: Minor
            Found in src/GameBundle/Service/AI/AIStrategyProcessor.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

            Severity
            Category
            Status
            Source
            Language