railpage/railpagecore

View on GitHub
lib/News/Topic.php

Summary

Maintainability
F
3 days
Test Coverage

Method fetchStoriesFromSphinx has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
            
            $Sphinx = $this->getSphinx();
        
            $query = $Sphinx->select("*")
Severity: Minor
Found in lib/News/Topic.php - About 1 hr to fix

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

            public function validate() {
                if (empty($this->title)) {
                    throw new Exception("Cannot validate news topic - no title provided"); 
                    return false;
                }
    Severity: Minor
    Found in lib/News/Topic.php - About 45 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

            private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
                
                $Sphinx = $this->getSphinx();
            
                $query = $Sphinx->select("*")
    Severity: Minor
    Found in lib/News/Topic.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            public function __construct($topic_id = false) {
                parent::__construct();
                
                if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
                    $this->id = $topic_id;
    Severity: Minor
    Found in lib/News/Topic.php - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

            public function __construct($topic_id = false) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

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

            private function fetchStoriesFromDatabase($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

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

            private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

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

            public function getStories($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

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

            public function stories($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

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

            public function stories($page = 0, $limit = 25, $total = true) {
                $return = false;
                $mckey = "railpage:topic_id=" . $this->id . ".stories.page=" . $page . ".limit=" . $limit . ".total=" . (int)$total;
                $mcexp = strtotime("+1 hour"); 
                
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

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

            private function load() {
                
                if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                    return;
                }
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

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

            public function stories($page = 0, $limit = 25, $total = true) {
                $return = false;
                $mckey = "railpage:topic_id=" . $this->id . ".stories.page=" . $page . ".limit=" . $limit . ".total=" . (int)$total;
                $mcexp = strtotime("+1 hour"); 
                
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

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

            public function __construct($topic_id = false) {
                parent::__construct();
                
                if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
                    $this->id = $topic_id;
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

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

                    } else {
                        $result = $this->db_readonly->fetchAll("SELECT topicname FROM nuke_topics WHERE topicname = ?", $this->alias); 
                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    ElseExpression

    Since: 1.4.0

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

    Example

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

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

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

            private function fetchStoriesFromDatabase($page = 0, $limit = 25, $total = true) {
                
                $query = "SELECT SQL_CALC_FOUND_ROWS s.*, t.topicname, t.topicimage, t.topictext, u.user_id AS informant_id FROM nuke_stories AS s LEFT JOIN nuke_topics AS t ON s.topic = t.topicid LEFT JOIN nuke_users AS u ON s.informant = u.username WHERE s.topic = ? AND s.approved = ? ORDER BY s.time DESC LIMIT ?, ?"; 
                
                $return = array(
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

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

    Example

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

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

    Avoid unused parameters such as '$total'.
    Open

            private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    UnusedFormalParameter

    Since: 0.2

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

    Example

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

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

    Avoid unused parameters such as '$total'.
    Open

            private function fetchStoriesFromDatabase($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    UnusedFormalParameter

    Since: 0.2

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

    Example

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

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

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

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

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

                $this->url = new Url(sprintf("%s/t/%s", $this->Module->url, $this->alias));
    Severity: Major
    Found in lib/News/Topic.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/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/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

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

                    $row['firstline']   = preg_replace('/([^?!.]*.).*/', '\\1', strip_tags($line[0]));
    Severity: Major
    Found in lib/News/Topic.php and 1 other location - About 1 hr to fix
    lib/News/Topic.php on lines 296..296

    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

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

                        $row['firstline'] = preg_replace('/([^?!.]*.).*/', '\\1', strip_tags($line[0]));
    Severity: Major
    Found in lib/News/Topic.php and 1 other location - About 1 hr to fix
    lib/News/Topic.php on lines 237..237

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

                        if (empty($row['story_slug'])) {
                            $row['slug'] = $this->createSlug($row['story_id']); 
                        }
    Severity: Major
    Found in lib/News/Topic.php and 4 other locations - About 1 hr to fix
    lib/News/Base.php on lines 94..96
    lib/News/Base.php on lines 140..142
    lib/News/Base.php on lines 252..254
    lib/News/Topic.php on lines 239..241

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 32.

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

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

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

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

    Refactorings

    Further Reading

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

                    if (empty($row['slug'])) {
                        $row['slug'] = $this->createSlug($row['sid']); 
                    }
    Severity: Major
    Found in lib/News/Topic.php and 4 other locations - About 1 hr to fix
    lib/News/Base.php on lines 94..96
    lib/News/Base.php on lines 140..142
    lib/News/Base.php on lines 252..254
    lib/News/Topic.php on lines 298..300

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 32.

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

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

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

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

    Refactorings

    Further Reading

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

                $data = array(
                    "topictext" => $this->title,
                    "topicname" => $this->alias,
                    "desc" => $this->desc
                );
    Severity: Major
    Found in lib/News/Topic.php and 5 other locations - About 55 mins to fix
    lib/Events/EventCategory.php on lines 149..153
    lib/Images/Collection.php on lines 268..272
    lib/Images/Collection.php on lines 291..295
    lib/Locos/Manufacturer.php on lines 162..166
    lib/PrivateMessages/Message.php on lines 504..508

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

                    if (count($result)) {
                        $this->alias .= count($result);
                    }
    Severity: Major
    Found in lib/News/Topic.php and 2 other locations - About 55 mins to fix
    lib/Gallery/Album.php on lines 435..437
    lib/Images/Camera.php on lines 160..162

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

                if (empty($this->title)) {
                    throw new Exception("Cannot validate news topic - no title provided"); 
                    return false;
                }
    Severity: Major
    Found in lib/News/Topic.php and 17 other locations - About 45 mins to fix
    lib/Jobs/Job.php on lines 230..233
    lib/Jobs/Job.php on lines 243..246
    lib/Links/Link.php on lines 136..139
    lib/Links/Link.php on lines 141..144
    lib/Links/Link.php on lines 146..149
    lib/Locations/Location.php on lines 881..884
    lib/Locations/Location.php on lines 899..902
    lib/Locos/Type.php on lines 117..120
    lib/Locos/WheelArrangement.php on lines 161..164
    lib/News/Topic.php on lines 356..359
    lib/Sightings/Sighting.php on lines 219..222
    lib/Sightings/Sighting.php on lines 224..227
    lib/Sightings/Sighting.php on lines 229..232
    lib/Sightings/Sighting.php on lines 234..237
    lib/SiteEvent.php on lines 148..151
    lib/SiteEvent.php on lines 153..156
    lib/SiteEvent.php on lines 158..161

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 25.

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

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

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

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

    Refactorings

    Further Reading

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

                if (empty($this->alias)) {
                    throw new Exception("Cannot validate news topic - no alias / permalink provided"); 
                    return false;
                }
    Severity: Major
    Found in lib/News/Topic.php and 17 other locations - About 45 mins to fix
    lib/Jobs/Job.php on lines 230..233
    lib/Jobs/Job.php on lines 243..246
    lib/Links/Link.php on lines 136..139
    lib/Links/Link.php on lines 141..144
    lib/Links/Link.php on lines 146..149
    lib/Locations/Location.php on lines 881..884
    lib/Locations/Location.php on lines 899..902
    lib/Locos/Type.php on lines 117..120
    lib/Locos/WheelArrangement.php on lines 161..164
    lib/News/Topic.php on lines 337..340
    lib/Sightings/Sighting.php on lines 219..222
    lib/Sightings/Sighting.php on lines 224..227
    lib/Sightings/Sighting.php on lines 229..232
    lib/Sightings/Sighting.php on lines 234..237
    lib/SiteEvent.php on lines 148..151
    lib/SiteEvent.php on lines 153..156
    lib/SiteEvent.php on lines 158..161

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 25.

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

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

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

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

    Refactorings

    Further Reading

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

                $this->desc     = isset($row['desc']) ? $row['desc'] : "";
    Severity: Major
    Found in lib/News/Topic.php and 2 other locations - About 45 mins to fix
    lib/SiteMessages/SiteMessage.php on lines 107..107
    lib/Timetables/Point.php on lines 107..107

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 25.

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

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

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

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

    Refactorings

    Further Reading

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

                    "url" => $this->url instanceof Url ? $this->url->getURLs() : [],
    Severity: Major
    Found in lib/News/Topic.php and 2 other locations - About 40 mins to fix
    lib/Gallery/Album.php on lines 391..391
    lib/Images/Image.php on lines 1020..1020

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 24.

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

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

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

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

    Refactorings

    Further Reading

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

                $query = $Sphinx->select("*")
                        ->from("idx_news_article")
                        ->orderBy("story_time_unix", "DESC")
                        ->limit($page * $limit, $limit)
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 40 mins to fix
    lib/News/Article.php on lines 1008..1011
    lib/News/Base.php on lines 67..70
    lib/News/Scraper.php on lines 232..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 23.

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

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

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

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

    Refactorings

    Further Reading

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

                if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
                    return;
                }
    Severity: Minor
    Found in lib/News/Topic.php and 1 other location - About 40 mins to fix
    lib/Locos/Gauge.php on lines 100..102

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 23.

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

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

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

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

    Refactorings

    Further Reading

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

            private function fetchStoriesFromDatabase($page = 0, $limit = 25, $total = true) {
                
                $query = "SELECT SQL_CALC_FOUND_ROWS s.*, t.topicname, t.topicimage, t.topictext, u.user_id AS informant_id FROM nuke_stories AS s LEFT JOIN nuke_topics AS t ON s.topic = t.topicid LEFT JOIN nuke_users AS u ON s.informant = u.username WHERE s.topic = ? AND s.approved = ? ORDER BY s.time DESC LIMIT ?, ?"; 
                
                $return = array(
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 35 mins to fix
    lib/News/Topic.php on lines 178..200
    lib/News/Topic.php on lines 262..315
    lib/News/Topic.php on lines 326..328

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

            private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
                
                $Sphinx = $this->getSphinx();
            
                $query = $Sphinx->select("*")
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 35 mins to fix
    lib/News/Topic.php on lines 178..200
    lib/News/Topic.php on lines 211..251
    lib/News/Topic.php on lines 326..328

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

                    $row['title'] = ContentUtility::FormatTitle($row['title']);
    Severity: Major
    Found in lib/News/Topic.php and 14 other locations - About 35 mins to fix
    lib/Formatting/MultimediaUtility.php on lines 263..263
    lib/Images/Competition.php on lines 351..351
    lib/Images/Exif.php on lines 145..145
    lib/Images/Exif.php on lines 146..146
    lib/Images/Exif.php on lines 147..147
    lib/Images/ImageFactory.php on lines 229..229
    lib/Images/Utility/Finder.php on lines 706..706
    lib/Images/Utility/Finder.php on lines 735..735
    lib/Locos/Utility/LocosUtility.php on lines 56..56
    lib/News/Topic.php on lines 290..290
    lib/News/Topic.php on lines 292..292
    lib/Newsletters/Weekly.php on lines 412..412
    lib/Newsletters/Weekly.php on lines 414..414
    lib/Users/Timeline.php on lines 177..177

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

                        $row['title'] = ContentUtility::FormatTitle($row['story_title']);
    Severity: Major
    Found in lib/News/Topic.php and 14 other locations - About 35 mins to fix
    lib/Formatting/MultimediaUtility.php on lines 263..263
    lib/Images/Competition.php on lines 351..351
    lib/Images/Exif.php on lines 145..145
    lib/Images/Exif.php on lines 146..146
    lib/Images/Exif.php on lines 147..147
    lib/Images/ImageFactory.php on lines 229..229
    lib/Images/Utility/Finder.php on lines 706..706
    lib/Images/Utility/Finder.php on lines 735..735
    lib/Locos/Utility/LocosUtility.php on lines 56..56
    lib/News/Topic.php on lines 233..233
    lib/News/Topic.php on lines 290..290
    lib/Newsletters/Weekly.php on lines 412..412
    lib/Newsletters/Weekly.php on lines 414..414
    lib/Users/Timeline.php on lines 177..177

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

            public function getStories($page = 0, $limit = 25, $total = true) {
                return $this->stories($page, $limit, $total);
            }
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 35 mins to fix
    lib/News/Topic.php on lines 178..200
    lib/News/Topic.php on lines 211..251
    lib/News/Topic.php on lines 262..315

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

            public function stories($page = 0, $limit = 25, $total = true) {
                $return = false;
                $mckey = "railpage:topic_id=" . $this->id . ".stories.page=" . $page . ".limit=" . $limit . ".total=" . (int)$total;
                $mcexp = strtotime("+1 hour"); 
                
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 35 mins to fix
    lib/News/Topic.php on lines 211..251
    lib/News/Topic.php on lines 262..315
    lib/News/Topic.php on lines 326..328

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

                        $row['time_relative'] = ContentUtility::relativeTime($row['story_time_unix']);
    Severity: Major
    Found in lib/News/Topic.php and 14 other locations - About 35 mins to fix
    lib/Formatting/MultimediaUtility.php on lines 263..263
    lib/Images/Competition.php on lines 351..351
    lib/Images/Exif.php on lines 145..145
    lib/Images/Exif.php on lines 146..146
    lib/Images/Exif.php on lines 147..147
    lib/Images/ImageFactory.php on lines 229..229
    lib/Images/Utility/Finder.php on lines 706..706
    lib/Images/Utility/Finder.php on lines 735..735
    lib/Locos/Utility/LocosUtility.php on lines 56..56
    lib/News/Topic.php on lines 233..233
    lib/News/Topic.php on lines 292..292
    lib/Newsletters/Weekly.php on lines 412..412
    lib/Newsletters/Weekly.php on lines 414..414
    lib/Users/Timeline.php on lines 177..177

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

                foreach ($this->db->fetchAll($query, array($this->id, $items_per_page)) as $row) {
                    yield new Article($row['sid']);
                }
    Severity: Minor
    Found in lib/News/Topic.php and 1 other location - About 35 mins to fix
    lib/Locations/Location.php on lines 835..835

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 22.

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

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

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

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

    Refactorings

    Further Reading

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

                if (isset($id) && filter_var($id, FILTER_VALIDATE_INT)) {
                    $this->id = $id;
                    
                    $this->load(); 
                }
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 30 mins to fix
    lib/Glossary/Glossary.php on lines 111..113
    lib/Images/Images.php on lines 113..115
    lib/Images/Images.php on lines 161..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 21.

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

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

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

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

    Refactorings

    Further Reading

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

                    $line = explode("\n", $row['hometext']); 
    Severity: Major
    Found in lib/News/Topic.php and 3 other locations - About 30 mins to fix
    lib/Forums/Forums.php on lines 553..553
    lib/Images/Utility/Finder.php on lines 147..147
    lib/Railcams/Camera.php on lines 279..279

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 21.

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

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

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

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

    Refactorings

    Further Reading

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

                        $result = $this->db_readonly->fetchAll("SELECT topicname FROM nuke_topics WHERE topicname = ?", $this->alias); 
    Severity: Major
    Found in lib/News/Topic.php and 6 other locations - About 30 mins to fix
    lib/Gallery/Image.php on lines 263..263
    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/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 (is_array($matches) && count($matches)) {
                    $return = array(
                        "total" => $meta[1]['Value'],
                        "children" => array(),
                        "page" => $page,
    Severity: Minor
    Found in lib/News/Topic.php and 2 other locations - About 30 mins to fix
    lib/Images/Utility/Finder.php on lines 698..710
    lib/News/Base.php on lines 79..104

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 20.

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

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

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

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

    Refactorings

    Further Reading

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

                    $row['time_relative'] = ContentUtility::relativeTime(strtotime($row['time']));
    Severity: Minor
    Found in lib/News/Topic.php and 1 other location - About 30 mins to fix
    lib/Locations/Locations.php on lines 151..151

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 20.

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

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

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

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

    Refactorings

    Further Reading

    The parameter $items_per_page is not named in camelCase.
    Open

            public function yieldMostReadThisWeek($items_per_page = 25) {
                $query = "SELECT sid FROM nuke_stories WHERE topic = ? ORDER BY weeklycounter DESC LIMIT 0, ?";
                
                foreach ($this->db->fetchAll($query, array($this->id, $items_per_page)) as $row) {
                    yield new Article($row['sid']);
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

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

    Source

    The parameter $topic_id is not named in camelCase.
    Open

            public function __construct($topic_id = false) {
                parent::__construct();
                
                if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
                    $this->id = $topic_id;
    Severity: Minor
    Found in lib/News/Topic.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

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

    Source

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

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

    Blank line found at start of control structure
    Open

                    foreach ($matches as $id => $row) {
    Severity: Minor
    Found in lib/News/Topic.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/News/Topic.php by phpcodesniffer

    Blank line found at end of control structure
    Open

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

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $image;
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!filter_var($this->id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function makeURLs() {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (empty($row['slug'])) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function validate() {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function load() {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    } else {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (isset($id) && filter_var($id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } 
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($this->db->fetchAll($query, array($this->id, $items_per_page)) as $row) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function stories($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 16
    Open

                    foreach ($matches as $id => $row) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function fetchStoriesFromSphinx($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 20
    Open

                        }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function commit() {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->alias)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (is_string($topic_id)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if ($return = $this->fetchStoriesFromSphinx($page, $limit, $total)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $title;
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $desc;
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 20
    Open

                        if (empty($row['story_slug'])) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        class Topic extends Base {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $alias;
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 16
    Open

                    }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function getStories($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $id;
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function fetchStoriesFromDatabase($page = 0, $limit = 25, $total = true) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$result = $this->db_readonly->fetchAll($query, $params)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function getArray() {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($result as $row) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (count($result)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->validate()) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if ($this->id > 0) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function __construct($topic_id = false) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($topic_id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$row = $this->Memcached->fetch($this->mckey)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function populate($row) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$return = $this->Memcached->fetch($mckey)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (is_array($matches) && count($matches)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->title)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->alias)) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (!$id = $this->Memcached->fetch(sprintf("railpage:news.topic.name=%s", $topic_id))) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function yieldMostReadThisWeek($items_per_page = 25) {
    Severity: Minor
    Found in lib/News/Topic.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status