ruby-grape/grape-swagger

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

Summary

Maintainability
B
5 hrs
Test Coverage

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 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 document_as_property has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def document_as_property(param)
              property_keys.each_with_object({}) do |x, memo|
                value = param[x]
                next if value.blank?
    
    
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/move_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

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

            def build_properties(params)
              properties = {}
              required = []
    
              params.each do |param|
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/move_params.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 unify! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def unify!(params)
              params.each { |x| x[:in] = x.delete(:param_type) if x[:param_type] }
              params.each { |x| x[:in] = 'body' if x[:in] == 'formData' } if includes_body_param?(params)
            end
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/move_params.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