encryptorcode/iam-oauth

View on GitHub

Showing 7 of 407 total issues

Method login has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

    public String login(HttpServletRequest request, HttpServletResponse response, String state, String grantCode) throws UserNotAllowedException {
        Map<String, OauthProvider> providers = configuration.oauthProviders;
        if (!providers.containsKey(state)) {
            LOGGER.log(Level.SEVERE, "INVALID_PROVIDER :: Redirecting the user to login page as given provider id is invalid: {0}", new String[]{state});
            return configuration.loginPath;

    Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

        public void initialize() {
            // Mandatory fields not set
            if (this.configuration.oauthProviders.size() == 0) {
                throw new RuntimeException("No oauth providers registered");
            }

      Method preProcessRequest has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

          public void preProcessRequest(HttpServletRequest request, HttpServletResponse response) {
              AuthenticationThreadLocal.clear();
              AuthenticationThreadLocal.setCurrentRequest(request);
      
              String sessionIdentifier = getAuthCookieValue(request);

        Method login has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            public String login(HttpServletRequest request, HttpServletResponse response, String state, String grantCode) throws UserNotAllowedException {
                Map<String, OauthProvider> providers = configuration.oauthProviders;
                if (!providers.containsKey(state)) {
                    LOGGER.log(Level.SEVERE, "INVALID_PROVIDER :: Redirecting the user to login page as given provider id is invalid: {0}", new String[]{state});
                    return configuration.loginPath;

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

            public String getLoginRedirectPath(HttpServletRequest request, String providerId, String redirectPath) {
        
                // user is already logged in
                User user = getCurrentUser();
                if (user != null) {
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - About 35 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

        Method preProcessRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            public void preProcessRequest(HttpServletRequest request, HttpServletResponse response) {
                AuthenticationThreadLocal.clear();
                AuthenticationThreadLocal.setCurrentRequest(request);
        
                String sessionIdentifier = getAuthCookieValue(request);
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - 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

        Method getAuthCookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Confirmed

            private Cookie getAuthCookie(HttpServletRequest request) {
                Cookie[] cookies = request.getCookies();
                Cookie authCookie = null;
                if (cookies != null) {
                    for (Cookie cookie : cookies) {
        Severity: Minor
        Found in src/main/java/io/github/encryptorcode/service/AuthenticationService.java - 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

        Severity
        Category
        Status
        Source
        Language