amtgard/ORK3

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

class Park extends Ork3
{

Severity: Major
Found in system/lib/ork3/class.Park.php - About 1 day to fix

    Function SetParkDetails has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public function SetParkDetails( $request )
        {
            logtrace( "SetParkDetails", $request );
            $this->park->clear();
            if ( trimlen( $request[ 'Name' ] ) > 0 ) {
    Severity: Minor
    Found in system/lib/ork3/class.Park.php - About 1 day 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

    Park has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Park extends Ork3
    {
    
        public function __construct()
        {
    Severity: Minor
    Found in system/lib/ork3/class.Park.php - About 3 hrs to fix

      Method SetParkDetails has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function SetParkDetails( $request )
          {
              logtrace( "SetParkDetails", $request );
              $this->park->clear();
              if ( trimlen( $request[ 'Name' ] ) > 0 ) {
      Severity: Major
      Found in system/lib/ork3/class.Park.php - About 2 hrs to fix

        Method PlayAmtgard has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public function PlayAmtgard($request) {
                $key = Ork3::$Lib->ghettocache->key($request);
                if (false && ($cache = Ork3::$Lib->ghettocache->get(__CLASS__ . '.' . __FUNCTION__, $key, 60)) !== false)
                    return $cache;
        
        
        Severity: Major
        Found in system/lib/ork3/class.Park.php - About 2 hrs to fix

          Method AddParkDay has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function AddParkDay( $request )
              {
                  if ( ( $mundane_id = Ork3::$Lib->authorization->IsAuthorized( $request[ 'Token' ] ) ) > 0
                      && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_PARK, $request[ 'ParkId' ], AUTH_EDIT )
                  ) {
          Severity: Minor
          Found in system/lib/ork3/class.Park.php - About 1 hr to fix

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

                public function GetOfficers( $request )
                {
                    $sql = "select a.*, p.name as park_name, k.name as kingdom_name, e.name as event_name, u.name as unit_name, m.mundane_id as m_mundane_id, m.username, m.given_name, m.surname, m.persona, m.restricted, o.role as officer_role, o.officer_id
                                from " . DB_PREFIX . "officer o
                                    left join " . DB_PREFIX . "mundane m on o.mundane_id = m.mundane_id
            Severity: Minor
            Found in system/lib/ork3/class.Park.php - About 1 hr to fix

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

                  public function GetParkDays( $request )
                  {
                      $parkday = new yapo( $this->db, DB_PREFIX . 'parkday' );
                      $parkday->clear();
                      $parkday->park_id = $request[ 'ParkId' ];
              Severity: Minor
              Found in system/lib/ork3/class.Park.php - About 1 hr to fix

                Method GetParkDetails has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function GetParkDetails( $request )
                    {
                        $this->park->clear();
                        $this->park->park_id = $request[ 'ParkId' ];
                        $response = [ ];
                Severity: Minor
                Found in system/lib/ork3/class.Park.php - About 1 hr to fix

                  Method GetParks has 29 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 pt.parktitle_id = p.parktitle_id
                  Severity: Minor
                  Found in system/lib/ork3/class.Park.php - About 1 hr to fix

                    Method CreatePark has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function CreatePark( $request )
                        {
                            if ( ( $mundane_id = Ork3::$Lib->authorization->IsAuthorized( $request[ 'Token' ] ) ) > 0
                                && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_ADMIN, $request[ 'KingdomId' ], AUTH_CREATE )
                            ) {
                    Severity: Minor
                    Found in system/lib/ork3/class.Park.php - About 1 hr to fix

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

                          public static function CalculateNextParkDay( $recurrence, $week_of_month, $month_day, $week_day, $from_date = null )
                      Severity: Minor
                      Found in system/lib/ork3/class.Park.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                return date( "Y-m-d", strtotime( "fourth $week_day of " . date( "F Y", $from_date ), $from_date ) );
                        Severity: Major
                        Found in system/lib/ork3/class.Park.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return date( "Y-m-d", strtotime( "fifth $week_day of " . date( "F Y", $from_date ), $from_date ) );
                          Severity: Major
                          Found in system/lib/ork3/class.Park.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return date( "Y-m-d", strtotime( date( "F $month_day, Y", $from_date ), $from_date ) );
                            Severity: Major
                            Found in system/lib/ork3/class.Park.php - About 30 mins to fix

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

                                  public function park_geocode_h( $geocode = null, & $parkobject = null )
                                  {
                                  $parkobject = is_null($parkobject) ? $this->park : $parkobject;
                                       logtrace( 'park_geocode_h', $parkobject );
                              
                              
                              Severity: Minor
                              Found in system/lib/ork3/class.Park.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 AddParkDay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function AddParkDay( $request )
                                  {
                                      if ( ( $mundane_id = Ork3::$Lib->authorization->IsAuthorized( $request[ 'Token' ] ) ) > 0
                                          && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_PARK, $request[ 'ParkId' ], AUTH_EDIT )
                                      ) {
                              Severity: Minor
                              Found in system/lib/ork3/class.Park.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 WafflePark has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function WafflePark( $request, $waffle )
                                  {
                                      $response = [ ];
                                      $this->park->clear();
                                      $this->park->park_id = $request[ 'ParkId' ];
                              Severity: Minor
                              Found in system/lib/ork3/class.Park.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 TransferPark has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function TransferPark( $request )
                                  {
                                      if ( ( $mundane_id = Ork3::$Lib->authorization->IsAuthorized( $request[ 'Token' ] ) ) > 0
                                          && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_ADMIN, $request[ 'KingdomId' ], AUTH_CREATE )
                                      ) {
                              Severity: Minor
                              Found in system/lib/ork3/class.Park.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

                                      if ($r !== false && $r->size() > 0) {
                                          $response['ParkDays'] = array();
                                          do {
                                              $response['ParkDays'][] = array(
                                                      'ParkdayId' => $r->parkday_id,
                              Severity: Major
                              Found in system/lib/ork3/class.Park.php and 1 other location - About 1 day to fix
                              system/lib/ork3/class.Event.php on lines 324..358

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

                              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 GetParkAuthorizations( $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.park_id = '" . mysql_real_escape_string( $request[ 'ParkId' ] ) . "' and system=0";
                                      $r = $this->db->query( $sql );
                                      $response = [ ];
                              Severity: Major
                              Found in system/lib/ork3/class.Park.php and 1 other location - About 6 hrs to fix
                              system/lib/ork3/class.Kingdom.php on lines 273..292

                              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 GetParkByAbbreviation($request) {
                                  if (trimlen($request['Abbreviation']) < 2 || trimlen($request['Abbreviation']) > 3)
                                    return null;
                                  
                                  $this->park->clear();
                              Severity: Major
                              Found in system/lib/ork3/class.Park.php and 1 other location - About 1 hr to fix
                              system/lib/ork3/class.Kingdom.php on lines 11..21

                              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

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

                                      $sql = "select a.*, p.name as park_name, k.name as kingdom_name, e.name as event_name, u.name as unit_name, m.mundane_id as m_mundane_id, m.username, m.given_name, m.surname, m.persona, m.restricted, o.role as officer_role, o.officer_id
                                                  from " . DB_PREFIX . "officer o
                                                      left join " . DB_PREFIX . "mundane m on o.mundane_id = m.mundane_id
                                                      left join " . DB_PREFIX . "authorization a on a.authorization_id = o.authorization_id
                                                          left join " . DB_PREFIX . "park p on a.park_id = p.park_id
                              Severity: Major
                              Found in system/lib/ork3/class.Park.php and 2 other locations - About 1 hr to fix
                              system/lib/ork3/class.Kingdom.php on lines 498..507
                              system/lib/ork3/class.Player.php on lines 265..278

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

                              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

                                      if ( ( $mundane_id = Ork3::$Lib->authorization->IsAuthorized( $request[ 'Token' ] ) ) > 0
                                          && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_ADMIN, $request[ 'FromParkId' ], AUTH_CREATE )
                                          && Ork3::$Lib->authorization->HasAuthority( $mundane_id, AUTH_ADMIN, $request[ 'ToParkId' ], AUTH_CREATE )
                                      ) {
                                    
                              Severity: Minor
                              Found in system/lib/ork3/class.Park.php and 1 other location - About 40 mins to fix
                              system/lib/ork3/class.Unit.php on lines 12..29

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

                              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