ruby-grape/grape

View on GitHub

Showing 83 of 87 total issues

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

        def validate_param!(attr_name, params)
          raise validation_exception(attr_name) unless params.is_a? Hash

          new_value = coerce_value(params[attr_name])

Severity: Minor
Found in lib/grape/validations/validators/coerce_validator.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 build_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def build_headers
      Grape::Util::Lazy::Object.new do
        env.each_pair.with_object(Grape::Util::Header.new) do |(k, v), headers|
          next unless k.to_s.start_with? HTTP_PREFIX

Severity: Minor
Found in lib/grape/request.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 stream has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def stream(value = nil)
        return if value.nil? && @stream.nil?

        header Rack::CONTENT_LENGTH, nil
        header Grape::Http::Headers::TRANSFER_ENCODING, nil
Severity: Minor
Found in lib/grape/dsl/inside_route.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