amtgard/ORK3

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

class Kingdom  extends Ork3 {

    public function __construct() {
Severity: Major
Found in system/lib/ork3/class.Kingdom.php - About 1 day to fix

    Function SetKingdomParkTitles has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        public function SetKingdomParkTitles($request) {
            $response = array();
            if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                    && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                $this->log->Write('Kingdom', $mundane_id, LOG_EDIT, $request);
    Severity: Minor
    Found in system/lib/ork3/class.Kingdom.php - About 4 hrs 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 GetAwardList has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function GetAwardList($request) {
            if ($request['IsLadder'] == 'Ladder') {
                $ladder_clause = " and ka.is_ladder = 1";
            } else if ($request['IsLadder'] == 'NonLadder') {
                $ladder_clause = " and ka.is_ladder = 0";
    Severity: Minor
    Found in system/lib/ork3/class.Kingdom.php - About 3 hrs 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

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

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

      Function SetKingdomDetails has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function SetKingdomDetails($request) {
              $response = array();
              if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                      && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                  $this->log->Write('Kingdom', $mundane_id, LOG_EDIT, $request);
      Severity: Minor
      Found in system/lib/ork3/class.Kingdom.php - About 2 hrs 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 SetKingdomParkTitles has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function SetKingdomParkTitles($request) {
              $response = array();
              if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                      && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                  $this->log->Write('Kingdom', $mundane_id, LOG_EDIT, $request);
      Severity: Major
      Found in system/lib/ork3/class.Kingdom.php - About 2 hrs to fix

        Method GetAwardList has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function GetAwardList($request) {
                if ($request['IsLadder'] == 'Ladder') {
                    $ladder_clause = " and ka.is_ladder = 1";
                } else if ($request['IsLadder'] == 'NonLadder') {
                    $ladder_clause = " and ka.is_ladder = 0";
        Severity: Minor
        Found in system/lib/ork3/class.Kingdom.php - About 1 hr to fix

          Method GetOfficers has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function GetOfficers($request) {
                  $kingdom_id = mysql_real_escape_string($request['KingdomId']);
                  $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']);
                  $is_authorized = Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $kingdom_id, AUTH_EDIT);
          
          
          Severity: Minor
          Found in system/lib/ork3/class.Kingdom.php - About 1 hr to fix

            Method CreateKingdom has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function CreateKingdom($request) {
                    $response = array();
                    if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                            && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_CREATE)) {
                        $this->log->Write('Kingdom', $mundane_id, LOG_ADD, $request);
            Severity: Minor
            Found in system/lib/ork3/class.Kingdom.php - About 1 hr to fix

              Method SetKingdomDetails has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function SetKingdomDetails($request) {
                      $response = array();
                      if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                              && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                          $this->log->Write('Kingdom', $mundane_id, LOG_EDIT, $request);
              Severity: Minor
              Found in system/lib/ork3/class.Kingdom.php - About 1 hr to fix

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

                    public function GetParks($request) {
                        $sql = "select * 
                                    from " . DB_PREFIX . "park p
                                        left join " . DB_PREFIX . "parktitle pt on p.parktitle_id = pt.parktitle_id
                                    where p.kingdom_id = '" . mysql_real_escape_string($request['KingdomId']) . "'
                Severity: Minor
                Found in system/lib/ork3/class.Kingdom.php - About 1 hr to fix

                  Function GetOfficers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function GetOfficers($request) {
                          $kingdom_id = mysql_real_escape_string($request['KingdomId']);
                          $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']);
                          $is_authorized = Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $kingdom_id, AUTH_EDIT);
                  
                  
                  Severity: Minor
                  Found in system/lib/ork3/class.Kingdom.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

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

                      public function WaffleKingdom($request, $waffle) {
                          $response = array();
                          if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                                  && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_EDIT)) {
                              $this->log->Write('Kingdom', $mundane_id, 'Active'==$waffle?LOG_RESTORE:LOG_RETIRE, $request);
                  Severity: Minor
                  Found in system/lib/ork3/class.Kingdom.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 SetOfficer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function SetOfficer($request) {
                          $response = array();
                          $mundane = Ork3::$Lib->player->player_info($request['MundaneId']);
                          if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                                  && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                  Severity: Minor
                  Found in system/lib/ork3/class.Kingdom.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 EditAward has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function EditAward($request) {
                          if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0
                                  && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $request['KingdomId'], AUTH_EDIT)) {
                              $this->log->Write('Award', $mundane_id, LOG_EDIT, $request);
                              $this->kingdomaward->clear();
                  Severity: Minor
                  Found in system/lib/ork3/class.Kingdom.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 GetOfficers($request) {
                          $kingdom_id = mysql_real_escape_string($request['KingdomId']);
                          $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']);
                          $is_authorized = Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $kingdom_id, AUTH_EDIT);
                  
                  
                  Severity: Major
                  Found in system/lib/ork3/class.Kingdom.php and 1 other location - About 2 days to fix
                  system/lib/ork3/class.Park.php on lines 215..267

                  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 474.

                  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

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

                      public function GetKingdomAuthorizations($request) {
                          $sql = "select authorization_id, username, a.mundane_id, role from ".DB_PREFIX."authorization a left join ".DB_PREFIX."mundane m on a.mundane_id = m.mundane_id where a.kingdom_id = '" . mysql_real_escape_string($request['KingdomId']) . "'";
                          $r = $this->db->query($sql);
                          $response = array();
                          $response['Authorizations'] = array();
                  Severity: Major
                  Found in system/lib/ork3/class.Kingdom.php and 1 other location - About 6 hrs to fix
                  system/lib/ork3/class.Park.php on lines 477..497

                  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 208.

                  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

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

                    public function GetKingdomByAbbreviation($request) {
                      if (trimlen($request['Abbreviation']) < 2 || trimlen($request['Abbreviation']) > 3)
                        return null;
                      
                      $this->kingdom->clear();
                  Severity: Major
                  Found in system/lib/ork3/class.Kingdom.php and 1 other location - About 1 hr to fix
                  system/lib/ork3/class.Park.php on lines 13..23

                  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 113.

                  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