railpage/railpagecore

View on GitHub
lib/Prerender/Prerender.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function setCaching($isEnabled = true, $lifetime = 300, $isCompileCheckEnabled = true) {
Severity: Minor
Found in lib/Prerender/Prerender.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 setCaching has a boolean flag argument $isCompileCheckEnabled, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function setCaching($isEnabled = true, $lifetime = 300, $isCompileCheckEnabled = true) {
Severity: Minor
Found in lib/Prerender/Prerender.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

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

        $defaultParams = [
            "handheld" => false,
            "touch" => false
        ];
Severity: Major
Found in lib/Prerender/Prerender.php and 2 other locations - About 40 mins to fix
lib/Images/Provider/Flickr.php on lines 364..367
lib/Railcams/Provider/Flickr.php on lines 222..225

Duplicated Code

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

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

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

Tuning

This issue has a mass of 24.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 23.

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

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

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

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

Refactorings

Further Reading

Avoid excessively long variable names like $isCompileCheckEnabled. Keep variable name length under 20.
Open

    public function setCaching($isEnabled = true, $lifetime = 300, $isCompileCheckEnabled = true) {
Severity: Minor
Found in lib/Prerender/Prerender.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

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

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

Spaces must be used to indent lines; tabs are not allowed
Open

    
Severity: Minor
Found in lib/Prerender/Prerender.php by phpcodesniffer

There are no issues that match your filters.

Category
Status