railpage/railpagecore

View on GitHub
lib/Downloads/Download.php

Summary

Maintainability
F
1 wk
Test Coverage

File Download.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/** 
 * Downloads 
 * @since Version 3.0
Severity: Minor
Found in lib/Downloads/Download.php - About 4 hrs to fix

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

    class Download extends Base {
        
        /**
         * Download ID
         * @since Version 3.2
    Severity: Minor
    Found in lib/Downloads/Download.php by phpmd

    Method getThumbnail has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getThumbnail() {
            
            $mime = explode("/", $this->mime); 
            $thumbnail = sprintf("%s.thumbnail.jpg", $this->filepath);
            
    Severity: Major
    Found in lib/Downloads/Download.php - About 2 hrs to fix

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

          public function fetch() {
              if (empty($this->id)) {
                  throw new Exception("Cannot fetch download object - no download ID given"); 
              }
              
      Severity: Minor
      Found in lib/Downloads/Download.php - About 1 hr to fix

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

            public function getIcon() {
                
                $mime = explode("/", $this->mime); 
                
                switch ($mime[0]) {
        Severity: Minor
        Found in lib/Downloads/Download.php - About 1 hr to fix

          The class Download has 17 fields. Consider redesigning Download to keep the number of fields under 15.
          Open

          class Download extends Base {
              
              /**
               * Download ID
               * @since Version 3.2
          Severity: Minor
          Found in lib/Downloads/Download.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 getHTML5Video has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getHTML5Video() {
                  if (empty($this->mime) && file_exists(RP_DOWNLOAD_DIR . $this->filepath)) {
                      $this->getThumbnail(); 
                  }
                  
          Severity: Minor
          Found in lib/Downloads/Download.php - About 1 hr to fix

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

                public function commit() {
                    
                    $this->validate();
                    
                    $data = array(
            Severity: Minor
            Found in lib/Downloads/Download.php - About 1 hr to fix

              Function fetch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function fetch() {
                      if (empty($this->id)) {
                          throw new Exception("Cannot fetch download object - no download ID given"); 
                      }
                      
              Severity: Minor
              Found in lib/Downloads/Download.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  public function validate() {
                      if (empty($this->name)) {
                          throw new Exception("Verification failed - download must have a name");
                      }
                      
              Severity: Minor
              Found in lib/Downloads/Download.php - About 1 hr to fix

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

                    public function validate() {
                        if (empty($this->name)) {
                            throw new Exception("Verification failed - download must have a name");
                        }
                        
                Severity: Minor
                Found in lib/Downloads/Download.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 getIcon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getIcon() {
                        
                        $mime = explode("/", $this->mime); 
                        
                        switch ($mime[0]) {
                Severity: Minor
                Found in lib/Downloads/Download.php - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Avoid too many return statements within this method.
                Open

                                return [ 
                                    "label" => "PDF",
                                    "icon" => '<i class="fa fa-file-pdf-o"></i>'
                                ];
                Severity: Major
                Found in lib/Downloads/Download.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return false;
                  Severity: Major
                  Found in lib/Downloads/Download.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return [
                                "label" => "Unknown",
                                "icon" => '<i class="fa fa-file-o"></i>'
                            ];
                    Severity: Major
                    Found in lib/Downloads/Download.php - About 30 mins to fix

                      The method validate() has an NPath complexity of 512. The configured NPath complexity threshold is 200.
                      Open

                          public function validate() {
                              if (empty($this->name)) {
                                  throw new Exception("Verification failed - download must have a name");
                              }
                              
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpmd

                      NPathComplexity

                      Since: 0.1

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

                      Example

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

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

                      The method fetch() has an NPath complexity of 3456. The configured NPath complexity threshold is 200.
                      Open

                          public function fetch() {
                              if (empty($this->id)) {
                                  throw new Exception("Cannot fetch download object - no download ID given"); 
                              }
                              
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpmd

                      NPathComplexity

                      Since: 0.1

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

                      Example

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

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

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

                          public function validate() {
                              if (empty($this->name)) {
                                  throw new Exception("Verification failed - download must have a name");
                              }
                              
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpmd

                      CyclomaticComplexity

                      Since: 0.1

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

                      Example

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

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

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

                          public function fetch() {
                              if (empty($this->id)) {
                                  throw new Exception("Cannot fetch download object - no download ID given"); 
                              }
                              
                      Severity: Minor
                      Found in lib/Downloads/Download.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

                      Duplicated array key url, first declared at line 346.
                      Open

                              $data = array(
                                  "category_id" => $this->Category instanceof Category ? $this->Category->id : 10,
                                  "title" => $this->name,
                                  "url" => $this->url_file,
                                  "filename" => $this->filename,
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpmd

                      DuplicatedArrayKey

                      Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.

                      Example

                      function createArray() {
                          return [
                              'non-associative 0element', // not applied
                              0 => 'associative 0-element', // applied
                              false => 'associative 0-element', // applied
                              'foo' => 'bar', // not applied
                              "foo" => 'baz', // applied
                          ];
                      }

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

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

                          public function getDetails() {
                              
                              $mckey = sprintf("%s;details", $this->mckey); 
                              
                              if (!$data = $this->Memcached->fetch($mckey)) {
                      Severity: Minor
                      Found in lib/Downloads/Download.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

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

                              if (!file_exists(RP_DOWNLOAD_DIR . $dstfile)) {
                                  exec(sprintf("%s -i %s%s -vcodec h264 -acodec aac -strict -2 -ar 64k %s%s", $avlib, RP_DOWNLOAD_DIR, $this->filepath, RP_DOWNLOAD_DIR, $dstfile), $return);
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 2 hrs to fix
                      lib/Downloads/Download.php on lines 606..608

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 64.

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

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

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

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

                      Refactorings

                      Further Reading

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

                              if (!file_exists(RP_DOWNLOAD_DIR . $dstfile)) {
                                  exec(sprintf("%s -i %s%s -acodec libvorbis -ac 2 -ab 96k -ar 44100 %s%s", $avlib, RP_DOWNLOAD_DIR, $this->filepath, RP_DOWNLOAD_DIR, $dstfile), $return);
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 2 hrs to fix
                      lib/Downloads/Download.php on lines 586..588

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 64.

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

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

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

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

                      Refactorings

                      Further Reading

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

                              $videos['webm'] = array(
                                  "absolute" => RP_DOWNLOAD_DIR . $dstfile,
                                  "file" => $dstfile,
                                  "size" => filesize(RP_DOWNLOAD_DIR . $dstfile),
                                  "mime" => $mime
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 2 hrs to fix
                      lib/Downloads/Download.php on lines 593..598

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

                      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

                              $videos['mp4'] = array(
                                  "absolute" => RP_DOWNLOAD_DIR . $dstfile,
                                  "file" => $dstfile,
                                  "size" => filesize(RP_DOWNLOAD_DIR . $dstfile),
                                  "mime" => $mime
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 2 hrs to fix
                      lib/Downloads/Download.php on lines 613..618

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 53.

                      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

                              $dstfile = sprintf("%s/%s.v3.mp4", pathinfo($this->filepath, PATHINFO_DIRNAME), pathinfo($this->filepath, PATHINFO_FILENAME));
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 1 hr to fix
                      lib/Downloads/Download.php on lines 604..604

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

                      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

                              $dstfile = sprintf("%s/%s.v3.webm", pathinfo($this->filepath, PATHINFO_DIRNAME), pathinfo($this->filepath, PATHINFO_FILENAME));
                      Severity: Major
                      Found in lib/Downloads/Download.php and 1 other location - About 1 hr to fix
                      lib/Downloads/Download.php on lines 584..584

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

                      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

                                      return array(
                                          "file" => $thumbnail,
                                          "width" => $info[0],
                                          "height" => $info[1],
                                          "size" => filesize(RP_DOWNLOAD_DIR . $thumbnail)
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 437..442
                      lib/Downloads/Download.php on lines 453..458

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

                      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

                                  return array(
                                      "file" => $thumbnail,
                                      "width" => $info[0],
                                      "height" => $info[1],
                                      "size" => filesize(RP_DOWNLOAD_DIR . $thumbnail)
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 453..458
                      lib/Downloads/Download.php on lines 488..493

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

                      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

                                      return array(
                                          "file" => $thumbnail,
                                          "width" => $info[0],
                                          "height" => $info[1],
                                          "size" => filesize(RP_DOWNLOAD_DIR . $thumbnail)
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 437..442
                      lib/Downloads/Download.php on lines 488..493

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

                      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("Requested download not found");
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Locos/Locomotive.php on lines 387..389
                      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

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

                              foreach (func_get_args() as $arg) {
                                  if (filter_var($arg, FILTER_VALIDATE_INT)) {
                                      $this->id = $arg;
                                  }
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Downloads/Category.php on lines 70..74
                      lib/SiteMessage/SiteMessage.php on lines 40..44

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

                      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->user_id, FILTER_VALIDATE_INT)) {
                                  throw new Exception("No valid owner of this download has been provided");
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 24 other locations - About 1 hr to fix
                      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/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 12 locations. Consider refactoring.
                      Open

                              if (!filter_var($this->approved, FILTER_VALIDATE_INT)) {
                                  $this->approved = 0;
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 11 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 297..299
                      lib/Downloads/Download.php on lines 305..307
                      lib/Feedback/FeedbackItem.php on lines 184..186
                      lib/Forums/Category.php on lines 166..168
                      lib/Gallery/Image.php on lines 334..336
                      lib/Ideas/Idea.php on lines 268..270
                      lib/Ideas/Idea.php on lines 272..274
                      lib/Locations/Location.php on lines 440..442
                      lib/Locations/Location.php on lines 452..454
                      lib/Locos/Operator.php on lines 129..131
                      lib/Users/User.php on lines 1208..1210

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

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

                              if (!filter_var($this->active, FILTER_VALIDATE_INT)) {
                                  $this->active = 1;
                              } 
                      Severity: Major
                      Found in lib/Downloads/Download.php and 11 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 301..303
                      lib/Downloads/Download.php on lines 305..307
                      lib/Feedback/FeedbackItem.php on lines 184..186
                      lib/Forums/Category.php on lines 166..168
                      lib/Gallery/Image.php on lines 334..336
                      lib/Ideas/Idea.php on lines 268..270
                      lib/Ideas/Idea.php on lines 272..274
                      lib/Locations/Location.php on lines 440..442
                      lib/Locations/Location.php on lines 452..454
                      lib/Locos/Operator.php on lines 129..131
                      lib/Users/User.php on lines 1208..1210

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

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

                              if (!filter_var($this->hits, FILTER_VALIDATE_INT)) {
                                  $this->hits = 0;
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 11 other locations - About 1 hr to fix
                      lib/Downloads/Download.php on lines 297..299
                      lib/Downloads/Download.php on lines 301..303
                      lib/Feedback/FeedbackItem.php on lines 184..186
                      lib/Forums/Category.php on lines 166..168
                      lib/Gallery/Image.php on lines 334..336
                      lib/Ideas/Idea.php on lines 268..270
                      lib/Ideas/Idea.php on lines 272..274
                      lib/Locations/Location.php on lines 440..442
                      lib/Locations/Location.php on lines 452..454
                      lib/Locos/Operator.php on lines 129..131
                      lib/Users/User.php on lines 1208..1210

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

                      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

                              $this->Date     = new DateTime($row['date'], new DateTimeZone("Australia/Melbourne"));
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 1 hr to fix
                      lib/Images/Collection.php on lines 135..135
                      lib/Images/Collection.php on lines 136..136

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

                          public function log($ip = null, $userId = null, $username = null) {
                              
                              if (!filter_var($ip, FILTER_VALIDATE_IP)) {
                                  return false;
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 14 other locations - About 55 mins to fix
                      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/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

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

                                  $this->mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $this->filepath);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 55 mins to fix
                      lib/Downloads/Download.php on lines 513..513

                      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

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

                                      $this->mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $this->filepath);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 55 mins to fix
                      lib/Downloads/Download.php on lines 263..263

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

                              if (!$this->Date instanceof DateTime) {
                                  $this->Date = new DateTime;
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 13 other locations - About 50 mins to fix
                      lib/Content/Page.php on lines 172..174
                      lib/Gallery/Image.php on lines 177..179
                      lib/Gallery/Image.php on lines 326..328
                      lib/Glossary/Entry.php on lines 266..268
                      lib/Ideas/Idea.php on lines 252..254
                      lib/Images/Collection.php on lines 192..194
                      lib/Locations/Correction.php on lines 172..174
                      lib/Locos/Correction.php on lines 183..185
                      lib/News/Article.php on lines 778..780
                      lib/Notifications/Notification.php on lines 187..189
                      lib/Railcams/Camera.php on lines 363..365
                      lib/Railcams/Footage.php on lines 143..145
                      lib/Warnings/Warning.php on lines 227..229

                      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

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

                                  if (empty($this->mime) && file_exists(RP_DOWNLOAD_DIR . $this->filepath)) {
                                      $finfo = finfo_open(FILEINFO_MIME_TYPE); 
                                      $this->mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $this->filepath);
                                  }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 45 mins to fix
                      lib/Downloads/Download.php on lines 261..265
                      lib/Downloads/Download.php on lines 564..566

                      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

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

                              if (empty($this->mime) && file_exists(RP_DOWNLOAD_DIR . $this->filepath)) {
                                  $finfo = finfo_open(FILEINFO_MIME_TYPE); 
                                  $this->mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $this->filepath);
                                  $this->commit(); 
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 45 mins to fix
                      lib/Downloads/Download.php on lines 511..514
                      lib/Downloads/Download.php on lines 564..566

                      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

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

                              if (empty($this->mime) && file_exists(RP_DOWNLOAD_DIR . $this->filepath)) {
                                  $this->getThumbnail(); 
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 2 other locations - About 45 mins to fix
                      lib/Downloads/Download.php on lines 261..265
                      lib/Downloads/Download.php on lines 511..514

                      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->filepath = str_replace("/uploads/", "", $pathinfo['path']);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 45 mins to fix
                      lib/PrivateMessages/Conversation.php on lines 86..86

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

                                  $this->Memcached->save($mckey, $data, strtotime("+12 hours"));
                      Severity: Major
                      Found in lib/Downloads/Download.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/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/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

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

                              $mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $dstfile);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 40 mins to fix
                      lib/Downloads/Download.php on lines 611..611

                      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

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

                              $mime = finfo_file($finfo, RP_DOWNLOAD_DIR . $dstfile);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 40 mins to fix
                      lib/Downloads/Download.php on lines 591..591

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

                              if (is_null($this->mime)) {
                                  $this->mime = "";
                              }
                      Severity: Major
                      Found in lib/Downloads/Download.php and 11 other locations - About 40 mins to fix
                      lib/Feedback/FeedbackItem.php on lines 180..182
                      lib/Forums/Post.php on lines 351..353
                      lib/Glossary/Entry.php on lines 262..264
                      lib/Locos/Date.php on lines 266..268
                      lib/Locos/WheelArrangement.php on lines 170..172
                      lib/News/Article.php on lines 766..768
                      lib/News/Article.php on lines 770..772
                      lib/News/Article.php on lines 786..788
                      lib/PrivateMessages/Message.php on lines 302..304
                      lib/Sightings/Sighting.php on lines 239..241
                      lib/Sightings/Sighting.php on lines 243..245

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

                                  $data['filesize']       = empty($this->filesize) ? 0 : $this->filesize; 
                      Severity: Major
                      Found in lib/Downloads/Download.php and 3 other locations - About 40 mins to fix
                      lib/News/Article.php on lines 683..683
                      lib/News/Article.php on lines 684..684
                      lib/News/Article.php on lines 685..685

                      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

                              if ($userId != null && $username != null) {
                                  $data['user_id'] = $userId;
                                  $data['username'] = $username;
                              }
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 1 other location - About 40 mins to fix
                      lib/Users/Timeline.php on lines 88..91

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

                                  "category_id" => $this->Category instanceof Category ? $this->Category->id : 10,
                      Severity: Major
                      Found in lib/Downloads/Download.php and 3 other locations - About 35 mins to fix
                      lib/Downloads/Category.php on lines 167..167
                      lib/Forums/Forum.php on lines 329..329
                      lib/Locos/Utility/LocomotiveUtility.php on lines 92..92

                      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

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

                                      $info = getimagesize(RP_DOWNLOAD_DIR . $thumbnail);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 2 other locations - About 30 mins to fix
                      lib/Downloads/Download.php on lines 435..435
                      lib/Downloads/Download.php on lines 486..486

                      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

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

                                  $info = getimagesize(RP_DOWNLOAD_DIR . $thumbnail);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 2 other locations - About 30 mins to fix
                      lib/Downloads/Download.php on lines 451..451
                      lib/Downloads/Download.php on lines 486..486

                      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

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

                                      $info = getimagesize(RP_DOWNLOAD_DIR . $thumbnail);
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 2 other locations - About 30 mins to fix
                      lib/Downloads/Download.php on lines 435..435
                      lib/Downloads/Download.php on lines 451..451

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

                              $this->filesize = isset($row['filesize']) && $row['filesize'] > 0 ? formatBytes($row['filesize']) : "Unknown";
                      Severity: Minor
                      Found in lib/Downloads/Download.php and 2 other locations - About 30 mins to fix
                      lib/Locos/LocoClass.php on lines 424..431
                      lib/Locos/Locomotive.php on lines 474..480

                      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

                      Blank line found at start of control structure
                      Open

                              switch ($this->mime) {
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpcodesniffer

                      Blank line found at end of control structure
                      Open

                                      
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpcodesniffer

                      Blank line found at end of control structure
                      Open

                                  
                      Severity: Minor
                      Found in lib/Downloads/Download.php by phpcodesniffer

                      Blank line found at end of control structure
                      Open

                                      
                      Severity: Minor
                      Found in lib/Downloads/Download.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/Downloads/Download.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/Downloads/Download.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/Downloads/Download.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/Downloads/Download.php by phpcodesniffer

                      There are no issues that match your filters.

                      Category
                      Status