railpage/railpagecore

View on GitHub
lib/Railcams/Storage/LocalFS.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method storeFile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function storeFile($tmpFile, $origFile) {
        
        if (!file_exists($tmpFile)) {
            throw new InvalidArgumentException("Supplied file path " . $tmpFile . " does not exist"); 
        }
Severity: Minor
Found in lib/Railcams/Storage/LocalFS.php - About 1 hr to fix

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

            if (!is_array($config) || count($config) === 0) {
                throw new InvalidArgumentException("No configuration array was supplied"); 
            }
    Severity: Major
    Found in lib/Railcams/Storage/LocalFS.php and 2 other locations - About 1 hr to fix
    lib/Downloads/Download.php on lines 204..206
    lib/Locos/Locomotive.php on lines 387..389

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

    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 (!file_exists($tmpFile)) {
                throw new InvalidArgumentException("Supplied file path " . $tmpFile . " does not exist"); 
            }
    Severity: Major
    Found in lib/Railcams/Storage/LocalFS.php and 1 other location - About 1 hr to fix
    lib/Railcams/Storage.php on lines 129..131

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

            if (file_exists($dstPath)) {
                throw new Exception("Could not store railcam footage in LocalFS - destination file already exists"); 
            }
    Severity: Major
    Found in lib/Railcams/Storage/LocalFS.php and 20 other locations - About 35 mins to fix
    lib/Events/EventDate.php on lines 372..374
    lib/Images/Image.php on lines 963..965
    lib/Images/Image.php on lines 1095..1097
    lib/Images/Images.php on lines 96..98
    lib/Images/Images.php on lines 137..139
    lib/Locations/Region.php on lines 93..95
    lib/Locos/Locos.php on lines 590..592
    lib/Locos/Locos.php on lines 901..903
    lib/Locos/Locos.php on lines 925..927
    lib/Users/User.php on lines 2572..2574
    lib/Users/User.php on lines 2576..2578
    lib/Users/User.php on lines 2584..2586
    lib/Users/Utility/PasswordUtility.php on lines 70..72
    lib/Users/Utility/PasswordUtility.php on lines 74..76
    lib/Users/Utility/PasswordUtility.php on lines 78..80
    lib/API.php on lines 124..126
    lib/API.php on lines 194..196
    lib/BanControl/BanControl.php on lines 243..245
    lib/BanControl/BanControl.php on lines 354..356
    lib/BanControl/BanControl.php on lines 358..360

    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

        }

    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

        }

    There are no issues that match your filters.

    Category
    Status