railpage/railpagecore

View on GitHub
lib/Locos/Locomotive.php

Summary

Maintainability
F
1 wk
Test Coverage

File Locomotive.php has 649 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/** 
 * Loco database
 * @since Version 3.2
Severity: Major
Found in lib/Locos/Locomotive.php - About 1 day to fix

    Locomotive has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Locomotive extends Locos {
        
        /**
         * Registry cache key
         * @since Version 3.9.1
    Severity: Minor
    Found in lib/Locos/Locomotive.php - About 5 hrs to fix

      The class Locomotive has 26 non-getter- and setter-methods. Consider refactoring Locomotive to keep number of methods under 25.
      Open

      class Locomotive extends Locos {
          
          /**
           * Registry cache key
           * @since Version 3.9.1
      Severity: Minor
      Found in lib/Locos/Locomotive.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

      The class Locomotive has 20 public methods. Consider refactoring Locomotive to keep number of public methods under 10.
      Open

      class Locomotive extends Locos {
          
          /**
           * Registry cache key
           * @since Version 3.9.1
      Severity: Minor
      Found in lib/Locos/Locomotive.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

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

      The class Locomotive has an overall complexity of 133 which is very high. The configured complexity threshold is 50.
      Open

      class Locomotive extends Locos {
          
          /**
           * Registry cache key
           * @since Version 3.9.1
      Severity: Minor
      Found in lib/Locos/Locomotive.php by phpmd

      Function validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function validate() {
              
              if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
                  $this->Class = &$this->class;
              }
      Severity: Minor
      Found in lib/Locos/Locomotive.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

      The class Locomotive has 32 fields. Consider redesigning Locomotive to keep the number of fields under 15.
      Open

      class Locomotive extends Locos {
          
          /**
           * Registry cache key
           * @since Version 3.9.1
      Severity: Minor
      Found in lib/Locos/Locomotive.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

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

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

          private function validate() {
              
              if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
                  $this->Class = &$this->class;
              }
      Severity: Minor
      Found in lib/Locos/Locomotive.php - About 1 hr to fix

        The class Locomotive has 69 public methods and attributes. Consider reducing the number of public items to less than 45.
        Open

        class Locomotive extends Locos {
            
            /**
             * Registry cache key
             * @since Version 3.9.1
        Severity: Minor
        Found in lib/Locos/Locomotive.php by phpmd

        ExcessivePublicCount

        Since: 0.1

        A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

        Example

        public class Foo {
            public $value;
            public $something;
            public $var;
            // [... more more public attributes ...]
        
            public function doWork() {}
            public function doMoreWork() {}
            public function doWorkAgain() {}
            // [... more more public methods ...]
        }

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

        Method addNote has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addNote($noteText = false, $userId = false, $noteId = false) {
                if (!$noteText || empty($noteText)) {
                    throw new Exception("No note text given"); 
                } 
                
        Severity: Minor
        Found in lib/Locos/Locomotive.php - About 1 hr to fix

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

              private function reloadOrganisations($type) {
                  
                  if (substr($type, -1) !== "s") {
                      $type .= "s";
                  }
          Severity: Minor
          Found in lib/Locos/Locomotive.php - About 1 hr to fix

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

                public function setRating($userId = false, $rating = false) {
                    if (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
                        throw new Exception("Cannot set user rating for this loco - no user given"); 
                    }
                    
            Severity: Minor
            Found in lib/Locos/Locomotive.php - About 1 hr to fix

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

                  public function fetch() {
                      if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                          throw new Exception("Cannot load loco object - loco ID not provided");
                          return false;
                      }
              Severity: Minor
              Found in lib/Locos/Locomotive.php - About 1 hr to fix

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

                    public function next() {
                        $members = $this->Class->members(); 
                        
                        if ($members['stat'] === "ok") {
                            // Get the previous loco in this class
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                    public function previous() {
                        $members = $this->Class->members(); 
                        
                        // Get the next loco in this class
                        if ($members['stat'] === "ok") {
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                    public function addNote($noteText = false, $userId = false, $noteId = false) {
                        if (!$noteText || empty($noteText)) {
                            throw new Exception("No note text given"); 
                        } 
                        
                Severity: Minor
                Found in lib/Locos/Locomotive.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 setRating has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function setRating($userId = false, $rating = false) {
                        if (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot set user rating for this loco - no user given"); 
                        }
                        
                Severity: Minor
                Found in lib/Locos/Locomotive.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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function fetch() {
                        if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot load loco object - loco ID not provided");
                            return false;
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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 loadNotes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function loadNotes() {
                        $query = "SELECT n.*, u.username, user_avatar FROM loco_notes AS n LEFT JOIN nuke_users AS u ON n.user_id = u.user_id WHERE n.loco_id = ?";
                        
                        $notes = array(); 
                        
                Severity: Minor
                Found in lib/Locos/Locomotive.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 populate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function populate() {
                        
                        $timer = Debug::getTimer();
                        
                        $row = Utility\LocomotiveUtility::fetchLocomotive($this); 
                Severity: Minor
                Found in lib/Locos/Locomotive.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 validate() has an NPath complexity of 864. The configured NPath complexity threshold is 200.
                Open

                    private function validate() {
                        
                        if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
                            $this->Class = &$this->class;
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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 class Locomotive has 1518 lines of code. Current threshold is 1000. Avoid really long classes.
                Open

                class Locomotive extends Locos {
                    
                    /**
                     * Registry cache key
                     * @since Version 3.9.1
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

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

                    private function validate() {
                        
                        if ($this->class instanceof LocoClass && !$this->Class instanceof LocoClass) {
                            $this->Class = &$this->class;
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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 '$user_id' which will lead to PHP notices.
                Open

                        if (!$user_id) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 class Locomotive has a coupling between objects value of 28. Consider to reduce the number of dependencies under 13.
                Open

                class Locomotive extends Locos {
                    
                    /**
                     * Registry cache key
                     * @since Version 3.9.1
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                CouplingBetweenObjects

                Since: 1.1.0

                A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                Example

                class Foo {
                    /**
                     * @var \foo\bar\X
                     */
                    private $x = null;
                
                    /**
                     * @var \foo\bar\Y
                     */
                    private $y = null;
                
                    /**
                     * @var \foo\bar\Z
                     */
                    private $z = null;
                
                    public function setFoo(\Foo $foo) {}
                    public function setBar(\Bar $bar) {}
                    public function setBaz(\Baz $baz) {}
                
                    /**
                     * @return \SplObjectStorage
                     * @throws \OutOfRangeException
                     * @throws \InvalidArgumentException
                     * @throws \ErrorException
                     */
                    public function process(\Iterator $it) {}
                
                    // ...
                }

                Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                    public function setRating($userId = false, $rating = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addDate has a boolean flag argument $dateId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addDate($dateId = false, $dateDate = false, $dateText = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 newCorrection has a boolean flag argument $text, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function newCorrection($text = false, $userId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addDate has a boolean flag argument $dateText, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addDate($dateId = false, $dateDate = false, $dateText = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 logEvent has a boolean flag argument $title, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function logEvent($userId = false, $title = false, $args = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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

                Missing class import via use statement (line '1129', column '22').
                Open

                        $Event = new \Railpage\SiteEvent; 
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

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

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

                    public function corrections($active = true) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addNote has a boolean flag argument $noteId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addNote($noteText = false, $userId = false, $noteId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addDate has a boolean flag argument $dateDate, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addDate($dateId = false, $dateDate = false, $dateText = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 newCorrection has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function newCorrection($text = false, $userId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 setRating has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function setRating($userId = false, $rating = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 logEvent has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function logEvent($userId = false, $title = false, $args = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 getRating has a boolean flag argument $detailed, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function getRating($detailed = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 userRating has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function userRating($userId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 getLiveries has a boolean flag argument $f, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function getLiveries($f = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addNote has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addNote($noteText = false, $userId = false, $noteId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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

                Missing class import via use statement (line '992', column '27').
                Open

                            "date" => new \Zend_Db_Expr('NOW()')
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

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

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

                    public function getOrgLink($id = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addAsset has a boolean flag argument $data, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addAsset($data = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 logEvent has a boolean flag argument $args, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function logEvent($userId = false, $title = false, $args = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 addNote has a boolean flag argument $noteText, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function addNote($noteText = false, $userId = false, $noteId = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 '1206', column '13').
                Open

                    public function getContributors() {
                        
                        $key = sprintf(self::CACHE_KEY, $this->id) . ";contributors";
                        
                        if ($contributors = $this->Redis->fetch($key)) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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->Memcached->delete($this->mckey);
                            $this->Redis->delete($this->mckey); 
                            
                            $where = array(
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                        } else {
                            $this->id = Utility\LocomotiveUtility::getLocoId($classIdOrSlug, $number); 
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                            } else {
                                throw new Exception("Cannot add locomotive because we don't know which class to add it into");
                            }
                Severity: Minor
                Found in lib/Locos/Locomotive.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

                The method addNote 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("loco_notes", $data);
                            return $this->db->lastInsertId(); 
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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 '1500', column '13').
                Open

                    public function generateDescription() {
                        
                        $mckey = sprintf(self::CACHE_KEY_DESC, $this->id); 
                        
                        if ($str = $this->Memcached->fetch($mckey)) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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 setRating 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("rating_loco", $data);
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                        } else {
                            $active_sql = "";
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.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 unused local variables such as '$rs'.
                Open

                            $rs = $this->db->insert("loco_unit", $data); 
                Severity: Minor
                Found in lib/Locos/Locomotive.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 '$verb'.
                Open

                            $verb = "Insert";
                Severity: Minor
                Found in lib/Locos/Locomotive.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 parameters such as '$f'.
                Open

                    public function getLiveries($f = false) {
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                UnusedFormalParameter

                Since: 0.2

                Avoid passing parameters to methods or constructors and then not using those parameters.

                Example

                class Foo
                {
                    private function bar($howdy)
                    {
                        // $howdy is not used
                    }
                }

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

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

                        if (!$user_id) {
                Severity: Minor
                Found in lib/Locos/Locomotive.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

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

                            foreach ($members['locos'] as $row) {
                                if ($break === true) {
                                    return new Locomotive($row['loco_id']);
                                }
                                
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 2 hrs to fix
                lib/Locos/Locomotive.php on lines 1277..1285

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

                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

                            foreach ($members['locos'] as $row) {
                                if ($break === true) {
                                    return new Locomotive($row['loco_id']);
                                }
                                
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 2 hrs to fix
                lib/Locos/Locomotive.php on lines 1304..1312

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

                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 (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
                            throw new Exception("No user provided"); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 950..952
                lib/Locos/Locomotive.php on lines 974..976

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

                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

                        foreach ($ints as $int) {
                            if (!filter_var($this->$int, FILTER_VALIDATE_INT)) {
                                $this->$int = 0;
                            }
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Forums/Forum.php on lines 301..305

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

                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 (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot fetch user rating for this loco - no user given"); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 716..718
                lib/Locos/Locomotive.php on lines 974..976

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

                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 (!$userId instanceof User && !filter_var($userId, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot set user rating for this loco - no user given"); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 716..718
                lib/Locos/Locomotive.php on lines 950..952

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

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

                        $this->meta = isset($row['meta']) ? json_decode($row['meta'], true) : array(); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Forums/Thread.php on lines 250..250
                lib/Images/Competition.php on lines 419..419
                lib/Railcams/Camera.php on lines 268..268

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

                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 (!is_array($row) || count($row) === 0) {
                            throw new Exception("Data for this locomotive could not be retrieved") ;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 1 hr to fix
                lib/Downloads/Download.php on lines 204..206
                lib/Railcams/Storage/LocalFS.php on lines 65..67

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

                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 (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot load loco object - loco ID not provided");
                            return false;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 1 hr to fix
                lib/Links/Category.php on lines 123..126
                lib/Locos/Liveries/Livery.php on lines 178..181

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

                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

                        $query = $Sphinx->select("user_id", "username")
                                        ->from("idx_logs")
                                        ->match("module", "locos")
                                        ->where("key", "=", "loco_id")
                                        ->where("value", "=", intval($this->id))
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 751..755

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

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

                        if (!filter_var($orgId, FILTER_VALIDATE_INT)) {
                            throw new Exception("Could not add new organisation link - no org_id given"); 
                            return false;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 1069..1072
                lib/Locos/Locomotive.php on lines 1098..1101
                lib/BanControl/BanControl.php on lines 625..628

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

                        if (!filter_var($orgLinkId, FILTER_VALIDATE_INT)) {
                            throw new Exception("Could not delete org link - no org_link_id specified"); 
                            return false;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 1064..1067
                lib/Locos/Locomotive.php on lines 1069..1072
                lib/BanControl/BanControl.php on lines 625..628

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

                    public function setManufacturer(Manufacturer $Manufacturer) {
                        $this->manufacturer_id = $Manufacturer->id;
                        $this->manufacturer = $Manufacturer->name;
                        
                        return $this;
                Severity: Major
                Found in lib/Locos/Locomotive.php and 5 other locations - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 1214..1219
                lib/Locos/LocoClass.php on lines 1228..1233
                lib/Locos/LocoClass.php on lines 1242..1247
                lib/Users/Group.php on lines 190..196
                lib/Users/Group.php on lines 205..211

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

                        if (!filter_var($orgType, FILTER_VALIDATE_INT)) {
                            throw new Exception("Could not add new organisation link - no org_type_id given"); 
                            return false;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locos/Locomotive.php on lines 1064..1067
                lib/Locos/Locomotive.php on lines 1098..1101
                lib/BanControl/BanControl.php on lines 625..628

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

                        foreach ($ints as $int) {
                            $this->$int = filter_var($this->$int, FILTER_VALIDATE_INT); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Forums/Forum.php on lines 278..280

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

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

                        foreach ($texts as $text) {
                            if (is_null($this->$text)) {
                                $this->$text = "";
                            }
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locations/Location.php on lines 434..438
                lib/Locos/Liveries/Livery.php on lines 298..302
                lib/Organisations/Organisation.php on lines 327..331

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

                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

                    public function addAsset($data = false) {
                        
                        return Utility\LocosUtility::addAsset($this->namespace, $this->id, $data); 
                        
                    }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 816..820

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

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

                        if (!filter_var($this->status_id, FILTER_VALIDATE_INT)) {
                            throw new Exception("No status has been set");
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 24 other locations - About 1 hr to fix
                lib/Downloads/Download.php on lines 313..315
                lib/Events/Event.php on lines 425..427
                lib/Events/Events.php on lines 130..132
                lib/Images/Competition.php on lines 624..626
                lib/Images/Competition.php on lines 654..656
                lib/Images/Competition.php on lines 823..825
                lib/Images/Competition.php on lines 860..862
                lib/Images/Favourites.php on lines 112..114
                lib/Images/Favourites.php on lines 178..180
                lib/Jobs/Classification.php on lines 80..82
                lib/Locations/Location.php on lines 406..408
                lib/Locations/Location.php on lines 410..412
                lib/Locos/Locomotive.php on lines 622..624
                lib/Locos/Locomotive.php on lines 897..899
                lib/News/Article.php on lines 361..363
                lib/News/Article.php on lines 834..836
                lib/Newsletters/Newsletters.php on lines 135..137
                lib/PrivateMessages/Message.php on lines 244..246
                lib/PrivateMessages/Message.php on lines 452..454
                lib/Railcams/Photo.php on lines 330..332
                lib/Railcams/Storage.php on lines 224..226
                lib/Sightings/Sighting.php on lines 133..135
                lib/Users/Group.php on lines 236..238
                lib/Warnings/Warning.php on lines 209..211

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

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

                        if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                            throw new Exception("Cannot fetch rating - no loco ID given"); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 24 other locations - About 1 hr to fix
                lib/Downloads/Download.php on lines 313..315
                lib/Events/Event.php on lines 425..427
                lib/Events/Events.php on lines 130..132
                lib/Images/Competition.php on lines 624..626
                lib/Images/Competition.php on lines 654..656
                lib/Images/Competition.php on lines 823..825
                lib/Images/Competition.php on lines 860..862
                lib/Images/Favourites.php on lines 112..114
                lib/Images/Favourites.php on lines 178..180
                lib/Jobs/Classification.php on lines 80..82
                lib/Locations/Location.php on lines 406..408
                lib/Locations/Location.php on lines 410..412
                lib/Locos/Locomotive.php on lines 622..624
                lib/Locos/Locomotive.php on lines 626..628
                lib/News/Article.php on lines 361..363
                lib/News/Article.php on lines 834..836
                lib/Newsletters/Newsletters.php on lines 135..137
                lib/PrivateMessages/Message.php on lines 244..246
                lib/PrivateMessages/Message.php on lines 452..454
                lib/Railcams/Photo.php on lines 330..332
                lib/Railcams/Storage.php on lines 224..226
                lib/Sightings/Sighting.php on lines 133..135
                lib/Users/Group.php on lines 236..238
                lib/Warnings/Warning.php on lines 209..211

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

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

                        if (!filter_var($this->gauge_id, FILTER_VALIDATE_INT)) {
                            throw new Exception("No gauge has been set");
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 24 other locations - About 1 hr to fix
                lib/Downloads/Download.php on lines 313..315
                lib/Events/Event.php on lines 425..427
                lib/Events/Events.php on lines 130..132
                lib/Images/Competition.php on lines 624..626
                lib/Images/Competition.php on lines 654..656
                lib/Images/Competition.php on lines 823..825
                lib/Images/Competition.php on lines 860..862
                lib/Images/Favourites.php on lines 112..114
                lib/Images/Favourites.php on lines 178..180
                lib/Jobs/Classification.php on lines 80..82
                lib/Locations/Location.php on lines 406..408
                lib/Locations/Location.php on lines 410..412
                lib/Locos/Locomotive.php on lines 626..628
                lib/Locos/Locomotive.php on lines 897..899
                lib/News/Article.php on lines 361..363
                lib/News/Article.php on lines 834..836
                lib/Newsletters/Newsletters.php on lines 135..137
                lib/PrivateMessages/Message.php on lines 244..246
                lib/PrivateMessages/Message.php on lines 452..454
                lib/Railcams/Photo.php on lines 330..332
                lib/Railcams/Storage.php on lines 224..226
                lib/Sightings/Sighting.php on lines 133..135
                lib/Users/Group.php on lines 236..238
                lib/Warnings/Warning.php on lines 209..211

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

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

                        $this->url->edit = sprintf("%s?mode=loco.edit&id=%d", $this->Module->url, $this->id);
                Severity: Major
                Found in lib/Locos/Locomotive.php and 13 other locations - About 1 hr to fix
                lib/Events/Event.php on lines 476..476
                lib/Events/Event.php on lines 477..477
                lib/Events/Event.php on lines 479..479
                lib/Gallery/Album.php on lines 143..143
                lib/Glossary/Entry.php on lines 233..233
                lib/Glossary/Entry.php on lines 234..234
                lib/Glossary/Entry.php on lines 235..235
                lib/Ideas/Idea.php on lines 202..202
                lib/Ideas/Idea.php on lines 203..203
                lib/Ideas/Idea.php on lines 204..204
                lib/Locos/LocoClass.php on lines 649..649
                lib/Locos/LocoClass.php on lines 650..650
                lib/Railcams/Photo.php on lines 166..166

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

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

                        $this->StatsD->target->edit = sprintf("%s.%d.view", $this->namespace, $this->id);
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 475..475
                lib/Locos/LocoClass.php on lines 476..476
                lib/Locos/Locomotive.php on lines 505..505

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

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

                        $this->StatsD->target->view = sprintf("%s.%d.view", $this->namespace, $this->id);
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 475..475
                lib/Locos/LocoClass.php on lines 476..476
                lib/Locos/Locomotive.php on lines 506..506

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

                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 ($Image instanceof Asset) {
                            $this->Asset = clone $Image;
                            $this->commit(); 
                            
                            return $this;
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Locos/LocoClass.php on lines 1158..1163

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

                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

                        $data = array(
                            "loco_id" => $this->id,
                            "operator_id" => $orgId,
                            "link_type" => $orgType,
                            "link_weight" => $weight
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 1 hr to fix
                lib/Notifications/Notifications.php on lines 199..204

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

                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

                        $ints = [ "gauge_id", "status_id", "class_id", "owner_id", "operator_id", "photo_id", "manufacturer_id" ];
                Severity: Major
                Found in lib/Locos/Locomotive.php and 5 other locations - About 55 mins to fix
                lib/Events/Month.php on lines 151..151
                lib/Formatting/BbcodeUtility.php on lines 89..97
                lib/Formatting/BbcodeUtility.php on lines 99..107
                lib/Formatting/MultimediaUtility.php on lines 179..187
                lib/Locos/Liveries/Livery.php on lines 297..297

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

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

                    public function __construct($id = NULL, $classIdOrSlug = NULL, $number = NULL) {
                        parent::__construct(); 
                        
                        $timer = Debug::getTimer();
                        
                Severity: Major
                Found in lib/Locos/Locomotive.php and 14 other locations - About 55 mins to fix
                lib/Downloads/Download.php on lines 384..403
                lib/Images/ImageFactory.php on lines 30..90
                lib/Images/Images.php on lines 95..126
                lib/Links/Category.php on lines 122..133
                lib/Locations/Locations.php on lines 356..397
                lib/Locos/Factory.php on lines 90..123
                lib/Locos/LocoClass.php on lines 1038..1061
                lib/Locos/Locomotive.php on lines 711..745
                lib/Locos/Locomotive.php on lines 806..817
                lib/Locos/Locomotive.php on lines 1118..1144
                lib/Locos/Locos.php on lines 995..1019
                lib/Modules/Modules.php on lines 91..112
                lib/Notifications/Notification.php on lines 465..484
                lib/Users/Utility/PasswordUtility.php on lines 68..96

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

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

                    public function logEvent($userId = false, $title = false, $args = false) {
                        if (!$user_id) {
                            throw new Exception("Cannot log event, no User ID given"); 
                            return false;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 14 other locations - About 55 mins to fix
                lib/Downloads/Download.php on lines 384..403
                lib/Images/ImageFactory.php on lines 30..90
                lib/Images/Images.php on lines 95..126
                lib/Links/Category.php on lines 122..133
                lib/Locations/Locations.php on lines 356..397
                lib/Locos/Factory.php on lines 90..123
                lib/Locos/LocoClass.php on lines 1038..1061
                lib/Locos/Locomotive.php on lines 327..354
                lib/Locos/Locomotive.php on lines 711..745
                lib/Locos/Locomotive.php on lines 806..817
                lib/Locos/Locos.php on lines 995..1019
                lib/Modules/Modules.php on lines 91..112
                lib/Notifications/Notification.php on lines 465..484
                lib/Users/Utility/PasswordUtility.php on lines 68..96

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

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

                    public function addNote($noteText = false, $userId = false, $noteId = false) {
                        if (!$noteText || empty($noteText)) {
                            throw new Exception("No note text given"); 
                        } 
                        
                Severity: Major
                Found in lib/Locos/Locomotive.php and 14 other locations - About 55 mins to fix
                lib/Downloads/Download.php on lines 384..403
                lib/Images/ImageFactory.php on lines 30..90
                lib/Images/Images.php on lines 95..126
                lib/Links/Category.php on lines 122..133
                lib/Locations/Locations.php on lines 356..397
                lib/Locos/Factory.php on lines 90..123
                lib/Locos/LocoClass.php on lines 1038..1061
                lib/Locos/Locomotive.php on lines 327..354
                lib/Locos/Locomotive.php on lines 806..817
                lib/Locos/Locomotive.php on lines 1118..1144
                lib/Locos/Locos.php on lines 995..1019
                lib/Modules/Modules.php on lines 91..112
                lib/Notifications/Notification.php on lines 465..484
                lib/Users/Utility/PasswordUtility.php on lines 68..96

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

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

                    public function addDate($dateId = false, $dateDate = false, $dateText = false) {
                        
                        $Date = new Date;
                        $Date->action = $dateText;
                        $Date->action_id = $dateId;
                Severity: Major
                Found in lib/Locos/Locomotive.php and 14 other locations - About 55 mins to fix
                lib/Downloads/Download.php on lines 384..403
                lib/Images/ImageFactory.php on lines 30..90
                lib/Images/Images.php on lines 95..126
                lib/Links/Category.php on lines 122..133
                lib/Locations/Locations.php on lines 356..397
                lib/Locos/Factory.php on lines 90..123
                lib/Locos/LocoClass.php on lines 1038..1061
                lib/Locos/Locomotive.php on lines 327..354
                lib/Locos/Locomotive.php on lines 711..745
                lib/Locos/Locomotive.php on lines 1118..1144
                lib/Locos/Locos.php on lines 995..1019
                lib/Modules/Modules.php on lines 91..112
                lib/Notifications/Notification.php on lines 465..484
                lib/Users/Utility/PasswordUtility.php on lines 68..96

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

                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 ($row['link_type_id'] === RP_LOCO_RENUMBERED) {
                                $return[$row['link_id']][$row[$key]] = "Renumbered " . $article;
                            } elseif ($row['link_type_id'] === RP_LOCO_REBUILT) {
                                $return[$row['link_id']][$row[$key]] = "Rebuilt " . $article;
                            }
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 55 mins to fix
                lib/Locos/Locomotive.php on lines 835..837

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

                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

                            } elseif ($row['link_type_id'] === RP_LOCO_REBUILT) {
                                $return[$row['link_id']][$row[$key]] = "Rebuilt " . $article;
                            }
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 55 mins to fix
                lib/Locos/Locomotive.php on lines 833..837

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

                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

                    public function loadDates() {
                        $query = "SELECT d.date_id, d.date, d.text, dt.loco_date_text AS title, dt.loco_date_id AS date_type_id
                                    FROM loco_unit_date AS d
                                    LEFT JOIN loco_date_type AS dt ON d.loco_date_id = dt.loco_date_id
                                    WHERE d.loco_unit_id = ?
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 50 mins to fix
                lib/Images/Camera.php on lines 248..259
                lib/Images/Competition.php on lines 760..764

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

                        $rating = $this->db->fetchOne($query, array($userId, $this->id)); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 50 mins to fix
                lib/Railcams/Camera.php on lines 863..863
                lib/Users/User.php on lines 2456..2456

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

                        $this->Memcached->delete(sprintf(self::CACHE_KEY_DESC, $this->id));
                Severity: Major
                Found in lib/Locos/Locomotive.php and 7 other locations - About 45 mins to fix
                lib/Events/Event.php on lines 313..313
                lib/Forums/Post.php on lines 452..452
                lib/Forums/Post.php on lines 453..453
                lib/Locos/LocoClass.php on lines 1074..1074
                lib/Locos/LocoClass.php on lines 1075..1075
                lib/News/Article.php on lines 670..670
                lib/News/Article.php on lines 671..671

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

                        if (filter_var($this->id, FILTER_VALIDATE_INT)) {
                            $this->fetch(); 
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 4 other locations - About 45 mins to fix
                lib/Glossary/Entry.php on lines 211..213
                lib/Locations/Location.php on lines 296..298
                lib/Users/User.php on lines 984..986
                lib/Users/User.php on lines 2368..2370

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

                    public function sightings() {
                        $Sightings = new Sightings;
                        
                        return $Sightings->findLoco($this->id); 
                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 45 mins to fix
                lib/Locos/LocoClass.php on lines 1088..1092

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

                            $str = substr($str, 0, -1) . ".";
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 45 mins to fix
                lib/Locos/Locomotive.php on lines 575..575

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

                        $this->namespace = sprintf("%s.%s", $this->Module->namespace, "loco");
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 45 mins to fix
                lib/Locos/LocoClass.php on lines 283..283

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

                        $var_name_id = substr($type, 0, -1) . "_id";
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 45 mins to fix
                lib/Locos/Locomotive.php on lines 1535..1535

                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->sightings = sprintf("%s/sightings", $this->url->url);
                Severity: Major
                Found in lib/Locos/Locomotive.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 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/Timetables/Train.php on lines 183..183
                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 23 locations. Consider refactoring.
                Open

                        $this->url->photos = sprintf("%s/photos", $this->url->url);
                Severity: Major
                Found in lib/Locos/Locomotive.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/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/Timetables/Train.php on lines 183..183
                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 3 locations. Consider refactoring.
                Open

                        foreach ($result as $row) {
                            $return[$row['user_id']] = $row['username'];
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 45 mins to fix
                lib/Locos/LocoClass.php on lines 760..762
                lib/Users/Base.php on lines 159..161

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

                        $this->Memcached->save($mckey, $str, strtotime("+1 year"));
                Severity: Major
                Found in lib/Locos/Locomotive.php and 21 other locations - About 40 mins to fix
                lib/Chronicle/Chronicle.php on lines 119..119
                lib/Config/Base.php on lines 40..40
                lib/Config/Base.php on lines 111..111
                lib/Downloads/Download.php on lines 530..530
                lib/Glossary/Glossary.php on lines 107..107
                lib/Images/Images.php on lines 110..110
                lib/Links/Links.php on lines 94..94
                lib/Links/Links.php on lines 129..129
                lib/Locations/Country.php on lines 179..179
                lib/Locations/Country.php on lines 180..180
                lib/Locations/Location.php on lines 811..811
                lib/Locations/Locations.php on lines 76..76
                lib/Locations/Locations.php on lines 127..127
                lib/Locations/Locations.php on lines 161..161
                lib/Locations/Locations.php on lines 474..474
                lib/Locos/Locomotive.php on lines 1227..1227
                lib/Locos/Locos.php on lines 238..238
                lib/PrivateMessages/Folder.php on lines 259..259
                lib/Users/Base.php on lines 82..82
                lib/Users/Timeline.php on lines 241..241
                lib/Place.php on lines 600..600

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

                        $this->Redis->save($key, $return, strtotime("+2 hours"));
                Severity: Major
                Found in lib/Locos/Locomotive.php and 21 other locations - About 40 mins to fix
                lib/Chronicle/Chronicle.php on lines 119..119
                lib/Config/Base.php on lines 40..40
                lib/Config/Base.php on lines 111..111
                lib/Downloads/Download.php on lines 530..530
                lib/Glossary/Glossary.php on lines 107..107
                lib/Images/Images.php on lines 110..110
                lib/Links/Links.php on lines 94..94
                lib/Links/Links.php on lines 129..129
                lib/Locations/Country.php on lines 179..179
                lib/Locations/Country.php on lines 180..180
                lib/Locations/Location.php on lines 811..811
                lib/Locations/Locations.php on lines 76..76
                lib/Locations/Locations.php on lines 127..127
                lib/Locations/Locations.php on lines 161..161
                lib/Locations/Locations.php on lines 474..474
                lib/Locos/Locomotive.php on lines 1538..1538
                lib/Locos/Locos.php on lines 238..238
                lib/PrivateMessages/Folder.php on lines 259..259
                lib/Users/Base.php on lines 82..82
                lib/Users/Timeline.php on lines 241..241
                lib/Place.php on lines 600..600

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

                        $str = trim(implode("", $bits)); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 40 mins to fix
                lib/Locations/Locations.php on lines 472..472
                lib/Locos/Utility/LocosUtility.php on lines 104..104

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

                        foreach ($this->db->fetchAll($query, array($this->id, $this->id)) as $row) {
                            $article = $row['loco_id_a'] === $this->id ? "to" : "from";
                            $key = $row['loco_id_a'] === $this->id ? "loco_id_b" : "loco_id_a";
                            
                            if ($row['link_type_id'] === RP_LOCO_RENUMBERED) {
                Severity: Major
                Found in lib/Locos/Locomotive.php and 2 other locations - About 40 mins to fix
                lib/Images/Competition.php on lines 525..525
                lib/Locos/Manufacturer.php on lines 192..196

                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 (!$noteText || empty($noteText)) {
                            throw new Exception("No note text given"); 
                        } 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 5 other locations - About 40 mins to fix
                lib/Notifications/Notification.php on lines 474..476
                lib/Timetables/Train.php on lines 264..266
                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

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

                        $query = "SELECT o.*, op.operator_id AS organisation_id, op.operator_name AS organisation_name FROM loco_org_link AS o LEFT JOIN loco_org_link_type AS ot ON ot.id = o.link_type LEFT JOIN operators AS op ON op.operator_id = o.operator_id WHERE o.loco_id = ? " . $org_sql . " ORDER BY ot.id, o.link_weight DESC ".$limit_sql.""; 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 4 other locations - About 40 mins to fix
                lib/Formatting/Html.php on lines 63..63
                lib/Images/Utility/Geoplace.php on lines 50..59
                lib/PrivateMessages/Folder.php on lines 204..211
                lib/SiteMessage/Admin.php on lines 35..35

                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 (filter_var($id, FILTER_VALIDATE_INT)) {
                            $this->id = filter_var($id, FILTER_VALIDATE_INT);
                        } else {
                            $this->id = Utility\LocomotiveUtility::getLocoId($classIdOrSlug, $number); 
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 40 mins to fix
                lib/Organisations/Organisation.php on lines 190..194

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

                            $key = $row['loco_id_a'] === $this->id ? "loco_id_b" : "loco_id_a";
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 40 mins to fix
                lib/Locos/Locomotive.php on lines 830..830

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

                            $article = $row['loco_id_a'] === $this->id ? "to" : "from";
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 40 mins to fix
                lib/Locos/Locomotive.php on lines 831..831

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

                        $mckey = sprintf(self::CACHE_KEY_DESC, $this->id); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 7 other locations - About 35 mins to fix
                lib/Forums/Post.php on lines 626..626
                lib/Forums/Post.php on lines 660..660
                lib/Images/Camera.php on lines 207..207
                lib/Images/Competition.php on lines 338..338
                lib/Locos/LocoClass.php on lines 657..657
                lib/Locos/Locomotive.php on lines 692..692
                lib/Users/User.php on lines 1282..1282

                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

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

                        $regkey = sprintf(self::REGISTRY_KEY, $this->id); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 7 other locations - About 35 mins to fix
                lib/Forums/Post.php on lines 626..626
                lib/Forums/Post.php on lines 660..660
                lib/Images/Camera.php on lines 207..207
                lib/Images/Competition.php on lines 338..338
                lib/Locos/LocoClass.php on lines 657..657
                lib/Locos/Locomotive.php on lines 1498..1498
                lib/Users/User.php on lines 1282..1282

                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

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

                        if (isset($this->meta['coverimage'])) {
                            unset($this->meta['coverimage']);
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 3 other locations - About 35 mins to fix
                lib/Locos/LocoClass.php on lines 1139..1141
                lib/Users/User.php on lines 2249..2251
                lib/Users/User.php on lines 2253..2255

                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

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

                            $rs = $this->db->update("loco_unit", $data, $where); 
                Severity: Major
                Found in lib/Locos/Locomotive.php and 4 other locations - About 30 mins to fix
                lib/Links/Link.php on lines 194..194
                lib/Links/Links.php on lines 342..342
                lib/News/Base.php on lines 384..384
                lib/Organisations/Base.php on lines 160..160

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

                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 ($Image instanceof Image && $Image->provider === "flickr") {
                            $this->photo_id = $Image->photo_id;
                            $this->commit(); 
                            
                            return $this;
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 30 mins to fix
                lib/Locos/LocoClass.php on lines 1147..1152

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

                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 (!is_null($limit)) {
                            $limit_sql = "LIMIT 0, 1"; 
                        }
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 30 mins to fix
                lib/Forums/Thread.php on lines 377..379

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

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

                        $texts = [ "entered_service", "withdrawal_date", "builders_num", "name" ];
                Severity: Major
                Found in lib/Locos/Locomotive.php and 8 other locations - About 30 mins to fix
                lib/Downloads/Base.php on lines 141..146
                lib/Formatting/BbcodeUtility.php on lines 111..116
                lib/Formatting/MakeClickable.php on lines 256..256
                lib/Forums/Forum.php on lines 294..299
                lib/Gallery/Utility/CreateSizes.php on lines 153..153
                lib/Images/Competition.php on lines 258..258
                lib/Images/Utility/Tagger.php on lines 131..136
                lib/Locos/Locomotive.php on lines 634..634

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

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

                                try {
                                    #$User = UserFactory::CreateUser($row['user_id']);
                                    
                                    $row['user_avatar'] = AvatarUtility::Format($row['user_avatar'], 50, 50);
                                    #$row['user_url'] = $User->url;
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 2 other locations - About 30 mins to fix
                lib/Locos/LocoClass.php on lines 425..430
                lib/Users/User.php on lines 1630..1636

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

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

                        if ($contributors = $this->Redis->fetch($key)) {
                            return $contributors;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 8 other locations - About 30 mins to fix
                lib/Chronicle/Chronicle.php on lines 105..107
                lib/Links/Links.php on lines 40..42
                lib/Locations/Location.php on lines 722..724
                lib/Locations/Locations.php on lines 99..101
                lib/Locos/Locomotive.php on lines 1500..1502
                lib/Users/Timeline.php on lines 209..211
                lib/Place.php on lines 383..385
                lib/Place.php on lines 482..484

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

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

                        $ints = [ "owner_id", "operator_id", "photo_id", "manufacturer_id" ];
                Severity: Major
                Found in lib/Locos/Locomotive.php and 8 other locations - About 30 mins to fix
                lib/Downloads/Base.php on lines 141..146
                lib/Formatting/BbcodeUtility.php on lines 111..116
                lib/Formatting/MakeClickable.php on lines 256..256
                lib/Forums/Forum.php on lines 294..299
                lib/Gallery/Utility/CreateSizes.php on lines 153..153
                lib/Images/Competition.php on lines 258..258
                lib/Images/Utility/Tagger.php on lines 131..136
                lib/Locos/Locomotive.php on lines 646..646

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

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

                        if ($str = $this->Memcached->fetch($mckey)) {
                            return $str;
                        }
                Severity: Major
                Found in lib/Locos/Locomotive.php and 8 other locations - About 30 mins to fix
                lib/Chronicle/Chronicle.php on lines 105..107
                lib/Links/Links.php on lines 40..42
                lib/Locations/Location.php on lines 722..724
                lib/Locations/Locations.php on lines 99..101
                lib/Locos/Locomotive.php on lines 1206..1208
                lib/Users/Timeline.php on lines 209..211
                lib/Place.php on lines 383..385
                lib/Place.php on lines 482..484

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

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

                            "manufacturer" => array(
                                "id" => $this->manufacturer_id,
                                "text" => $this->manufacturer
                            ),
                Severity: Major
                Found in lib/Locos/Locomotive.php and 4 other locations - About 30 mins to fix
                lib/Images/Image.php on lines 1013..1016
                lib/Jobs/Jobs.php on lines 210..213
                lib/Jobs/Scraper.php on lines 278..281
                lib/Sightings/Sighting.php on lines 187..190

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

                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 (isset($row['asset_id']) && $row['asset_id'] > 0) {
                            try {
                                $this->Asset = new Asset($row['asset_id']);
                            } catch (Exception $e) {
                                // throw it away
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 2 other locations - About 30 mins to fix
                lib/Downloads/Download.php on lines 215..215
                lib/Locos/LocoClass.php on lines 424..431

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

                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

                            $where = array(
                                "user_id = ?" => $userId,
                                "loco_id = ?" => $this->id
                            );
                Severity: Minor
                Found in lib/Locos/Locomotive.php and 1 other location - About 30 mins to fix
                lib/Images/Provider/SmugMug.php on lines 116..119

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

                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

                The parameter $Image is not named in camelCase.
                Open

                    public function setCoverImage($Image) {
                        
                        /**
                         * Zero out any existing images
                         */
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $Gauge is not named in camelCase.
                Open

                    public function setGauge(Gauge $Gauge) {
                        $this->gauge_id = $Gauge->id;
                        $this->gauge = $Gauge->getArray(); 
                        $this->gauge_formatted = (string) $Gauge;
                        
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $Manufacturer is not named in camelCase.
                Open

                    public function setManufacturer(Manufacturer $Manufacturer) {
                        $this->manufacturer_id = $Manufacturer->id;
                        $this->manufacturer = $Manufacturer->name;
                        
                        return $this;
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $LocoClass is not named in camelCase.
                Open

                    public function setLocoClass(LocoClass $LocoClass) {
                        $this->Class = $LocoClass;
                        $this->class = $LocoClass;
                        $this->class_id = $LocoClass->id;
                        
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Function closing brace must go on the next line following the body; found 1 blank lines before brace
                Open

                    }
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                Blank line found at start of control structure
                Open

                        if ($members['stat'] === "ok") {
                Severity: Minor
                Found in lib/Locos/Locomotive.php by phpcodesniffer

                There are no issues that match your filters.

                Category
                Status