eugene-matvejev/battleship-game-api

View on GitHub

Showing 13 of 153 total issues

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

          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

          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

            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

            Function successfulInitAction_XML has a Cognitive Complexity of 7 (exceeds 5 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 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 unsuccessfulTurnActionOnDeadCell has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function unsuccessfulTurnActionOnDeadCell(array $response)
                {
                    foreach ($response as $battlefield) {
                        if ($battlefield->player->flags === PlayerModel::FLAG_AI_CONTROLLED) {
                            foreach ($battlefield->cells as $cell) {
            Severity: Minor
            Found in tests/phpunit/GameBundle/Controller/GameControllerTest.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 getAdjacentCells has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getAdjacentCells(Battlefield $battlefield, int $levels = 1, int $onlyFlag = CellModel::FLAG_NONE, int $excludeFlag = CellModel::FLAG_NONE) : array
                {
                    $cells = [];
                    foreach (static::$extendedPaths as $path) {
                        $this->setPath($path);
            Severity: Minor
            Found in src/GameBundle/Service/CoordinateSystem/PathProcessor.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 chooseStrategy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function chooseStrategy(Cell $cell) : int
                {
                    $processor = new PathProcessor($cell->getCoordinate());
            
                    $battlefield = $cell->getBattlefield();
            Severity: Minor
            Found in src/GameBundle/Service/AI/AIStrategyService.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 addBattlefield has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addBattlefield()
                {
                    $game = MockFactory::getGameMock();
                    $game->getBattlefields()[0]
                        ->setPlayer(MockFactory::getAIPlayerMock(''))
            Severity: Minor
            Found in tests/phpunit/GameBundle/Response/GameInitiationResponseTest.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 processPlayerTurnOnBattlefields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function processPlayerTurnOnBattlefields(Game $game, Player $attacker, Cell $cell) : bool
                {
                    foreach ($game->getBattlefields() as $battlefield) {
                        try {
                            if ($this->processPlayerTurnOnBattlefield($battlefield, $attacker, $cell)) {
            Severity: Minor
            Found in src/GameBundle/Service/GameSystem/GameProcessor.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