pac4j-core/src/main/java/org/pac4j/core/authorization/checker/DefaultAuthorizationChecker.java
Method retrieveAuthorizer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
protected Authorizer retrieveAuthorizer(final String authorizerName, final Map<String, Authorizer> authorizersMap) {
Authorizer authorizer = null;
for (val entry : authorizersMap.entrySet()) {
if (areEqualsIgnoreCaseAndTrim(entry.getKey(), authorizerName)) {
authorizer = entry.getValue();
- Read upRead up
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
Method isAuthorized
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public boolean isAuthorized(final WebContext context, final SessionStore sessionStore, final List<UserProfile> profiles,
final String authorizersValue, final Map<String, Authorizer> authorizersMap, final List<Client> clients) {
Method computeAuthorizers
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
protected List<Authorizer> computeAuthorizers(final WebContext context, final List<UserProfile> profiles, final String authorizersValue,
final Map<String, Authorizer> authorizersMap, final List<Client> clients) {
Method isAuthorized
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
protected boolean isAuthorized(final WebContext context, final SessionStore sessionStore,
final List<UserProfile> profiles, final Collection<Authorizer> authorizers) {
// authorizations check comes after authentication and profile must not be null nor empty
assertTrue(isNotEmpty(profiles), "profiles must not be null or empty");
if (isNotEmpty(authorizers)) {
- Read upRead up
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
Avoid too many return
statements within this method. Open
Open
return CSRF_AUTHORIZER;
Avoid too many return
statements within this method. Open
Open
return authorizer;