ruby-grape/grape-swagger

View on GitHub
lib/grape-swagger/doc_methods/parse_params.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method parse_array_item has a Cognitive Complexity of 11 (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 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 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_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 parse_additional_properties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def parse_additional_properties(definitions, settings)
          return false unless settings.key?(:additionalProperties) || settings.key?(:additional_properties)

          value =
            if settings.key?(:additionalProperties)
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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def call(param, settings, path, route, definitions)
          method = route.request_method
          additional_documentation = settings.fetch(:documentation, {})
          settings.merge!(additional_documentation)
          data_type = DataType.call(settings)
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 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 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

    There are no issues that match your filters.

    Category
    Status