pac4j-core/src/main/java/org/pac4j/core/matching/checker/DefaultMatchingChecker.java

Summary

Maintainability
C
1 day
Test Coverage

Method retrieveMatchers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected List<Matcher> retrieveMatchers(final String matcherName, final Map<String, Matcher> matchersMap) {
        final List<Matcher> results = new ArrayList<>();
        for (val entry : matchersMap.entrySet()) {
            if (areEqualsIgnoreCaseAndTrim(entry.getKey(), matcherName)) {
                results.add(entry.getValue());

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 retrieveMatchers has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected List<Matcher> retrieveMatchers(final String matcherName, final Map<String, Matcher> matchersMap) {
        final List<Matcher> results = new ArrayList<>();
        for (val entry : matchersMap.entrySet()) {
            if (areEqualsIgnoreCaseAndTrim(entry.getKey(), matcherName)) {
                results.add(entry.getValue());

    Method computeMatchersFromNames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected List<Matcher> computeMatchersFromNames(final String matchersValue, final Map<String, Matcher> matchersMap) {
            assertNotNull("matchersMap", matchersMap);
            final List<Matcher> matchers = new ArrayList<>();
            final List<String> names = new ArrayList<>(Arrays.asList(matchersValue.split(Pac4jConstants.ELEMENT_SEPARATOR)));
            for (var i = 0; i < names.size(); ) {

    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 matches has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected boolean matches(final CallContext ctx, final Collection<Matcher> matchers) {
            if (!matchers.isEmpty()) {
                // check matching using matchers: all must be satisfied
                for (val matcher : matchers) {
                    val matches = matcher.matches(ctx);

    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

                    return List.of(CACHE_CONTROL_MATCHER);

      Avoid too many return statements within this method.
      Open

                      return List.of(CORS_MATCHER);

        Avoid too many return statements within this method.
        Open

                        return List.of(STRICT_TRANSPORT_MATCHER);

          Avoid too many return statements within this method.
          Open

                  return results;

            Avoid too many return statements within this method.
            Open

                            return List.of(CSRF_TOKEN_MATCHER);

              Avoid too many return statements within this method.
              Open

                              return List.of(XSS_PROTECTION_MATCHER);

                Avoid too many return statements within this method.
                Open

                                return List.of(X_FRAME_OPTIONS_MATCHER);

                  Avoid too many return statements within this method.
                  Open

                                  return List.of(X_CONTENT_TYPE_OPTIONS_MATCHER);

                    There are no issues that match your filters.

                    Category
                    Status