archiloque/sinatra-swagger-exposer

View on GitHub

Showing 35 of 35 total issues

Method create_request_processor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def create_request_processor(swagger_endpoint)
        request_processor = Sinatra::SwaggerExposer::Processing::SwaggerRequestProcessor.new(swagger_endpoint.produces)

        swagger_endpoint.parameters.each do |parameter|
          if TYPE_FILE == parameter.type
Severity: Minor
Found in lib/sinatra/swagger-exposer/swagger-request-processor-creator.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 endpoint_parameter has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def endpoint_parameter(name, description, how_to_pass, required, type, params = {})
Severity: Minor
Found in lib/sinatra/swagger-exposer/swagger-exposer.rb - About 45 mins to fix

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

            def initialize(type, description, known_types, headers, known_headers)
    Severity: Minor
    Found in lib/sinatra/swagger-exposer/configuration/swagger-endpoint-response.rb - About 35 mins to fix

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

              def initialize(name, required, type, default, params)

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

                def validate_numerical_value_internal(value, limit_param_name, exclusive_limit_param_name, limit_param_method, exclusive_limit_param_method)

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

                  def swagger_path(sinatra_path, explicit_path)
                    if explicit_path
                      explicit_path
                    elsif sinatra_path.is_a? String
                      while (m = REGEX_PATH_PARAM_MIDDLE.match(sinatra_path))
          Severity: Minor
          Found in lib/sinatra/swagger-exposer/configuration/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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def initialize(type, description, known_types, headers, known_headers)
                    if type
                      get_type(type, known_types + RESPONSE_PRIMITIVES_FILES)
                    end
          
          
          Severity: Minor
          Found in lib/sinatra/swagger-exposer/configuration/swagger-endpoint-response.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 validate_numerical_value_internal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def validate_numerical_value_internal(value, limit_param_name, exclusive_limit_param_name, limit_param_method, exclusive_limit_param_method)
                    if @params.key? limit_param_name
                      target_value = @params[limit_param_name]
                      method_to_call = @params[exclusive_limit_param_name] ? exclusive_limit_param_method : limit_param_method
                      unless value.send(method_to_call, target_value)

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

                  def to_swagger
                    result = {:type => 'object'}
          
                    unless @properties.empty?
                      result[PROPERTY_PROPERTIES] = hash_to_swagger(@properties)
          Severity: Minor
          Found in lib/sinatra/swagger-exposer/configuration/swagger-type.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

          Avoid too many return statements within this method.
          Open

                        return validate_value_string(value)

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

                    def process_required(type_name, type_content, properties_names)
                      possible_value = check_attribute_empty_or_bad(type_name, type_content, PROPERTY_REQUIRED, Array)
                      if possible_value
                        possible_value
                      else
            Severity: Minor
            Found in lib/sinatra/swagger-exposer/configuration/swagger-type.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 create_processor_for_property has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def create_processor_for_property(name, type_property, required)
                    property_type = type_property.type
                    if property_type == TYPE_ARRAY
                      if PRIMITIVE_TYPES.include? type_property.items
                        processor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValueProcessor.new(
            Severity: Minor
            Found in lib/sinatra/swagger-exposer/swagger-request-processor-creator.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 process_example has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def process_example(type_name, type_content, properties_names)
                      possible_value = check_attribute_empty_or_bad(type_name, type_content, PROPERTY_EXAMPLE, Hash)
                      if possible_value
                        possible_value
                      else
            Severity: Minor
            Found in lib/sinatra/swagger-exposer/configuration/swagger-type.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 process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def process(params)
                      unless params.is_a? Hash
                        raise SwaggerInvalidException.new("Value [#{@name}] should be an object but is a [#{params.class}]")
                      end
                      if params.key?(@name) && (!params[@name].nil?)
            Severity: Minor
            Found in lib/sinatra/swagger-exposer/processing/swagger-base-value-processor.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 create_parameter_value_processor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def create_parameter_value_processor(parameter)
                    type_name = parameter.type
                    if type_name == TYPE_ARRAY
                      if PRIMITIVE_TYPES.include? parameter.items
                        processor_for_values = Sinatra::SwaggerExposer::Processing::SwaggerPrimitiveValueProcessor.new(
            Severity: Minor
            Found in lib/sinatra/swagger-exposer/swagger-request-processor-creator.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