railpage/railpagecore

View on GitHub
lib/Users/Utility/PasswordUtility.php

Summary

Maintainability
B
4 hrs
Test Coverage

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

    public static function validatePassword($password = null, $storedPassword = null, $storedBcrypt = null) {
        
        if (is_null($password)) {
            throw new InvalidArgumentException("No password supplied"); 
        }
Severity: Minor
Found in lib/Users/Utility/PasswordUtility.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 validateParameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function validateParameters($username = null, $password = null, User $userObject) {
        
        /**
         * Check for a valid password
         */
Severity: Minor
Found in lib/Users/Utility/PasswordUtility.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 15 locations. Consider refactoring.
Open

    public static function validatePassword($password = null, $storedPassword = null, $storedBcrypt = null) {
        
        if (is_null($password)) {
            throw new InvalidArgumentException("No password supplied"); 
        }
Severity: Major
Found in lib/Users/Utility/PasswordUtility.php and 14 other locations - About 55 mins to fix
lib/Downloads/Download.php on lines 384..403
lib/Images/ImageFactory.php on lines 30..90
lib/Images/Images.php on lines 95..126
lib/Links/Category.php on lines 122..133
lib/Locations/Locations.php on lines 356..397
lib/Locos/Factory.php on lines 90..123
lib/Locos/LocoClass.php on lines 1038..1061
lib/Locos/Locomotive.php on lines 327..354
lib/Locos/Locomotive.php on lines 711..745
lib/Locos/Locomotive.php on lines 806..817
lib/Locos/Locomotive.php on lines 1118..1144
lib/Locos/Locos.php on lines 995..1019
lib/Modules/Modules.php on lines 91..112
lib/Notifications/Notification.php on lines 465..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 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 21 locations. Consider refactoring.
Open

        if (is_null($storedBcrypt)) {
            throw new InvalidArgumentException("BCrypted password missing"); 
        }
Severity: Major
Found in lib/Users/Utility/PasswordUtility.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/Railcams/Storage/LocalFS.php on lines 127..129
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/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

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

        if (is_null($password)) {
            throw new InvalidArgumentException("No password supplied"); 
        }
Severity: Major
Found in lib/Users/Utility/PasswordUtility.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/Railcams/Storage/LocalFS.php on lines 127..129
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 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

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

        if (is_null($storedPassword)) {
            throw new InvalidArgumentException("Encrypted password missing"); 
        }
Severity: Major
Found in lib/Users/Utility/PasswordUtility.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/Railcams/Storage/LocalFS.php on lines 127..129
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 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

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

        if (password_verify($password, $storedPassword)) {
            return true;
        }
Severity: Minor
Found in lib/Users/Utility/PasswordUtility.php and 2 other locations - About 30 mins to fix
lib/Users/User.php on lines 2424..2426
lib/Users/Utility/PasswordUtility.php on lines 90..92

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

        if (password_verify($password, $storedBcrypt)) {
            return true;
        }
Severity: Minor
Found in lib/Users/Utility/PasswordUtility.php and 2 other locations - About 30 mins to fix
lib/Users/User.php on lines 2424..2426
lib/Users/Utility/PasswordUtility.php on lines 86..88

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

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

    }

Arguments with default values must be at the end of the argument list
Open

    public static function validateParameters($username = null, $password = null, User $userObject) {

There are no issues that match your filters.

Category
Status