railpage/railpagecore

View on GitHub
lib/Locos/Liveries/Liveries.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

    public function findFromTag($rawtags = false) {
Severity: Minor
Found in lib/Locos/Liveries/Liveries.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 2 locations. Consider refactoring.
Open

    public function listAll() {
        $query = "SELECT livery_id FROM loco_livery ORDER BY livery";
        
        $return = array(); 
        
Severity: Major
Found in lib/Locos/Liveries/Liveries.php and 1 other location - About 1 hr to fix
lib/Locos/Locos.php on lines 703..713

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

            if (preg_match("@railpage\:livery\=([0-9]+)@", $tag, $matches)) {
                $tags[] = $matches[1];
            }
Severity: Major
Found in lib/Locos/Liveries/Liveries.php and 2 other locations - About 1 hr to fix
lib/Locos/Maintainers/Finder.php on lines 209..211
lib/Locos/Maintainers/Finder.php on lines 213..215

Duplicated Code

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

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

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

Tuning

This issue has a mass of 31.

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

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

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

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

Refactorings

Further Reading

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

    public function getAllCountries() {
        
        $query = "SELECT l.country, g.country_name, (SELECT COUNT(*) FROM loco_livery WHERE loco_livery.country = l.country) AS num
            FROM loco_livery AS l
                LEFT JOIN geoplace AS g ON g.country_code = l.country 
Severity: Major
Found in lib/Locos/Liveries/Liveries.php and 14 other locations - About 35 mins to fix
lib/Images/Competitions.php on lines 332..341
lib/Images/Screener.php on lines 258..269
lib/Images/Statistics.php on lines 93..104
lib/Images/Statistics.php on lines 112..133
lib/Images/Statistics.php on lines 141..147
lib/Images/Statistics.php on lines 155..170
lib/Images/Statistics.php on lines 250..256
lib/Images/Statistics.php on lines 264..270
lib/Links/Links.php on lines 227..231
lib/Locations/Locations.php on lines 204..213
lib/Locations/Locations.php on lines 531..535
lib/Users/Admin.php on lines 34..39
lib/Users/Base.php on lines 234..238
lib/Users/Base.php on lines 271..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 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

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

    }

There are no issues that match your filters.

Category
Status