railpage/railpagecore

View on GitHub
lib/Locos/Correction.php

Summary

Maintainability
D
2 days
Test Coverage

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

    private function closeCorrection($type, $reason) {
        
        if (!isset($this->Resolution->User) || !$this->Resolution->User instanceof User) {
            throw new Exception("Cannot close correction - User resolving this correction not specified");
        }
Severity: Minor
Found in lib/Locos/Correction.php - About 1 hr to fix

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

        private function populate($id) {
            
            $query = "SELECT * FROM loco_unit_corrections WHERE correction_id = ?";
            
            $row = $this->db->fetchRow($query, $id);
    Severity: Minor
    Found in lib/Locos/Correction.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private function validate() {
            if (empty($this->text)) {
                throw new Exception("Cannot validate changes to this correction: no text provided");
            }
            
    Severity: Minor
    Found in lib/Locos/Correction.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

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

        private function closeCorrection($type, $reason) {
            
            if (!isset($this->Resolution->User) || !$this->Resolution->User instanceof User) {
                throw new Exception("Cannot close correction - User resolving this correction not specified");
            }
    Severity: Minor
    Found in lib/Locos/Correction.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 closeCorrection uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $Message->body = "Your suggested correction for [url=" . $this->Object->url . "]" . strval($this->Object) . "[/url] " . $action . " by " . $this->Resolution->User->username . ".";
            }
    Severity: Minor
    Found in lib/Locos/Correction.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 '147', column '17').
    Open

        private function populate($id) {
            
            $query = "SELECT * FROM loco_unit_corrections WHERE correction_id = ?";
            
            $row = $this->db->fetchRow($query, $id);
    Severity: Minor
    Found in lib/Locos/Correction.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 '152', column '17').
    Open

        private function populate($id) {
            
            $query = "SELECT * FROM loco_unit_corrections WHERE correction_id = ?";
            
            $row = $this->db->fetchRow($query, $id);
    Severity: Minor
    Found in lib/Locos/Correction.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 commit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $this->db->insert("loco_unit_corrections", $data);
                $this->id = $this->db->lastInsertId();
            }
    Severity: Minor
    Found in lib/Locos/Correction.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 '116', column '13').
    Open

        public function __construct($id = NULL) {
            
            parent::__construct(); 
            
            if ($id = filter_var($id, FILTER_VALIDATE_INT)) {
    Severity: Minor
    Found in lib/Locos/Correction.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

                $Message->body = "Your suggested correction for [url=" . $this->Object->url->url . "]" . strval($this->Object) . "[/url] in [url=" . $this->Object->Class->url->url . "]" . $this->Object->Class->name . "[/url] " . $action . " by " . $this->Resolution->User->username . ".";
    Severity: Major
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locations/Correction.php on lines 275..275

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

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

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

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

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

    Refactorings

    Further Reading

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

                if ($loco_id = filter_var($row['loco_id'], FILTER_VALIDATE_INT)) {
                    $this->Object = new Locomotive($loco_id); 
                    return;
                }
    Severity: Major
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locos/Correction.php on lines 152..155

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

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

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

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

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

    Refactorings

    Further Reading

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

                if ($class_id = filter_var($row['class_id'], FILTER_VALIDATE_INT)) {
                    $this->Object = new LocoClass($class_id); 
                    return;
                }
    Severity: Major
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locos/Correction.php on lines 147..150

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

    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

                case "class_id" : 
                    $return = $this->Object instanceof LocoClass ? $this->Object->id : NULL;
                    break;
    Severity: Major
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locos/Correction.php on lines 210..212

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

                case "loco_id" : 
                    $return = $this->Object instanceof Locomotive ? $this->Object->id : NULL;
                    break;
    Severity: Major
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locos/Correction.php on lines 206..208

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

            if (!empty($this->text)) {
                $Message->body .= "\n\n[quote=Your suggestion]" . $this->text . "[/quote]";
            }
    Severity: Minor
    Found in lib/Locos/Correction.php and 1 other location - About 1 hr to fix
    lib/Locations/Correction.php on lines 277..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 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 5 locations. Consider refactoring.
    Open

            if (!filter_var($this->status)) {
                $this->status = self::STATUS_OPEN;
            }
    Severity: Major
    Found in lib/Locos/Correction.php and 4 other locations - About 55 mins to fix
    lib/Events/Event.php on lines 262..264
    lib/Locations/Location.php on lines 444..446
    lib/News/Article.php on lines 782..784
    lib/Newsletters/Newsletter.php on lines 155..157

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

        public function ignore($reason = NULL) {
            
            $this->closeCorrection("ignore", $reason); 
            
            return $this;
    Severity: Minor
    Found in lib/Locos/Correction.php and 1 other location - About 55 mins to fix
    lib/Locos/Correction.php on lines 282..288

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

        public function close($reason = NULL) {
            
            $this->closeCorrection("accept", $reason); 
            
            return $this;
    Severity: Minor
    Found in lib/Locos/Correction.php and 1 other location - About 55 mins to fix
    lib/Locos/Correction.php on lines 298..304

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 28.

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

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

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

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

    Refactorings

    Further Reading

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

            if (!$this->Date instanceof DateTime) {
                $this->Date = new DateTime;
            }
    Severity: Major
    Found in lib/Locos/Correction.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/Ideas/Idea.php on lines 252..254
    lib/Images/Collection.php on lines 192..194
    lib/Locations/Correction.php on lines 172..174
    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 2 locations. Consider refactoring.
    Open

            if (!is_null($reason)) {
                $Message->body .= "\n\n" . $reason;
            }
    Severity: Minor
    Found in lib/Locos/Correction.php and 1 other location - About 50 mins to fix
    lib/Locations/Correction.php on lines 281..283

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

            if (!isset($this->Resolution->User) || !$this->Resolution->User instanceof User) {
                throw new Exception("Cannot close correction - User resolving this correction not specified");
            }
    Severity: Major
    Found in lib/Locos/Correction.php and 2 other locations - About 45 mins to fix
    lib/Images/Favourites.php on lines 124..126
    lib/Users/Timeline.php on lines 203..205

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

        public function approve($reason = NULL) {
            
            return $this->close($reason); 
            
        }
    Severity: Major
    Found in lib/Locos/Correction.php and 4 other locations - About 35 mins to fix
    lib/Locos/Correction.php on lines 373..377
    lib/News/Base.php on lines 298..300
    lib/Memcached.php on lines 192..194
    lib/Submenu.php on lines 212..214

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

        public function reject($reason = NULL) {
            
            return $this->ignore($reason); 
            
        }
    Severity: Major
    Found in lib/Locos/Correction.php and 4 other locations - About 35 mins to fix
    lib/Locos/Correction.php on lines 387..391
    lib/News/Base.php on lines 298..300
    lib/Memcached.php on lines 192..194
    lib/Submenu.php on lines 212..214

    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

                    $this->Resolution->User = UserFactory::CreateUser($row['resolved_by']);
    Severity: Minor
    Found in lib/Locos/Correction.php and 1 other location - About 35 mins to fix
    lib/Images/Image.php on lines 382..382

    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

                "resolved_by" => (isset($this->Resolution->User) && $this->Resolution->User instanceof User) ? $this->Resolution->User : 0,
    Severity: Major
    Found in lib/Locos/Correction.php and 3 other locations - About 30 mins to fix
    lib/Images/Image.php on lines 464..464
    lib/Images/PhotoOfTheWeek.php on lines 84..92
    lib/Locos/Correction.php on lines 256..256

    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

                "resolved_date" => (isset($this->Resolution->Date) && $this->Resolution->Date instanceof DateTime) ? $this->Resolution->Date->format("Y-m-d H:i:s") : NULL,
    Severity: Major
    Found in lib/Locos/Correction.php and 3 other locations - About 30 mins to fix
    lib/Images/Image.php on lines 464..464
    lib/Images/PhotoOfTheWeek.php on lines 84..92
    lib/Locos/Correction.php on lines 255..255

    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

    The parameter $Object is not named in camelCase.
    Open

        public function setObject($Object = NULL) {
            
            if ($Object instanceof Locomotive) {
                $this->Object = $Object;
            }
    Severity: Minor
    Found in lib/Locos/Correction.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 $Maintainer is not named in camelCase.
    Open

        public function setMaintainer(User $Maintainer) {
            
            if (!isset($this->Resolution)) {
                $this->Resolution = new stdClass;
            }
    Severity: Minor
    Found in lib/Locos/Correction.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/Locos/Correction.php by phpcodesniffer

    Blank line found at end of control structure
    Open

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

    Blank line found at start of control structure
    Open

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

    There are no issues that match your filters.

    Category
    Status