tim-vandecasteele/grape-swagger

View on GitHub

Showing 28 of 28 total issues

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

    class MoveParams
      class << self
        attr_accessor :definitions

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

    Class Endpoint has 27 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 3 hrs to fix

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

          def response_object(route, markdown)
            codes = (route.http_codes || route.options[:failure] || [])
      
            codes = apply_success_codes(route) + codes
            codes.map! { |x| x.is_a?(Array) ? { code: x[0], message: x[1], model: x[2] } : x }
      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

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

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

        Method combine_routes has a Cognitive Complexity of 17 (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.to_s}/).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 combine_namespace_routes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def combine_namespace_routes(namespaces)
                # iterate over each single namespace
                namespaces.each do |name, namespace|
                  # get the parent route for the namespace
                  parent_route_name = extract_parent_route(name)
        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 setup has a Cognitive Complexity of 16 (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 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 document_array_param has a Cognitive Complexity of 13 (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 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 39 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 parse_request_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_request_params(params)
                array_key = nil
                params.select { |param| public_parameter?(param) }.each_with_object({}) do |param, memo|
                  name, options = *param
                  param_type = options[:type]
          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 combine_namespace_routes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def combine_namespace_routes(namespaces)
                  # iterate over each single namespace
                  namespaces.each do |name, namespace|
                    # get the parent route for the namespace
                    parent_route_name = extract_parent_route(name)
          Severity: Minor
          Found in lib/grape-swagger.rb - About 1 hr to fix

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

                  def standalone_sub_namespaces(name, namespaces)
                    # assign all nested namespace routes to this resource, too
                    # (unless they are assigned to another standalone namespace themselves)
                    sub_namespaces = {}
                    # fetch all namespaces that are children of the current namespace
            Severity: Minor
            Found in lib/grape-swagger.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_enum_or_range_values has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def parse_enum_or_range_values(values)
                      case values
                      when Range
                        parse_range_values(values) if values.first.is_a?(Integer)
                      when Proc
            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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

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

                def partition_params(route)
                  declared_params = route.settings[:declared_params] if route.settings[:declared_params].present?
                  required, exposed = route.params.partition { |x| x.first.is_a? String }
                  required = GrapeSwagger::DocMethods::Headers.parse(route) + required unless route.headers.nil?
            
            
            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 prepare_nested_types has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def prepare_nested_types(params)
                      params.each do |param|
                        next unless param[:items]
                        param[:type] = param[:items][:type] == 'array' ? 'string' : param[:items][:type]
                        param[:format] = param[:items][:format] if param[:items][:format]
            Severity: Minor
            Found in lib/grape-swagger/doc_methods/move_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 apply_success_codes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def apply_success_codes(route)
                  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 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 combine_namespaces has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def combine_namespaces(app)
                    app.endpoints.each do |endpoint|
                      ns = if endpoint.respond_to?(:namespace_stackable)
                             endpoint.namespace_stackable(:namespace).last
                           else
            Severity: Minor
            Found in lib/grape-swagger.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 params_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def params_object(route)
                  parameters = partition_params(route).map do |param, value|
                    value = { required: false }.merge(value) if value.is_a?(Hash)
                    _, value = default_type([[param, value]]).first if value == ''
                    if value[:type]
            Severity: Minor
            Found in lib/grape-swagger/endpoint.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 expose_params_from_model has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def expose_params_from_model(model)
                  model = model.is_a?(String) ? model.constantize : model
                  model_name = model_name(model)
            
                  return model_name if @definitions.key?(model_name)
            Severity: Minor
            Found in lib/grape-swagger/endpoint.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

            Severity
            Category
            Status
            Source
            Language