railpage/railpagecore

View on GitHub
lib/Users/SockpuppetManager.php

Summary

Maintainability
B
4 hrs
Test Coverage

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

    public function compare() {
        
        /**
         * Load our reference data first
         */
Severity: Minor
Found in lib/Users/SockpuppetManager.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

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

        foreach ($ref as $key => $lookup) {
            $this->hashes[$key]['reference'] = $SimHash->hash($Extractor->extract($lookup), SimHash::SIMHASH_64);
        }
Severity: Major
Found in lib/Users/SockpuppetManager.php and 1 other location - About 1 hr to fix
lib/Users/SockpuppetManager.php on lines 118..120

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

            foreach ($suspectData as $key => $lookup) {
                $this->hashes[$key]['suspect'] = $SimHash->hash($Extractor->extract($lookup), SimHash::SIMHASH_64);
            }
Severity: Major
Found in lib/Users/SockpuppetManager.php and 1 other location - About 1 hr to fix
lib/Users/SockpuppetManager.php on lines 108..110

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

    public function setReferenceUser(User $userObject) {
        
        $this->ReferenceUser = $userObject;
        
        return $this;
Severity: Major
Found in lib/Users/SockpuppetManager.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/Prerender/Prerender.php on lines 89..94
lib/Railcams/Footage.php on lines 89..95
lib/Railcams/Photo.php on lines 143..147
lib/Railcams/Storage.php on lines 95..101
lib/Railcams/Storage.php on lines 110..116
lib/SiteMessages/SiteMessage.php on lines 206..210
lib/Timetables/Timetables.php on lines 52..56
lib/Timetables/Timetables.php on lines 64..68
lib/Timetables/Timetables.php on lines 76..80
lib/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

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

    }

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

    }

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

    }

Blank line found at end of control structure
Open

            

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

    }

Blank line found at start of control structure
Open

        foreach ($this->suspects as $Suspect) {

There are no issues that match your filters.

Category
Status