ruby-grape/grape-swagger

View on GitHub

Showing 36 of 36 total issues

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

  class Endpoint
    def content_types_for(target_class)
      content_types = (target_class.content_types || {}).values

      if content_types.empty?
Severity: Minor
Found in lib/grape-swagger/endpoint.rb - About 5 hrs to fix

    Method response_object has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def response_object(route, options)
          codes(route).each_with_object({}) do |value, memo|
            value[:message] ||= ''
            memo[value[:code]] = { description: value[:message] ||= '' } unless memo[value[:code]].present?
            memo[value[:code]][:headers] = value[:headers] if value[:headers]
    Severity: Minor
    Found in lib/grape-swagger/endpoint.rb - About 4 hrs 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

    File endpoint.rb has 335 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'active_support'
    require 'active_support/core_ext/string/inflections'
    require 'grape-swagger/endpoint/params_parser'
    
    module Grape
    Severity: Minor
    Found in lib/grape-swagger/endpoint.rb - About 4 hrs to fix

      Class MoveParams has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class MoveParams
            class << self
              attr_accessor :definitions
      
              def can_be_moved?(http_verb, params)
      Severity: Minor
      Found in lib/grape-swagger/doc_methods/move_params.rb - About 3 hrs to fix

        Method success_code_from_entity has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def success_code_from_entity(route, entity)
              default_code = GrapeSwagger::DocMethods::StatusCodes.get[route.request_method.downcase.to_sym]
              if entity.is_a?(Hash)
                default_code[:code] = entity[:code] if entity[:code].present?
                default_code[:model] = entity[:model] if entity[:model].present?
        Severity: Minor
        Found in lib/grape-swagger/endpoint.rb - About 2 hrs 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 combine_routes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def combine_routes(app, doc_klass)
            app.routes.each do |route|
              route_path = route.path
              route_match = route_path.split(/^.*?#{route.prefix}/).last
              next unless route_match
        Severity: Minor
        Found in lib/grape-swagger.rb - About 2 hrs 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 params_object has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def params_object(route, options, path)
              parameters = build_request_params(route, options).each_with_object([]) do |(param, value), memo|
                next if hidden_parameter?(value)
        
                value = { required: false }.merge(value) if value.is_a?(Hash)
        Severity: Minor
        Found in lib/grape-swagger/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 move_params_to_new has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                def move_params_to_new(definition, params)
                  params, nested_params = params.partition { |x| !x[:name].to_s.include?('[') }
                  params.each do |param|
                    property = param[:name]
                    param_properties, param_required = build_properties([param])
        Severity: Minor
        Found in lib/grape-swagger/doc_methods/move_params.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 setup has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def setup(options)
              options = DEFAULTS.merge(options)
        
              # options could be set on #add_swagger_documentation call,
              # for available options see #defaults
        Severity: Minor
        Found in lib/grape-swagger/doc_methods.rb - About 1 hr to fix

          Method build has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def build(route, options = {})
                    path = route.path.dup
                    # always removing format
                    path.sub!(/\(\.\w+?\)$/, '')
                    path.sub!('(.:format)', '')
          Severity: Minor
          Found in lib/grape-swagger/doc_methods/path_string.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 parse_array_item has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def parse_array_item(definitions, type, value_type)
                    array_items = {}
                    if definitions[value_type[:data_type]]
                      array_items['$ref'] = "#/definitions/#{@parsed_param[:type]}"
                    else
          Severity: Minor
          Found in lib/grape-swagger/doc_methods/parse_params.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 build_memo_schema has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_memo_schema(memo, route, value, response_model, options)
                if memo[value[:code]][:schema] && value[:as]
                  memo[value[:code]][:schema][:properties].merge!(build_reference(route, value, response_model, options))
          
                  if value[:required]
          Severity: Minor
          Found in lib/grape-swagger/endpoint.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 param_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def param_type(value_type)
                    param_type = value_type[:param_type] || value_type[:in]
                    if value_type[:path].include?("{#{value_type[:param_name]}}")
                      'path'
                    elsif param_type
          Severity: Minor
          Found in lib/grape-swagger/doc_methods/parse_params.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 parse_request_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def parse_request_params
                  public_params.each_with_object({}) do |(name, options), memo|
                    name = name.to_s
                    param_type = options[:type]
                    param_type = param_type.to_s unless param_type.nil?
          Severity: Minor
          Found in lib/grape-swagger/endpoint/params_parser.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 parse_enum_or_range_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def parse_enum_or_range_values(values)
                    case values
                    when Proc
                      parse_enum_or_range_values(values.call) if values.parameters.empty?
                    when Range
          Severity: Minor
          Found in lib/grape-swagger/doc_methods/parse_params.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 build_memo_schema has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def build_memo_schema(memo, route, value, response_model, options)
          Severity: Minor
          Found in lib/grape-swagger/endpoint.rb - About 35 mins to fix

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

                    def call(param, settings, path, route, definitions)
            Severity: Minor
            Found in lib/grape-swagger/doc_methods/parse_params.rb - About 35 mins to fix

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

                  def self.output_path_definitions(combi_routes, endpoint, target_class, options)
                    output = endpoint.swagger_object(
                      target_class,
                      endpoint.request,
                      options
              Severity: Minor
              Found in lib/grape-swagger/doc_methods.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 setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def setup(options)
                    options = DEFAULTS.merge(options)
              
                    # options could be set on #add_swagger_documentation call,
                    # for available options see #defaults
              Severity: Minor
              Found in lib/grape-swagger/doc_methods.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 document_array_param has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def document_array_param(value_type, definitions)
                        if value_type[:documentation].present?
                          param_type = value_type[:documentation][:param_type]
                          doc_type = value_type[:documentation][:type]
                          type = DataType.mapping(doc_type) if doc_type && !DataType.request_primitive?(doc_type)
              Severity: Minor
              Found in lib/grape-swagger/doc_methods/parse_params.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