resource-watch/resource-watch-manager

View on GitHub
app/controllers/api_controller.rb

Summary

Maintainability
B
6 hrs
Test Coverage
B
82%

Method log_request_to_cloud_watch has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def log_request_to_cloud_watch(validation_response, request)
    logger.debug 'Logging request to CloudWatch'

    log_query = request.query_parameters.except(:loggedUser)

Severity: Minor
Found in app/controllers/api_controller.rb - About 1 hr to fix

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

      def validate_request(request)
        logger.debug 'Validating request'
    
        if request.headers['Authorization'].nil?
          logger.debug 'No authorization header found'
    Severity: Minor
    Found in app/controllers/api_controller.rb - About 1 hr to fix

      Method validate_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_request(request)
          logger.debug 'Validating request'
      
          if request.headers['Authorization'].nil?
            logger.debug 'No authorization header found'
      Severity: Minor
      Found in app/controllers/api_controller.rb - 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 validate_user_and_application has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_user_and_application
          validation_response = validate_request(request)
          logger.debug 'validation response: ' + validation_response.to_json
      
          return false unless validation_response
      Severity: Minor
      Found in app/controllers/api_controller.rb - About 55 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 log_request_to_cloud_watch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def log_request_to_cloud_watch(validation_response, request)
          logger.debug 'Logging request to CloudWatch'
      
          log_query = request.query_parameters.except(:loggedUser)
      
      
      Severity: Minor
      Found in app/controllers/api_controller.rb - About 45 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

      There are no issues that match your filters.

      Category
      Status