railpage/railpagecore

View on GitHub
lib/Images/Images.php

Summary

Maintainability
F
3 days
Test Coverage

Function getImageFromUrl has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function getImageFromUrl($url = null, $option = null) {
        
        /**
         * Flickr
         */
Severity: Minor
Found in lib/Images/Images.php - About 3 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

class Images extends AppCore {
    
    /**
     * Option: Do not load a \Railpage\Place object
     * @since Version 3.9.1
Severity: Minor
Found in lib/Images/Images.php by phpmd

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

    private static function normaliseSizes_addShorthands($missingSize, $minWidth = 0, $maxWidth = 99999) {
        
        if (!count(self::$sizes)) {
            return;
        }
Severity: Minor
Found in lib/Images/Images.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 getImageFromUrl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getImageFromUrl($url = null, $option = null) {
        
        /**
         * Flickr
         */
Severity: Minor
Found in lib/Images/Images.php - About 1 hr to fix

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

        public function findLocoImage($locoId = null, $liveryId = null) {
            if (is_null($locoId)) {
                throw new Exception("Cannot find loco image - no loco ID given");
            }
            
    Severity: Minor
    Found in lib/Images/Images.php - About 1 hr to fix

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

          public function findImage($provider = null, $photoId = null, $option = null) {
              if (is_null($provider)) {
                  throw new Exception("Cannot lookup image from image provider - no provider given (hint: Flickr, WestonLangford)");
              }
              
      Severity: Minor
      Found in lib/Images/Images.php - About 45 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function normaliseSizes_addMissingSizes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function normaliseSizes_addMissingSizes($missingSize, $minWidth, $minHeight) {
              
              if (isset(self::$sizes[$missingSize])) {
                  return;
              }
      Severity: Minor
      Found in lib/Images/Images.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

      The method getImageFromUrl() has an NPath complexity of 378. The configured NPath complexity threshold is 200.
      Open

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.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 findImage() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
      Open

          public function findImage($provider = null, $photoId = null, $option = null) {
              if (is_null($provider)) {
                  throw new Exception("Cannot lookup image from image provider - no provider given (hint: Flickr, WestonLangford)");
              }
              
      Severity: Minor
      Found in lib/Images/Images.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 normaliseSizes_addShorthands() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
      Open

          private static function normaliseSizes_addShorthands($missingSize, $minWidth = 0, $maxWidth = 99999) {
              
              if (!count(self::$sizes)) {
                  return;
              }
      Severity: Minor
      Found in lib/Images/Images.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 getImageFromUrl() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
      Open

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      CyclomaticComplexity

      Since: 0.1

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

      Example

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

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

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

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

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

      Example

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

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

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

              } else {
                  $query = "SELECT il.image_id FROM image_link AS il WHERE il.namespace = ? AND il.namespace_key = ? AND il.image_id IN (SELECT i.id FROM image_link AS il INNER JOIN image AS i ON il.image_id = i.id WHERE il.namespace = ? AND il.namespace_key = ? AND il.ignored = 0)";
                  $args = array(
                      "railpage.locos.liveries.livery",
                      $liveryId,
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      ElseExpression

      Since: 1.4.0

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

      Example

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

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

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

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

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

      Example

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

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

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

          public function findImage($provider = null, $photoId = null, $option = null) {
              if (is_null($provider)) {
                  throw new Exception("Cannot lookup image from image provider - no provider given (hint: Flickr, WestonLangford)");
              }
              
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

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

      Example

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

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

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

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

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

      Example

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

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

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

          public function getImageFromUrl($url = null, $option = null) {
              
              /**
               * Flickr
               */
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

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

      Example

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

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

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

              $decoded = 0;
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      UnusedLocalVariable

      Since: 0.2

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

      Example

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

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

      Avoid unused parameters such as '$provider'.
      Open

          public function deleteFromCache($provider, $photoId = null) {
      Severity: Minor
      Found in lib/Images/Images.php by phpmd

      UnusedFormalParameter

      Since: 0.2

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

      Example

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

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

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

              foreach ($result as $k => $v) {
                  $result[$k]['meta'] = json_decode($v['meta'], true);
                  $result[$k]['meta']['sizes'] = self::normaliseSizes($result[$k]['meta']['sizes']);
              }
      Severity: Major
      Found in lib/Images/Images.php and 1 other location - About 3 hrs to fix
      lib/Images/Utility/Finder.php on lines 385..388

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

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

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

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

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

      Refactorings

      Further Reading

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

          public function deleteFromCache($provider, $photoId = null) {
              
              if ($photoId == null) {
                  throw new InvalidArgumentException("No photo ID was provided"); 
              }
      Severity: Major
      Found in lib/Images/Images.php and 1 other location - About 2 hrs to fix
      lib/Locos/Locos.php on lines 1178..1190

      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

              if (!isset($sizes['medium'])) {
                  self::$sizes['medium'] = self::$sizes['large'];
              }
      Severity: Major
      Found in lib/Images/Images.php and 1 other location - About 1 hr to fix
      lib/Images/Images.php on lines 293..295

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 34.

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

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

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

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

      Refactorings

      Further Reading

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

              if (!isset($sizes['large'])) {
                  self::$sizes['large'] = self::$sizes['larger'];
              }
      Severity: Major
      Found in lib/Images/Images.php and 1 other location - About 1 hr to fix
      lib/Images/Images.php on lines 297..299

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 34.

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

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

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

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

      Refactorings

      Further Reading

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

          public function findImage($provider = null, $photoId = null, $option = null) {
              if (is_null($provider)) {
                  throw new Exception("Cannot lookup image from image provider - no provider given (hint: Flickr, WestonLangford)");
              }
              
      Severity: Major
      Found in lib/Images/Images.php and 14 other locations - About 55 mins to fix
      lib/Downloads/Download.php on lines 384..403
      lib/Images/ImageFactory.php on lines 30..90
      lib/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

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

                  $id = $this->db->fetchOne("SELECT id FROM image WHERE provider = ? AND photo_id = ?", array($provider, $photoId));
      Severity: Major
      Found in lib/Images/Images.php and 3 other locations - About 45 mins to fix
      lib/Links/Links.php on lines 320..320
      lib/News/Base.php on lines 362..362
      lib/Organisations/Base.php on lines 138..138

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 25.

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

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

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

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

      Refactorings

      Further Reading

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

                  $this->Redis->save($mckey, $id, strtotime("+1 month"));
      Severity: Major
      Found in lib/Images/Images.php and 21 other locations - About 40 mins to fix
      lib/Chronicle/Chronicle.php on lines 119..119
      lib/Config/Base.php on lines 40..40
      lib/Config/Base.php on lines 111..111
      lib/Downloads/Download.php on lines 530..530
      lib/Glossary/Glossary.php on lines 107..107
      lib/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

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

                  if ($Image = $this->findImage("FiveHundredPx", $photo_id, $option)) {
                      return $Image;
                  }
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 40 mins to fix
      lib/Images/Images.php on lines 192..194

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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 2 locations. Consider refactoring.
      Open

                  if ($Image = $this->findImage("flickr", $photo_id, $option)) {
                      return $Image;
                  }
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 40 mins to fix
      lib/Images/Images.php on lines 234..236

      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

              if ((defined("NOREDIS") && NOREDIS == true)  || ($option != self::OPT_REFRESH && !$id = $this->Redis->fetch($mckey))) {
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 40 mins to fix
      lib/Images/Image.php on lines 328..328

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

              if (is_null($provider)) {
                  throw new Exception("Cannot lookup image from image provider - no provider given (hint: Flickr, WestonLangford)");
              }
      Severity: Major
      Found in lib/Images/Images.php and 20 other locations - About 35 mins to fix
      lib/Events/EventDate.php on lines 372..374
      lib/Images/Image.php on lines 963..965
      lib/Images/Image.php on lines 1095..1097
      lib/Images/Images.php on lines 137..139
      lib/Locations/Region.php on lines 93..95
      lib/Locos/Locos.php on lines 590..592
      lib/Locos/Locos.php on lines 901..903
      lib/Locos/Locos.php on lines 925..927
      lib/Railcams/Storage/LocalFS.php on lines 127..129
      lib/Users/User.php on lines 2572..2574
      lib/Users/User.php on lines 2576..2578
      lib/Users/User.php on lines 2584..2586
      lib/Users/Utility/PasswordUtility.php on lines 70..72
      lib/Users/Utility/PasswordUtility.php on lines 74..76
      lib/Users/Utility/PasswordUtility.php on lines 78..80
      lib/API.php on lines 124..126
      lib/API.php on lines 194..196
      lib/BanControl/BanControl.php on lines 243..245
      lib/BanControl/BanControl.php on lines 354..356
      lib/BanControl/BanControl.php on lines 358..360

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 22.

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

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

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

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

      Refactorings

      Further Reading

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

              if (is_null($locoId)) {
                  throw new Exception("Cannot find loco image - no loco ID given");
              }
      Severity: Major
      Found in lib/Images/Images.php and 20 other locations - About 35 mins to fix
      lib/Events/EventDate.php on lines 372..374
      lib/Images/Image.php on lines 963..965
      lib/Images/Image.php on lines 1095..1097
      lib/Images/Images.php on lines 96..98
      lib/Locations/Region.php on lines 93..95
      lib/Locos/Locos.php on lines 590..592
      lib/Locos/Locos.php on lines 901..903
      lib/Locos/Locos.php on lines 925..927
      lib/Railcams/Storage/LocalFS.php on lines 127..129
      lib/Users/User.php on lines 2572..2574
      lib/Users/User.php on lines 2576..2578
      lib/Users/User.php on lines 2584..2586
      lib/Users/Utility/PasswordUtility.php on lines 70..72
      lib/Users/Utility/PasswordUtility.php on lines 74..76
      lib/Users/Utility/PasswordUtility.php on lines 78..80
      lib/API.php on lines 124..126
      lib/API.php on lines 194..196
      lib/BanControl/BanControl.php on lines 243..245
      lib/BanControl/BanControl.php on lines 354..356
      lib/BanControl/BanControl.php on lines 358..360

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 22.

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

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

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

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

      Refactorings

      Further Reading

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

              if (isset($image_id) && filter_var($image_id, FILTER_VALIDATE_INT)) {
                  $Image = new Image($image_id);
                  #$Image->populate();
                  
                  return $Image;
      Severity: Major
      Found in lib/Images/Images.php and 3 other locations - About 30 mins to fix
      lib/Glossary/Glossary.php on lines 111..113
      lib/Images/Images.php on lines 113..115
      lib/News/Topic.php on lines 105..109

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

              if (isset($id) && filter_var($id, FILTER_VALIDATE_INT)) {
                  return new Image($id, $option);
              }
      Severity: Major
      Found in lib/Images/Images.php and 3 other locations - About 30 mins to fix
      lib/Glossary/Glossary.php on lines 111..113
      lib/Images/Images.php on lines 161..166
      lib/News/Topic.php on lines 105..109

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 21.

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

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

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

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

      Refactorings

      Further Reading

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

              if (preg_match("#flickr.com/photos/([a-zA-Z0-9\-\_\@]+)/([0-9]+)#", $url, $matches) && $Image = $this->findImage("flickr", $matches[2], $option)) {
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 30 mins to fix
      lib/Images/Images.php on lines 207..207

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 21.

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

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

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

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

      Refactorings

      Further Reading

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

                          if ($Image = $this->findImage("SmugMug", $matches[1], $option)) {
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 30 mins to fix
      lib/Images/Images.php on lines 185..185

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

              $mckey = sprintf("railpage:image;provider=%s;id=%s", $provider, $photoId);
      Severity: Major
      Found in lib/Images/Images.php and 5 other locations - About 30 mins to fix
      lib/Images/Provider/FiveHundredPx.php on lines 287..287
      lib/Images/Utility/Finder.php on lines 230..230
      lib/Locations/Factory.php on lines 88..88
      lib/Place.php on lines 781..781
      lib/PlaceUtility.php on lines 329..329

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 20.

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

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

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

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

      Refactorings

      Further Reading

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

                              if (is_null($Image->photo_id) || $Image->photo_id == 0) {
                                  $Image->photo_id = $matches[1]; 
                                  $Image->commit(); 
                              }
      Severity: Minor
      Found in lib/Images/Images.php and 1 other location - About 30 mins to fix
      lib/Users/User.php on lines 1630..1636

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 20.

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

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

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

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

      Refactorings

      Further Reading

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

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

      There are no issues that match your filters.

      Category
      Status