railpage/railpagecore

View on GitHub
lib/Gallery/Image.php

Summary

Maintainability
F
5 days
Test Coverage

Method populate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function populate() {
        
        $this->mckey = sprintf("railpage:gallery.album.image=%d", $this->id);
        
        if (!$row = $this->Memcached->fetch($this->mckey)) {
Severity: Minor
Found in lib/Gallery/Image.php - About 1 hr to fix

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

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

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

          private function validate() {
              
              if (empty($this->title)) {
                  $this->name = $this->path;
              }
      Severity: Minor
      Found in lib/Gallery/Image.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

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

          private function populate() {
              
              $this->mckey = sprintf("railpage:gallery.album.image=%d", $this->id);
              
              if (!$row = $this->Memcached->fetch($this->mckey)) {
      Severity: Minor
      Found in lib/Gallery/Image.php - About 25 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          private function populate() {
              
              $this->mckey = sprintf("railpage:gallery.album.image=%d", $this->id);
              
              if (!$row = $this->Memcached->fetch($this->mckey)) {
      Severity: Minor
      Found in lib/Gallery/Image.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 (isset($this->meta['thumbnail'])) {
                  $this->sizes['thumb'] = array(
                      "source" => sprintf("//static.railpage.com.au/albums/%s/%s.%s", dirname($this->path), $this->meta['thumbnail']['name'], $this->meta['thumbnail']['type']),
                      "width" => $this->meta['thumbnail']['width'],
                      "height" => $this->meta['thumbnail']['height']
      Severity: Major
      Found in lib/Gallery/Image.php and 1 other location - About 4 hrs to fix
      lib/Gallery/Image.php on lines 221..227

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

      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($this->meta['image']['resizedName'])) {
                  $this->sizes['medium'] = array(
                      "source" => sprintf("//static.railpage.com.au/albums/%s/%s.%s", dirname($this->path), $this->meta['image']['resizedName'], $this->meta['image']['type']),
                      "width" => $this->meta['image']['width'],
                      "height" => $this->meta['image']['height']
      Severity: Major
      Found in lib/Gallery/Image.php and 1 other location - About 4 hrs to fix
      lib/Gallery/Image.php on lines 229..235

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

      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 getNextImage() {
              
              $query = "SELECT id FROM gallery_mig_image WHERE album_id = ? AND hidden = ? AND id > ? ORDER BY id ASC";
              $Album = $this->getAlbum();
              
      Severity: Major
      Found in lib/Gallery/Image.php and 1 other location - About 4 hrs to fix
      lib/Gallery/Image.php on lines 474..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 94.

      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 getPreviousImage() {
              
              $query = "SELECT id FROM gallery_mig_image WHERE album_id = ? AND hidden = ? AND id < ? ORDER BY id DESC";
              $Album = $this->getAlbum();
              
      Severity: Major
      Found in lib/Gallery/Image.php and 1 other location - About 4 hrs to fix
      lib/Gallery/Image.php on lines 501..520

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

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

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

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

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

      Refactorings

      Further Reading

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

              if (!$row = $this->Memcached->fetch($this->mckey)) {
                  $query = "SELECT * FROM gallery_mig_image WHERE id = ?";
                  
                  $row = $this->db->fetchRow($query, $this->id);
                  $this->Memcached->save($this->mckey, $row, strtotime("+1 year"));
      Severity: Major
      Found in lib/Gallery/Image.php and 4 other locations - About 3 hrs to fix
      lib/Gallery/Album.php on lines 127..133
      lib/Locos/Gauge.php on lines 106..111
      lib/Locos/Status.php on lines 65..69
      lib/News/Topic.php on lines 126..132

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

      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 getOwner() {
              
              if ($this->Owner instanceof User) {
                  return $this->Owner;
              }
      Severity: Major
      Found in lib/Gallery/Image.php and 1 other location - About 2 hrs to fix
      lib/Gallery/Album.php on lines 293..308

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

              $this->url = new Url(sprintf("%s?image=%d", $this->Module->url, $this->id));
      Severity: Major
      Found in lib/Gallery/Image.php and 11 other locations - About 1 hr to fix
      lib/Events/Event.php on lines 475..475
      lib/Events/EventCategory.php on lines 232..232
      lib/Glossary/Entry.php on lines 227..227
      lib/Ideas/Idea.php on lines 186..186
      lib/Jobs/Job.php on lines 195..195
      lib/Jobs/Job.php on lines 315..315
      lib/Locations/Region.php on lines 149..149
      lib/Locos/Type.php on lines 106..106
      lib/Locos/Type.php on lines 133..133
      lib/News/Topic.php on lines 147..147
      lib/Timetables/Point.php on lines 114..114

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

      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->hidden, FILTER_VALIDATE_INT)) {
                  $this->hidden = 0;
              }
      Severity: Major
      Found in lib/Gallery/Image.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/Downloads/Download.php on lines 305..307
      lib/Feedback/FeedbackItem.php on lines 184..186
      lib/Forums/Category.php on lines 166..168
      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 6 locations. Consider refactoring.
      Open

              $this->lon = isset($row['lon']) ? $row['lon'] : NULL;
      Severity: Major
      Found in lib/Gallery/Image.php and 5 other locations - About 55 mins to fix
      lib/Content/Page.php on lines 151..151
      lib/Gallery/Image.php on lines 209..209
      lib/Gallery/Image.php on lines 210..210
      lib/News/Article.php on lines 400..400
      lib/News/Article.php on lines 405..405

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

              $this->lat = isset($row['lat']) ? $row['lat'] : NULL; 
      Severity: Major
      Found in lib/Gallery/Image.php and 5 other locations - About 55 mins to fix
      lib/Content/Page.php on lines 151..151
      lib/Gallery/Image.php on lines 209..209
      lib/Gallery/Image.php on lines 211..211
      lib/News/Article.php on lines 400..400
      lib/News/Article.php on lines 405..405

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

              $this->hidden = isset($row['hidden']) ? $row['hidden'] : false;
      Severity: Major
      Found in lib/Gallery/Image.php and 5 other locations - About 55 mins to fix
      lib/Content/Page.php on lines 151..151
      lib/Gallery/Image.php on lines 210..210
      lib/Gallery/Image.php on lines 211..211
      lib/News/Article.php on lines 400..400
      lib/News/Article.php on lines 405..405

      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->DateTaken instanceof DateTime) {
                  $this->DateTaken = new DateTime;
              }
      Severity: Major
      Found in lib/Gallery/Image.php and 13 other locations - About 50 mins to fix
      lib/Content/Page.php on lines 172..174
      lib/Downloads/Download.php on lines 285..287
      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

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

              if (!$this->DateUploaded instanceof DateTime) {
                  $this->DateUploaded = new DateTime;
              }
      Severity: Major
      Found in lib/Gallery/Image.php and 13 other locations - About 50 mins to fix
      lib/Content/Page.php on lines 172..174
      lib/Downloads/Download.php on lines 285..287
      lib/Gallery/Image.php on lines 177..179
      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

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

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

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 26.

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

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

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

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

      Refactorings

      Further Reading

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

                  "lon" => $this->Place instanceof Place ? $this->Place->lon : NULL
      Severity: Minor
      Found in lib/Gallery/Image.php and 1 other location - About 45 mins to fix
      lib/Gallery/Image.php on lines 388..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 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 2 locations. Consider refactoring.
      Open

              if (!$this->getOwner() instanceof User) {
                  throw new Exception("No valid image owner has been set"); 
              }
      Severity: Minor
      Found in lib/Gallery/Image.php and 1 other location - About 45 mins to fix
      lib/Gallery/Image.php on lines 314..316

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

                  "lat" => $this->Place instanceof Place ? $this->Place->lat : NULL,
      Severity: Minor
      Found in lib/Gallery/Image.php and 1 other location - About 45 mins to fix
      lib/Gallery/Image.php on lines 389..389

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

              if (!$this->getAlbum() instanceof Album) {
                  throw new Exception("No valid album has been set"); 
              }
      Severity: Minor
      Found in lib/Gallery/Image.php and 1 other location - About 45 mins to fix
      lib/Gallery/Image.php on lines 318..320

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

              if (is_null($this->lat) || is_null($this->lon)) {
                  return false;
              }
      Severity: Minor
      Found in lib/Gallery/Image.php and 1 other location - About 40 mins to fix
      lib/Prerender/Home.php on lines 147..165

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 24.

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

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

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

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

      Refactorings

      Further Reading

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

                  $this->DateTaken = new DateTime("@" . $exif['DateTimeOriginal']); 
      Severity: Major
      Found in lib/Gallery/Image.php and 2 other locations - About 40 mins to fix
      lib/Feedback/FeedbackItem.php on lines 132..132
      lib/Warnings/Warning.php on lines 135..135

      Duplicated Code

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

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

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

      Tuning

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

          public function setOwner(User $userObject) {
              
              $this->Owner = $userObject; 
              
              return $this;
      Severity: Major
      Found in lib/Gallery/Image.php and 24 other locations - About 40 mins to fix
      lib/Feedback/Feedback.php on lines 52..56
      lib/Gallery/Album.php on lines 279..285
      lib/Gallery/Album.php on lines 317..323
      lib/Gallery/Image.php on lines 278..284
      lib/Glossary/Entry.php on lines 302..306
      lib/Locations/Correction.php on lines 118..124
      lib/News/Article.php on lines 941..945
      lib/Prerender/Prerender.php on lines 89..94
      lib/Railcams/Footage.php on lines 89..95
      lib/Railcams/Photo.php on lines 143..147
      lib/Railcams/Storage.php on lines 95..101
      lib/Railcams/Storage.php on lines 110..116
      lib/SiteMessages/SiteMessage.php on lines 206..210
      lib/Timetables/Timetables.php on lines 52..56
      lib/Timetables/Timetables.php on lines 64..68
      lib/Timetables/Timetables.php on lines 76..80
      lib/Users/SockpuppetManager.php on lines 61..67
      lib/Warnings/Warning.php on lines 249..255
      lib/Warnings/Warning.php on lines 267..273
      lib/AppCore.php on lines 401..407
      lib/AppCore.php on lines 416..422
      lib/AppCore.php on lines 431..437
      lib/AppCore.php on lines 463..469
      lib/AppCore.php on lines 478..484

      Duplicated Code

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

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

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

      Tuning

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

          public function setAlbum(Album $albumObject) {
              
              $this->Album = $albumObject;
              
              return $this;
      Severity: Major
      Found in lib/Gallery/Image.php and 24 other locations - About 40 mins to fix
      lib/Feedback/Feedback.php on lines 52..56
      lib/Gallery/Album.php on lines 279..285
      lib/Gallery/Album.php on lines 317..323
      lib/Gallery/Image.php on lines 460..466
      lib/Glossary/Entry.php on lines 302..306
      lib/Locations/Correction.php on lines 118..124
      lib/News/Article.php on lines 941..945
      lib/Prerender/Prerender.php on lines 89..94
      lib/Railcams/Footage.php on lines 89..95
      lib/Railcams/Photo.php on lines 143..147
      lib/Railcams/Storage.php on lines 95..101
      lib/Railcams/Storage.php on lines 110..116
      lib/SiteMessages/SiteMessage.php on lines 206..210
      lib/Timetables/Timetables.php on lines 52..56
      lib/Timetables/Timetables.php on lines 64..68
      lib/Timetables/Timetables.php on lines 76..80
      lib/Users/SockpuppetManager.php on lines 61..67
      lib/Warnings/Warning.php on lines 249..255
      lib/Warnings/Warning.php on lines 267..273
      lib/AppCore.php on lines 401..407
      lib/AppCore.php on lines 416..422
      lib/AppCore.php on lines 431..437
      lib/AppCore.php on lines 463..469
      lib/AppCore.php on lines 478..484

      Duplicated Code

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

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

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

      Tuning

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

              $album_id = $this->db->fetchOne("SELECT album_id FROM gallery_mig_image WHERE id = ?", $this->id);
      Severity: Major
      Found in lib/Gallery/Image.php and 6 other locations - About 30 mins to fix
      lib/Gallery/Image.php on lines 401..401
      lib/Images/Camera.php on lines 158..158
      lib/Links/Category.php on lines 97..97
      lib/Locos/Date.php on lines 147..147
      lib/News/Topic.php on lines 348..348
      lib/Railcams/Footage.php on lines 164..164

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

                  $albums = $this->db->fetchAll("SELECT id FROM gallery_mig_album WHERE featured_photo = ?", $this->id);
      Severity: Major
      Found in lib/Gallery/Image.php and 6 other locations - About 30 mins to fix
      lib/Gallery/Image.php on lines 263..263
      lib/Images/Camera.php on lines 158..158
      lib/Links/Category.php on lines 97..97
      lib/Locos/Date.php on lines 147..147
      lib/News/Topic.php on lines 348..348
      lib/Railcams/Footage.php on lines 164..164

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 20.

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

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

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

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

      Refactorings

      Further Reading

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

              if (!$this->DateTaken instanceof DateTime) {
                  $this->validateDates(); 
              }
      Severity: Minor
      Found in lib/Gallery/Image.php and 2 other locations - About 30 mins to fix
      lib/Forums/Post.php on lines 562..564
      lib/Locos/Date.php on lines 409..411

      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/Gallery/Image.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/Gallery/Image.php by phpcodesniffer

      Blank line found at start of control structure
      Open

              if (filter_var($id, FILTER_VALIDATE_INT)) {
      Severity: Minor
      Found in lib/Gallery/Image.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/Gallery/Image.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/Gallery/Image.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/Gallery/Image.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/Gallery/Image.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/Gallery/Image.php by phpcodesniffer

      Blank line found at end of control structure
      Open

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

      There are no issues that match your filters.

      Category
      Status