WeCamp/flyingliquourice

View on GitHub

Showing 17 of 17 total issues

Function generate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function generate($width, $height, array $shipSizes)
    {
        Assertion::integer($width);
        Assertion::integer($height);
        Assertion::allInteger($shipSizes);
Severity: Minor
Found in src/Domain/Game/FieldsGenerator.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

Function __toString has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function __toString()
    {
        if ($this->hasSunkenShip()) {
            return '🔥 ';
        }
Severity: Minor
Found in src/Domain/Game/Field.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 generate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function generate($width, $height, array $shipSizes)
    {
        Assertion::integer($width);
        Assertion::integer($height);
        Assertion::allInteger($shipSizes);
Severity: Minor
Found in src/Domain/Game/FieldsGenerator.php - About 1 hr to fix

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

        public function __toString()
        {
            $result     = PHP_EOL;
            $currentRow = 0;
            $rows       = 0;
    Severity: Minor
    Found in src/Domain/Game/Fields.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 fire has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function fire(Coords $coords)
        {
            if ($this->locked()) {
                throw new GameIsLockedException;
            }
    Severity: Minor
    Found in src/Domain/Game.php - About 1 hr to fix

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

          public function __toString()
          {
              $result     = PHP_EOL;
              $currentRow = 0;
              $rows       = 0;
      Severity: Minor
      Found in src/Domain/Game/Fields.php - About 1 hr to fix

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

            public function __toString()
            {
                if ($this->hasSunkenShip()) {
                    return '🔥 ';
                }
        Severity: Minor
        Found in src/Domain/Game/Field.php - About 1 hr to fix

          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function __construct(Identifier $id, Grid $grid, Score $score, array $fireResults = [], $locked = false)
          Severity: Minor
          Found in src/Domain/Game.php - About 35 mins to fix

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

                public static function fromArray(array $data)
                {
                    $ships = [];
                    foreach ($data['ships'] as $ship) {
                        $ships[] = Ship::fromArray($ship);
            Severity: Minor
            Found in src/Domain/Game/Fields.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 '< ';
            Severity: Major
            Found in src/Domain/Game/Field.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return 'ǁ ';
              Severity: Major
              Found in src/Domain/Game/Field.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return 'v ';
                Severity: Major
                Found in src/Domain/Game/Field.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return '  ';
                  Severity: Major
                  Found in src/Domain/Game/Field.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return '> ';
                    Severity: Major
                    Found in src/Domain/Game/Field.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return '= ';
                      Severity: Major
                      Found in src/Domain/Game/Field.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $neighbour->coords();
                        Severity: Major
                        Found in src/Domain/Game/FieldsGenerator.php - About 30 mins to fix

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

                              private static function validEndpoint(Fields $fields, Coords $spot, $shipSize, $direction)
                              {
                                  /** @var Field $field */
                                  $field = $fields->at($spot);
                                  if ($field->occupied()) {
                          Severity: Minor
                          Found in src/Domain/Game/FieldsGenerator.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