SeunAdelekan/Kanary

View on GitHub

Showing 19 of 77 total issues

Method resolveTargetRoute has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
Open

    /**
     * Method used for route resolution
     * @param method HTTP method of the request
     * @param target Target resource
     * @return route required to handle HTTP request
Severity: Minor
Found in src/main/com/iyanuadelekan/kanary/handlers/AppHandler.kt - About 5 hrs 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

Class AppRouter has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

/**
 * @author Iyanu Adelekan on 16/08/2018.
 *
 * Core application router class. Utilize instances of this class
 * to compose server routes. Upon composition of a route it must be
Severity: Minor
Found in src/main/com/iyanuadelekan/kanary/app/router/AppRouter.kt - About 2 hrs to fix

    Method fetchUserFeed has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        fun fetchUserFeed(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
            // Create json object mapper
            val mapper = ObjectMapper()
            val responseRootNode = mapper.createObjectNode()
    
    
    Severity: Major
    Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/timeline.kt - About 2 hrs to fix

      Class Router has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

      /**
       * @author Iyanu Adelekan on 16/08/2018.
       *
       * Interface defining methods that must be implemented by an application router.
       */
      Severity: Minor
      Found in src/main/com/iyanuadelekan/kanary/app/framework/router/Router.kt - About 2 hrs to fix

        Method addRoute has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
        Open

            /**
             * Invoked to register a new route to the router.
             *
             * @param routeType - type of route to be added. See [RouteType].
             * @param path - URL path.
        Severity: Minor
        Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - About 2 hrs 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 userSignUp has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            fun userSignUp(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                // Create json object mapper
                val mapper = ObjectMapper()
                val responseRootNode = mapper.createObjectNode()
        
        
        Severity: Minor
        Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/auth.kt - About 1 hr to fix

          Method resolveTargetRoute has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              /**
               * Method used for route resolution
               * @param method HTTP method of the request
               * @param target Target resource
               * @return route required to handle HTTP request
          Severity: Minor
          Found in src/main/com/iyanuadelekan/kanary/handlers/AppHandler.kt - About 1 hr to fix

            Method userSignUp has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
            Open

                fun userSignUp(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                    // Create json object mapper
                    val mapper = ObjectMapper()
                    val responseRootNode = mapper.createObjectNode()
            
            
            Severity: Minor
            Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/auth.kt - About 1 hr 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 fetchFeed has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                fun fetchFeed(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                    // Create json object mapper
                    val mapper = ObjectMapper()
                    val responseRootNode = mapper.createObjectNode()
            
            
            Severity: Minor
            Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/timeline.kt - About 1 hr to fix

              Method createCweet has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  fun createCweet(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                      // Create json object mapper
                      val mapper = ObjectMapper()
                      val responseRootNode = mapper.createObjectNode()
              
              
              Severity: Minor
              Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/timeline.kt - About 1 hr to fix

                Method userSignIn has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    fun userSignIn(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                        // Create json object mapper
                        val mapper = ObjectMapper()
                        val responseRootNode = mapper.createObjectNode()
                
                
                Severity: Minor
                Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/auth.kt - About 1 hr to fix

                  Method addRoute has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      /**
                       * Invoked to register a new route to the router.
                       *
                       * @param routeType - type of route to be added. See [RouteType].
                       * @param path - URL path.
                  Severity: Minor
                  Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - About 1 hr to fix

                    Method fetchUserFeed has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Open

                        fun fetchUserFeed(baseRequest: Request, request: HttpServletRequest, response: HttpServletResponse) {
                            // Create json object mapper
                            val mapper = ObjectMapper()
                            val responseRootNode = mapper.createObjectNode()
                    
                    
                    Severity: Minor
                    Found in examples/Kanary-Mini-Twitter-Clone/src/curious/cwitter/timeline.kt - About 1 hr 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 handle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        /**
                         * Handles server HTTP requests.
                         *
                         * @param path - request path.
                         * @param immutableRequest - immutable jetty specific request instance.
                    Severity: Minor
                    Found in src/main/com/iyanuadelekan/kanary/app/handler/AppRequestHandler.kt - About 1 hr to fix

                      Method getRouteNode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          /**
                           * Invoked to resolve a corresponding RouteNode to a given URL target - if any.
                           *
                           * @param path - URL path (target).
                           * @return [RouteNode] - Returns corresponding instance of [RouteNode], if one exists. Else returns null.
                      Severity: Minor
                      Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (i == subPaths.size - 1) {
                                                    childNode.action = action
                                                }
                        Severity: Major
                        Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if (middleware != null) {
                                                      childNode.addMiddleware(middleware)
                                                  }
                          Severity: Major
                          Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - About 45 mins to fix

                            Method sendMail has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                        title: String,
                                        subject: String,
                                        body: String,
                                        sender: String,
                                        receiver: String): Any

                              Method getRouteNode has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                              Open

                                  /**
                                   * Invoked to resolve a corresponding RouteNode to a given URL target - if any.
                                   *
                                   * @param path - URL path (target).
                                   * @return [RouteNode] - Returns corresponding instance of [RouteNode], if one exists. Else returns null.
                              Severity: Minor
                              Found in src/main/com/iyanuadelekan/kanary/app/router/RouteManager.kt - 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