Showing 8 of 8 total issues

Class Endpoint has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Endpoint

    # Raised when render is called and a response body is already present.
    class DoubleRenderError < StandardError
    end
Severity: Minor
Found in lib/crepe/endpoint.rb - About 4 hrs to fix

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

      class API
    
        METHODS = %w[GET POST PUT PATCH DELETE]
    
        SEPARATORS = %w[ / . ? ]
    Severity: Minor
    Found in lib/crepe/api.rb - About 2 hrs to fix

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

            def call env
              status, headers, body = @app.call env
      
              if status == 200 && !env['crepe.status']
                case env['REQUEST_METHOD']
      Severity: Minor
      Found in lib/crepe/middleware/restful_status.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 call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def call env
            @env = env
      
            halt = catch :halt do
              begin
      Severity: Minor
      Found in lib/crepe/endpoint.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 handle_exception has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_exception exception
            classes = config[:rescuers].keys.select { |c| exception.is_a? c }
      
            if handler = config[:rescuers][classes.sort.first]
              handler = method handler if handler.is_a? Symbol
      Severity: Minor
      Found in lib/crepe/endpoint.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 cache_control_header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def cache_control_header
            return 'max-age=0, private, must-revalidate' if cache_control.empty?
      
            header = cache_control.map do |key, value|
              next unless value
      Severity: Minor
      Found in lib/crepe/response.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

      Method helper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def helper mod = nil, prepend: false, &block
              if block
                warn 'block takes precedence over module' if mod
                config[:endpoint].class_eval(&block)
              else
      Severity: Minor
      Found in lib/crepe/api.rb - 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 generate_options_routes! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def generate_options_routes!
              paths = routes.group_by { |_, cond| cond[:path_info] }
              paths.each do |path, options|
                allowed = options.map { |_, cond| cond[:request_method] }
                next if allowed.include?('OPTIONS') || allowed.none?
      Severity: Minor
      Found in lib/crepe/api.rb - 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