railpage/railpagecore

View on GitHub
lib/Ideas/Idea.php

Summary

Maintainability
D
2 days
Test Coverage

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

class Idea extends AppCore {
    
    /**
     * Idea ID
     * @var int $id
Severity: Minor
Found in lib/Ideas/Idea.php by phpmd

File Idea.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Suggestions for side ideas and improvements, ala Wordpress.org/ideas
 * @since Version 3.8.7
Severity: Minor
Found in lib/Ideas/Idea.php - About 2 hrs to fix

    Method getArray has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getArray() {
            $idea = array(
                "id" => $this->id,
                "title" => $this->title,
                "description" => function_exists("format_post") ? format_post($this->description) : $this->description,
    Severity: Minor
    Found in lib/Ideas/Idea.php - About 1 hr to fix

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

          public function canVote(User $userObject) {
              
              if ($this->status == Ideas::STATUS_DELETED || $this->status == Ideas::STATUS_NO || $this->status == Ideas::STATUS_IMPLEMENTED) {
                  return false;
              }
      Severity: Minor
      Found in lib/Ideas/Idea.php - About 35 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Avoid too many return statements within this method.
      Open

              return true;
      Severity: Major
      Found in lib/Ideas/Idea.php - About 30 mins to fix

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

            private function setDefaults() {
                
                if (!$this->Date instanceof DateTime) {
                    $this->Date = new DateTime;
                }
        Severity: Minor
        Found in lib/Ideas/Idea.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

        Duplicated array key active, first declared at line 194.
        Open

                $status = [
                    "implemented" => Ideas::STATUS_IMPLEMENTED,
                    "declined" => Ideas::STATUS_NO,
                    "inprogress" => Ideas::STATUS_INPROGRESS,
                    "active" => Ideas::STATUS_ACTIVE,
        Severity: Minor
        Found in lib/Ideas/Idea.php by phpmd

        DuplicatedArrayKey

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

        Example

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

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

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

            private function populate($column, $value) {
                
                $query = sprintf("SELECT * FROM idea_ideas WHERE %s = ?", $column);
                
                if (!$row = $this->db->fetchRow($query, $value)) {
        Severity: Minor
        Found in lib/Ideas/Idea.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

                            "large" => function_exists("format_avatar") ? format_avatar($this->Author->avatar, 120) : $this->Author->avatar
        Severity: Major
        Found in lib/Ideas/Idea.php and 1 other location - About 1 hr to fix
        lib/Ideas/Idea.php on lines 536..536

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 36.

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

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

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

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

        Refactorings

        Further Reading

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

                            "small" => function_exists("format_avatar") ? format_avatar($this->Author->avatar, 40) : $this->Author->avatar,
        Severity: Major
        Found in lib/Ideas/Idea.php and 1 other location - About 1 hr to fix
        lib/Ideas/Idea.php on lines 537..537

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 36.

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

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

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

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

        Refactorings

        Further Reading

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

                $this->url = new Url(sprintf("%s/%s", $this->Category->url, $this->slug));
        Severity: Major
        Found in lib/Ideas/Idea.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/Gallery/Image.php on lines 207..207
        lib/Glossary/Entry.php on lines 227..227
        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 7 locations. Consider refactoring.
        Open

                if (!filter_var($this->status, FILTER_VALIDATE_INT)) {
                    $this->status = Ideas::STATUS_ACTIVE;
                }
        Severity: Major
        Found in lib/Ideas/Idea.php and 6 other locations - About 1 hr to fix
        lib/Events/EventDate.php on lines 219..221
        lib/Forums/Forum.php on lines 286..288
        lib/Locations/Correction.php on lines 180..182
        lib/Notifications/Notification.php on lines 179..181
        lib/Notifications/Notification.php on lines 183..185
        lib/Users/Group.php on lines 384..386

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

                if (!filter_var($this->forum_thread_id, FILTER_VALIDATE_INT)) {
                    $this->forum_thread_id = 0;
                }
        Severity: Major
        Found in lib/Ideas/Idea.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/Gallery/Image.php on lines 334..336
        lib/Ideas/Idea.php on lines 272..274
        lib/Locations/Location.php on lines 440..442
        lib/Locations/Location.php on lines 452..454
        lib/Locos/Operator.php on lines 129..131
        lib/Users/User.php on lines 1208..1210

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 31.

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

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

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

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

        Refactorings

        Further Reading

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

                if (!filter_var($this->redmine_id, FILTER_VALIDATE_INT)) {
                    $this->redmine_id = 0;
                }
        Severity: Major
        Found in lib/Ideas/Idea.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/Gallery/Image.php on lines 334..336
        lib/Ideas/Idea.php on lines 268..270
        lib/Locations/Location.php on lines 440..442
        lib/Locations/Location.php on lines 452..454
        lib/Locos/Operator.php on lines 129..131
        lib/Users/User.php on lines 1208..1210

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 31.

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

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

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

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

        Refactorings

        Further Reading

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

                    "votes" => is_array($this->votes) ? count($this->votes) : $this->votes,
        Severity: Major
        Found in lib/Ideas/Idea.php and 2 other locations - About 1 hr to fix
        lib/Railcams/Camera.php on lines 398..398
        lib/SiteEvent.php on lines 183..183

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

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

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 30.

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

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

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

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

        Refactorings

        Further Reading

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

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

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 30.

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

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

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

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

        Refactorings

        Further Reading

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

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

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 30.

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

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

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

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

        Refactorings

        Further Reading

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

                    "description" => function_exists("format_post") ? format_post($this->description) : $this->description,
        Severity: Major
        Found in lib/Ideas/Idea.php and 2 other locations - About 55 mins to fix
        lib/PrivateMessages/Message.php on lines 381..381
        lib/DialogueModal.php on lines 171..171

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 29.

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

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

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

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

        Refactorings

        Further Reading

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

                if (!$this->Date instanceof DateTime) {
                    $this->Date = new DateTime;
                }
        Severity: Major
        Found in lib/Ideas/Idea.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/Gallery/Image.php on lines 326..328
        lib/Glossary/Entry.php on lines 266..268
        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 5 locations. Consider refactoring.
        Open

                if (filter_var($this->forum_thread_id, FILTER_VALIDATE_INT) && $this->forum_thread_id > 0) {
                    return new Thread($this->forum_thread_id);
                }
        Severity: Major
        Found in lib/Ideas/Idea.php and 4 other locations - About 50 mins to fix
        lib/Chronicle/Entry.php on lines 263..271
        lib/Jobs/Job.php on lines 278..284
        lib/Locations/Location.php on lines 659..673
        lib/Railcams/Camera.php on lines 282..284

        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/Ideas/Idea.php and 22 other locations - About 45 mins to fix
        lib/Assets/Asset.php on lines 150..150
        lib/Chronicle/Entry.php on lines 156..156
        lib/Events/Event.php on lines 207..207
        lib/Events/EventDate.php on lines 154..154
        lib/Gallery/Album.php on lines 136..136
        lib/Gallery/Image.php on lines 208..208
        lib/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 3 locations. Consider refactoring.
        Open

                if (!is_array($this->meta)) {
                    $this->meta = []; 
                }
        Severity: Major
        Found in lib/Ideas/Idea.php and 2 other locations - About 45 mins to fix
        lib/Notifications/Notification.php on lines 160..162
        lib/Users/User.php on lines 2891..2893

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 26.

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

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

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

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

        Refactorings

        Further Reading

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

                } elseif (is_string($id) && strlen($id) > 1) {
                    $this->populate("slug", $id); 
                }
        Severity: Major
        Found in lib/Ideas/Idea.php and 4 other locations - About 40 mins to fix
        lib/Content/Page.php on lines 113..117
        lib/Events/EventCategory.php on lines 99..101
        lib/Ideas/Category.php on lines 80..91
        lib/Users/User.php on lines 980..987

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

                    $this->url->redmine = sprintf("http://redmine.railpage.org/redmine/issues/%d", $this->redmine_id); 
        Severity: Major
        Found in lib/Ideas/Idea.php and 30 other locations - About 40 mins to fix
        lib/Content/Page.php on lines 155..155
        lib/Events/EventDate.php on lines 161..161
        lib/Feedback/FeedbackItem.php on lines 147..147
        lib/Feedback/FeedbackItem.php on lines 148..148
        lib/Feedback/FeedbackItem.php on lines 154..154
        lib/Feedback/FeedbackItem.php on lines 155..155
        lib/Forums/Post.php on lines 749..749
        lib/Forums/Post.php on lines 750..750
        lib/Forums/Post.php on lines 751..751
        lib/Forums/Post.php on lines 752..752
        lib/Forums/Post.php on lines 753..753
        lib/Forums/Post.php on lines 754..754
        lib/Forums/Post.php on lines 755..755
        lib/Forums/Post.php on lines 756..756
        lib/Images/Camera.php on lines 131..131
        lib/Images/Competition.php on lines 431..431
        lib/Locos/Operator.php on lines 114..114
        lib/Locos/Operator.php on lines 115..115
        lib/News/Article.php on lines 481..481
        lib/News/Article.php on lines 482..482
        lib/News/Article.php on lines 483..483
        lib/News/Article.php on lines 484..484
        lib/News/Article.php on lines 485..485
        lib/Newsletters/Newsletter.php on lines 267..267
        lib/Newsletters/Newsletter.php on lines 268..268
        lib/Newsletters/Newsletter.php on lines 269..269
        lib/Newsletters/Newsletter.php on lines 270..270
        lib/Reminders/Reminder.php on lines 165..165
        lib/SiteMessages/SiteMessage.php on lines 193..193
        lib/SiteMessages/SiteMessage.php on lines 194..194

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 23.

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

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

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

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

        Refactorings

        Further Reading

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

                    $this->url->$key = sprintf("%s?id=%d&mode=idea.setstatus&status_id=%d", $this->Module->url, $this->id, $val); 
        Severity: Minor
        Found in lib/Ideas/Idea.php and 1 other location - About 40 mins to fix
        lib/Forums/Post.php on lines 824..824

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

                $this->setAuthor(UserFactory::CreateUser($row['author']));
        Severity: Major
        Found in lib/Ideas/Idea.php and 8 other locations - About 30 mins to fix
        lib/Events/Event.php on lines 215..215
        lib/Events/EventDate.php on lines 163..163
        lib/Glossary/Entry.php on lines 170..170
        lib/Images/Collection.php on lines 137..137
        lib/Images/Competition.php on lines 203..203
        lib/Locations/Correction.php on lines 144..144
        lib/PrivateMessages/Message.php on lines 289..289
        lib/PrivateMessages/Message.php on lines 290..290

        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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.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/Ideas/Idea.php by phpcodesniffer

        There are no issues that match your filters.

        Category
        Status