amtgard/ORK3

View on GitHub
system/lib/ork3/class.Game.php

Summary

Maintainability
C
1 day
Test Coverage

File class.Game.php has 285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class Game extends Ork3 {

    public function __construct() {
Severity: Minor
Found in system/lib/ork3/class.Game.php - About 2 hrs to fix

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

    class Game extends Ork3 {
    
        public function __construct() {
            parent::__construct();
            $this->game = new yapo($this->db, DB_PREFIX . 'game');
    Severity: Minor
    Found in system/lib/ork3/class.Game.php - About 2 hrs to fix

      Method set_flag_capture_state has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function set_flag_capture_state($game_id, $objective_id, $state) {
              $game = $this->GetGame(array('GameId' => $game_id));
              $obj = $this->GetObjective(array('ObjectiveId' => $objective_id));
              if (count($game) == 0) return false;
              
      Severity: Minor
      Found in system/lib/ork3/class.Game.php - About 1 hr to fix

        Function set_game_state has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function set_game_state($game_id, $objective_id, $state) {
                if (valid_id($game_id) && valid_id($objective_id)) {
                    $this->objective->game_objective_id = $objective_id;
                    if ($this->objective->find() && $this->game->game_objective_id == $objective_id) {
                        $this->objective->state = json_encode($state);
        Severity: Minor
        Found in system/lib/ork3/class.Game.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 if_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function if_state($state_requirements, $state_source, $state_lookup, $if_match) {
                foreach ($state_requirements as $state_var => $value) {
                    if (is_array($value)) {
                        $comp = $value['Comparator'];
                        if (!$comp($state_lookup($state_source, $stat_var), $value['Value'])) return true;
        Severity: Minor
        Found in system/lib/ork3/class.Game.php - About 45 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 create_game has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function create_game($name, $type, $mundane_id, $configuration, $state) {
        Severity: Minor
        Found in system/lib/ork3/class.Game.php - About 35 mins to fix

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

              public function GetObjectives($request) {
                  $objectives = array();
                  if (valid_id($request['GameId'])) {
                      $this->objective->clear();
                      $this->objective->game_id = $request['GameId'];
          Severity: Minor
          Found in system/lib/ork3/class.Game.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 ValidateGameMaster has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function ValidateGameMaster($request) {
                  if ($this->game_security($request['GameId'], $request['Code'])) {
                      if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0) {
                          $this->game->clear();
                          $this->game->game_id = $request['GameId'];
          Severity: Minor
          Found in system/lib/ork3/class.Game.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 $State['TeamId'];
          Severity: Major
          Found in system/lib/ork3/class.Game.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return count($Objective)>0;
            Severity: Major
            Found in system/lib/ork3/class.Game.php - About 30 mins to fix

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

                  public function GetGameState($request) {
                      if (valid_id($request['GameId']) && valid_id($request['ObjectiveId'])) {
                          $x = $this->GetObjective($request);
                      } else if (valid_id($request['GameId'])) {
                          $x = $this->GetGame($request);
              Severity: Minor
              Found in system/lib/ork3/class.Game.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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public function __construct() {
                      parent::__construct();
                      $this->game = new yapo($this->db, DB_PREFIX . 'game');
                      $this->team = new yapo($this->db, DB_PREFIX . 'game_team');
                      $this->objective = new yapo($this->db, DB_PREFIX . 'game_objective');
              Severity: Minor
              Found in system/lib/ork3/class.Game.php and 1 other location - About 45 mins to fix
              system/lib/ork3/class.Treasury.php on lines 5..10

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 95.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status