railpage/railpagecore

View on GitHub
lib/Timetables/Train.php

Summary

Maintainability
D
2 days
Test Coverage

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

        public function setCommodity($commodity) {
            switch (strtolower($commodity)) {
                case "intermodal" :
                    $this->commodity = self::COMMODITY_INTERMODAL;
                    break;
Severity: Minor
Found in lib/Timetables/Train.php - About 1 hr to fix

    Function setCommodity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            public function setCommodity($commodity) {
                switch (strtolower($commodity)) {
                    case "intermodal" :
                        $this->commodity = self::COMMODITY_INTERMODAL;
                        break;
    Severity: Minor
    Found in lib/Timetables/Train.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 addTiming has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
                if (!$this->Point instanceof Point) {
                    throw new Exception("Cannot add a timing because no valid timetable point has been set");
                }
                
    Severity: Minor
    Found in lib/Timetables/Train.php - About 1 hr to fix

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

              public function commit() {
                  $this->validate(); 
                  
                  if (isset($this->mckey)) {
                      $this->Memcached->delete($this->mckey);
      Severity: Minor
      Found in lib/Timetables/Train.php - About 1 hr to fix

        Function addTiming has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
                    if (!$this->Point instanceof Point) {
                        throw new Exception("Cannot add a timing because no valid timetable point has been set");
                    }
                    
        Severity: Minor
        Found in lib/Timetables/Train.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 addTiming has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
        Severity: Minor
        Found in lib/Timetables/Train.php - About 35 mins to fix

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

                  private function load() {
                      if (filter_var($this->id, FILTER_VALIDATE_INT)) {
                          $this->mckey = sprintf("railpage:timetable.train=%d", $this->id);
                          
                          if (!$row = $this->Memcached->fetch($this->mckey)) {
          Severity: Minor
          Found in lib/Timetables/Train.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

          The method addTiming() has an NPath complexity of 576. The configured NPath complexity threshold is 200.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
                      if (!$this->Point instanceof Point) {
                          throw new Exception("Cannot add a timing because no valid timetable point has been set");
                      }
                      
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

          Source https://phpmd.org/rules/codesize.html#npathcomplexity

          The method addTiming() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
                      if (!$this->Point instanceof Point) {
                          throw new Exception("Cannot add a timing because no valid timetable point has been set");
                      }
                      
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          The method setCommodity() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
          Open

                  public function setCommodity($commodity) {
                      switch (strtolower($commodity)) {
                          case "intermodal" :
                              $this->commodity = self::COMMODITY_INTERMODAL;
                              break;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          Avoid using undefined variables such as '$ithis' which will lead to PHP notices.
          Open

                              $row = $this->db->fetchRow($query, $ithis->d);
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          The method addTiming has a boolean flag argument $time, which is a certain sign of a Single Responsibility Principle violation.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          The method addTiming has a boolean flag argument $commencing, which is a certain sign of a Single Responsibility Principle violation.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          The method addTiming has a boolean flag argument $expiring, which is a certain sign of a Single Responsibility Principle violation.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          The method __construct has a boolean flag argument $id, which is a certain sign of a Single Responsibility Principle violation.
          Open

                  public function __construct($id = false, $provider = "artc") {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          The method addTiming has a boolean flag argument $day, which is a certain sign of a Single Responsibility Principle violation.
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          Avoid assigning values to variables in if clauses and the like (line '164', column '22').
          Open

                  private function load() {
                      if (filter_var($this->id, FILTER_VALIDATE_INT)) {
                          $this->mckey = sprintf("railpage:timetable.train=%d", $this->id);
                          
                          if (!$row = $this->Memcached->fetch($this->mckey)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

          Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

          The method commit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $this->db->insert("timetable_trains", $data);
                          $this->id = $this->db->lastInsertId(); 
                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          Avoid assigning values to variables in if clauses and the like (line '302', column '18').
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
                      if (!$this->Point instanceof Point) {
                          throw new Exception("Cannot add a timing because no valid timetable point has been set");
                      }
                      
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

          Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

          Avoid unused local variables such as '$id'.
          Open

                      if (!$id = $this->db->fetchOne($query, $where)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

          Avoid unused local variables such as '$ithis'.
          Open

                              $row = $this->db->fetchRow($query, $ithis->d);
          Severity: Minor
          Found in lib/Timetables/Train.php by phpmd

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

                          if (!$row = $this->Memcached->fetch($this->mckey)) {
                              $query = "SELECT * FROM timetable_trains WHERE id = ?";
                              $row = $this->db->fetchRow($query, $ithis->d);
                              
                              $this->Memcached->save($this->mckey, $row);
          Severity: Major
          Found in lib/Timetables/Train.php and 4 other locations - About 2 hrs to fix
          lib/Glossary/Entry.php on lines 152..158
          lib/News/Article.php on lines 375..384
          lib/Organisations/Organisation.php on lines 215..220
          lib/PrivateMessages/Message.php on lines 250..261

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

          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

                          $row['point'] = array(
                              "id" => $Point->id,
                              "name" => $Point->name,
                              "url" => $Point->url->getURLs()
                          );
          Severity: Major
          Found in lib/Timetables/Train.php and 2 other locations - About 1 hr to fix
          lib/Forums/Forums.php on lines 904..908
          lib/Forums/Forums.php on lines 911..915

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

          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

                      if ($this->Organisation instanceof Organisation) {
                          $data['operator_id'] = $this->Organisation->id;
                      }
          Severity: Major
          Found in lib/Timetables/Train.php and 2 other locations - About 50 mins to fix
          lib/Events/Event.php on lines 297..299
          lib/Locos/LocoClass.php on lines 616..618

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

          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 ($expiring instanceof DateTime) {
                          $data['expires'] = $expiring->format("Y-m-d H:i:s");
                      }
          Severity: Minor
          Found in lib/Timetables/Train.php and 1 other location - About 50 mins to fix
          lib/Timetables/Train.php on lines 292..294

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

          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 ($commencing instanceof DateTime) {
                          $data['starts'] = $commencing->format("Y-m-d H:i:s");
                      }
          Severity: Minor
          Found in lib/Timetables/Train.php and 1 other location - About 50 mins to fix
          lib/Timetables/Train.php on lines 296..298

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

          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 23 locations. Consider refactoring.
          Open

                          $this->meta = json_decode($row['meta'], true);
          Severity: Major
          Found in lib/Timetables/Train.php and 22 other locations - About 45 mins to fix
          lib/Assets/Asset.php on lines 150..150
          lib/Chronicle/Entry.php on lines 156..156
          lib/Events/Event.php on lines 207..207
          lib/Events/EventDate.php on lines 154..154
          lib/Gallery/Album.php on lines 136..136
          lib/Gallery/Image.php on lines 208..208
          lib/Ideas/Idea.php on lines 166..166
          lib/Images/Camera.php on lines 116..116
          lib/Images/Competition.php on lines 180..180
          lib/Images/Competition.php on lines 790..790
          lib/Locos/Date.php on lines 158..158
          lib/Locos/LocoClass.php on lines 417..417
          lib/News/Feed.php on lines 234..234
          lib/News/Feed.php on lines 235..235
          lib/Newsletters/Newsletter.php on lines 128..128
          lib/Newsletters/Newsletter.php on lines 129..129
          lib/Railcams/Storage.php on lines 201..201
          lib/Sightings/Sighting.php on lines 161..161
          lib/Sightings/Sighting.php on lines 162..162
          lib/Users/Group.php on lines 168..168
          lib/Users/User.php on lines 1068..1068
          lib/SiteEvent.php on lines 135..135

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

          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 23 locations. Consider refactoring.
          Open

                          $this->url->edit = sprintf("%s?mode=edit", $this->url->url);
          Severity: Major
          Found in lib/Timetables/Train.php and 22 other locations - About 45 mins to fix
          lib/Chronicle/Chronicle.php on lines 42..42
          lib/Chronicle/Chronicle.php on lines 43..43
          lib/Chronicle/Chronicle.php on lines 44..44
          lib/Chronicle/Chronicle.php on lines 45..45
          lib/Chronicle/Chronicle.php on lines 46..46
          lib/Images/Competition.php on lines 150..150
          lib/Jobs/Job.php on lines 196..196
          lib/Locos/Locomotive.php on lines 432..432
          lib/Locos/Locomotive.php on lines 433..433
          lib/Railcams/Camera.php on lines 258..258
          lib/Railcams/Camera.php on lines 259..259
          lib/Railcams/Camera.php on lines 261..261
          lib/Railcams/Camera.php on lines 262..262
          lib/Railcams/Camera.php on lines 263..263
          lib/Railcams/Camera.php on lines 264..264
          lib/Railcams/Camera.php on lines 266..266
          lib/Timetables/Point.php on lines 115..115
          lib/Timetables/Timetables.php on lines 41..41
          lib/Timetables/Timetables.php on lines 42..42
          lib/Timetables/Timetables.php on lines 43..43
          lib/Users/Group.php on lines 222..222
          lib/Users/Group.php on lines 223..223

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

          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 6 locations. Consider refactoring.
          Open

                          $day = date("N", strtotime($day));
          Severity: Major
          Found in lib/Timetables/Train.php and 5 other locations - About 40 mins to fix
          lib/Downloads/DownloadsFactory.php on lines 34..34
          lib/Glossary/Glossary.php on lines 85..85
          lib/Images/Collage.php on lines 229..229
          lib/Images/Utility/Finder.php on lines 757..757
          lib/Url.php on lines 115..115

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

          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 6 locations. Consider refactoring.
          Open

                      if (!$time || empty($time)) {
                          throw new Exception("Cannot add a timing because no valid time of day has been set");
                      }
          Severity: Major
          Found in lib/Timetables/Train.php and 5 other locations - About 40 mins to fix
          lib/Locos/Locomotive.php on lines 712..714
          lib/Notifications/Notification.php on lines 474..476
          lib/Timetables/Train.php on lines 264..266
          lib/Users/User.php on lines 2136..2138
          lib/Users/User.php on lines 2446..2448

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

          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 6 locations. Consider refactoring.
          Open

                      if (!$day || empty($day)) {
                          throw new Exception("Cannot add a timing because no valid day of week has been set");
                      }
          Severity: Major
          Found in lib/Timetables/Train.php and 5 other locations - About 40 mins to fix
          lib/Locos/Locomotive.php on lines 712..714
          lib/Notifications/Notification.php on lines 474..476
          lib/Timetables/Train.php on lines 268..270
          lib/Users/User.php on lines 2136..2138
          lib/Users/User.php on lines 2446..2448

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

          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

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

                      if (isset($this->mckey)) {
                          $this->Memcached->delete($this->mckey);
                      }
          Severity: Minor
          Found in lib/Timetables/Train.php and 1 other location - About 35 mins to fix
          lib/Events/Event.php on lines 315..317

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

          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 must be no space before the colon in a DEFAULT statement
          Open

                          default :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Blank line found at end of control structure
          Open

                              
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if ($commencing instanceof DateTime) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public function addTiming($day = false, $time = false, $going = "arr", $commencing = false, $expiring = false) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (!$id = $this->db->fetchOne($query, $where)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "steel" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public function commit() {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 0 spaces, found 4
          Open

              class Train extends Timetables {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $meta;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $commodity;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if ($id != false && $provider == "artc") {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (empty($this->provider)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "intermodal" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "grainmt" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (!$time || empty($time)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          if (!isset($timings[$day])) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "intermoda" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "cnypass" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $id;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if ($this->Organisation instanceof Organisation) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if ($expiring instanceof DateTime) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      switch (strtolower($commodity)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  private function validate() {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (empty($this->number)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "lighteng" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "vlppass" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "gsr-pass" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "genfrgt" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          default :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public function __construct($id = false, $provider = "artc") {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          if (!$row = $this->Memcached->fetch($this->mckey)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      } else {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $number;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $Organisation;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (filter_var($this->id, FILTER_VALIDATE_INT)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          if ($row['operator_id'] > 0) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (isset($this->mckey)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (strlen($going) > 3) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public function setCommodity($commodity) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (isset($row)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (!is_int($day)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      foreach ($this->db->fetchAll($query, $this->id) as $row) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public $provider;
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (filter_var($this->id, FILTER_VALIDATE_INT)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (!$this->Point instanceof Point) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 8 spaces, found 12
          Open

                      if (!$day || empty($day)) {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  public function getTimings() {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 4 spaces, found 8
          Open

                  private function load() {
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 12 spaces, found 16
          Open

                          case "grainld" :
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          Line indented incorrectly; expected 0 spaces, found 4
          Open

              }
          Severity: Minor
          Found in lib/Timetables/Train.php by phpcodesniffer

          There are no issues that match your filters.

          Category
          Status