intridea/grape

View on GitHub

Showing 78 of 84 total issues

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

        def call(message, backtrace, options = {}, env = nil, original_exception = nil)
          message = present(message, env)

          result = message.is_a?(Hash) ? message : { message: message }
          rescue_options = options[:rescue_options] || {}
Severity: Minor
Found in lib/grape/error_formatter/xml.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 transaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def transaction(env)
      input, method = *extract_input_and_method(env)
      response = yield(input, method)

      return response if response && !(cascade = cascade?(response))
Severity: Minor
Found in lib/grape/router.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 validate_param! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def validate_param!(attr_name, params)
          return if (options_key?(:value) ? @option[:value] : @option) || !params.is_a?(Hash)

          value = params[attr_name]
          value = value.strip if value.respond_to?(:strip)
Severity: Minor
Found in lib/grape/validations/validators/allow_blank_validator.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 guess_coerce_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def guess_coerce_type(coerce_type, *values_list)
        return coerce_type unless coerce_type == Array

        values_list.each do |values|
          next if !values || values.is_a?(Proc)
Severity: Minor
Found in lib/grape/validations/params_scope.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 header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def header(key = nil, val = nil)
        if key
          val ? header[key.to_s] = val : header.delete(key.to_s)
        else
          @header ||= Grape::Util::Header.new
Severity: Minor
Found in lib/grape/dsl/headers.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 declared_hash_attr has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def declared_hash_attr(passed_params, options, declared_param, params_nested_path, memo)
Severity: Minor
Found in lib/grape/dsl/inside_route.rb - About 35 mins to fix

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

            def initialize(attrs, options, required, scope, *opts)
    Severity: Minor
    Found in lib/grape/validations/validators/base.rb - About 35 mins to fix

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

              def initialize(attrs, options, required, scope, **opts)
      Severity: Minor
      Found in lib/grape/validations/validators/default_validator.rb - About 35 mins to fix

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

              def validate(type, options, attrs, doc, opts)
        Severity: Minor
        Found in lib/grape/validations/params_scope.rb - About 35 mins to fix

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

                  def call(message, backtrace, options = {}, env = nil, original_exception = nil)
          Severity: Minor
          Found in lib/grape/error_formatter/txt.rb - About 35 mins to fix

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

                    def initialize(attrs, options, required, scope, **opts)
            Severity: Minor
            Found in lib/grape/validations/validators/coerce_validator.rb - About 35 mins to fix

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

                      def initialize(attrs, options, required, scope, **opts)
              Severity: Minor
              Found in lib/grape/validations/validators/except_values_validator.rb - About 35 mins to fix

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

                      def error!(message, status = options[:default_status], headers = {}, backtrace = [], original_exception = nil)
                Severity: Minor
                Found in lib/grape/middleware/error.rb - About 35 mins to fix

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

                          def initialize(attrs, options, required, scope, **opts)
                  Severity: Minor
                  Found in lib/grape/validations/validators/values_validator.rb - About 35 mins to fix

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

                            def call(message, backtrace, options = {}, env = nil, original_exception = nil)
                    Severity: Minor
                    Found in lib/grape/error_formatter/xml.rb - About 35 mins to fix

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

                              def call(message, backtrace, options = {}, env = nil, original_exception = nil)
                      Severity: Minor
                      Found in lib/grape/error_formatter/json.rb - About 35 mins to fix

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

                                def validate!(params)
                                  attrs = SingleAttributeIterator.new(self, @scope, params)
                                  attrs.each do |resource_params, attr_name|
                                    next unless @scope.meets_dependency?(resource_params, params)
                        
                        
                        Severity: Minor
                        Found in lib/grape/validations/validators/default_validator.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 push_declared_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def push_declared_params(attrs, **opts)
                                opts = opts.merge(declared_params_scope: self) unless opts.key?(:declared_params_scope)
                                if lateral?
                                  @parent.push_declared_params(attrs, **opts)
                                else
                        Severity: Minor
                        Found in lib/grape/validations/params_scope.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 redirect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def redirect(url, permanent: false, body: nil, **_options)
                                body_message = body
                                if permanent
                                  status 301
                                  body_message ||= "This resource has been moved permanently to #{url}."
                        Severity: Minor
                        Found in lib/grape/dsl/inside_route.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 extract_message_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def extract_message_option(attrs)
                                return nil unless attrs.is_a?(Array)
                        
                                opts = attrs.last.is_a?(Hash) ? attrs.pop : {}
                                opts.key?(:message) && !opts[:message].nil? ? opts.delete(:message) : nil
                        Severity: Minor
                        Found in lib/grape/validations/params_scope.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

                        Severity
                        Category
                        Status
                        Source
                        Language