mepatterson/grape_ape_rails

View on GitHub
lib/grape_ape_rails/handlers/formatters.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

        def layout_template
          set_layouts_base unless env['api.tilt.layouts_base']
          ver = env['rack.routing_args'][:route_info].route_version
          layout_path = "#{env['api.tilt.layouts_base']}/#{ver}.json.haml"
          if File.exist?(layout_path)
Severity: Minor
Found in lib/grape_ape_rails/handlers/formatters.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.call(message, backtrace, options, env)
        err = { error: { code: 'ERROR', message: message } }
        if message.is_a?(Hash) && message[:code].present? && message[:message].present?
          full_msg = "[#{message[:code]}] #{message[:message]}"
          err = { error: { code: message[:code], message: full_msg } }
Severity: Minor
Found in lib/grape_ape_rails/handlers/formatters.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

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

        def call(object, env)
          @env = env
          @endpoint = env['api.endpoint']
          if rablable?
            rabl do |template|
Severity: Minor
Found in lib/grape_ape_rails/handlers/formatters.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

There are no issues that match your filters.

Category
Status