ruby-grape/grape-swagger

View on GitHub

Showing 40 of 40 total issues

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

          def public_parameter?(param)
            param_options = param.last
            return true unless param_options.key?(:documentation) && !param_options[:required]
    
            param_hidden = param_options[:documentation].fetch(:hidden, false)
    Severity: Minor
    Found in lib/grape-swagger/endpoint/params_parser.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 combine_namespace_routes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def combine_namespace_routes(namespaces)
        # iterate over each single namespace
        namespaces.each_key do |name, _|
          # get the parent route for the namespace
          parent_route_name = extract_parent_route(name)
    Severity: Minor
    Found in lib/grape-swagger.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 path_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def path_item(routes, options)
          routes.each do |route|
            next if hidden?(route, options)
    
            @item, path = GrapeSwagger::DocMethods::PathString.build(route, options)
    Severity: Minor
    Found in lib/grape-swagger/endpoint.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 move_down has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def move_down(parameter, related_parameters)
              case parameter[:type]
              when 'array'
                add_array(parameter, related_parameters)
                unless related_parameters.blank?
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/format_data.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

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

          def param_type_is_array?(param_type)
            return false unless param_type
            return true if param_type == 'Array'
    
            param_types = param_type.match(/\[(.*)\]$/)
    Severity: Minor
    Found in lib/grape-swagger/endpoint/params_parser.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 combine_namespaces has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def combine_namespaces(app)
        app.endpoints.each do |endpoint|
          ns = endpoint.namespace_stackable(:namespace).last
    
          # use the full namespace here (not the latest level only)
    Severity: Minor
    Found in lib/grape-swagger.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_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

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

        def expose_params(value)
          if value.is_a?(Class) && GrapeSwagger.model_parsers.find(value)
            expose_params_from_model(value)
          elsif value.is_a?(String)
            begin
    Severity: Minor
    Found in lib/grape-swagger/endpoint.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 get_path_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_path_params(stackable_values)
          params = {}
          return param unless stackable_values
          return params unless stackable_values.is_a? Grape::Util::StackableValues
    
    
    Severity: Minor
    Found in lib/grape-swagger/endpoint.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 parse_params_from_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse_params_from_model(parsed_response, model, model_name)
              if parsed_response.is_a?(Hash) && parsed_response.keys.first == :allOf
                refs_or_models = parsed_response[:allOf]
                parsed = parse_refs_and_models(refs_or_models, model)
    
    
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/build_model_definition.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 document_as_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def document_as_array(param)
              {}.tap do |property|
                property[:type] = 'array'
                property[:description] = param.delete(:description) unless param[:description].nil?
                property[:example] = param.delete(:example) unless param[:example].nil?
    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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def add(path, definitions, route)
              @route = route
    
              description = route.settings[:description]
              add_extension_to(path[method], extension(description)) if description && extended?(description, :x)
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/extensions.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 produces_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def produces_object(route, format)
          return ['application/octet-stream'] if file_response?(route.attributes.success) &&
                                                 !route.attributes.produces.present?
    
          mime_types = GrapeSwagger::DocMethods::ProducesConsumes.call(format)
    Severity: Minor
    Found in lib/grape-swagger/endpoint.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 default_code_from_route has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def default_code_from_route(route)
          entity = route.options[:default_response]
          return [] if entity.nil?
    
          default_code = { code: 'default', message: 'Default Response' }
    Severity: Minor
    Found in lib/grape-swagger/endpoint.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 add_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def add_array(parameter, related_parameters)
              related_parameters.each do |p|
                next if p.key?(:items)
    
                p_type = p[:type] == 'array' ? 'string' : p[:type]
    Severity: Minor
    Found in lib/grape-swagger/doc_methods/format_data.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