archiloque/sinatra-swagger-exposer

View on GitHub

Showing 35 of 35 total issues

Method route has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def route(verb, path, options = {}, &block)
      no_swagger = options[:no_swagger]
      options.delete(:no_swagger)
      if (verb == 'HEAD') || no_swagger
        super(verb, path, options, &block)
Severity: Minor
Found in lib/sinatra/swagger-exposer/swagger-exposer.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 process has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def process(current_hash, current_field_name, current_fields, top_level_hash)
          result = {}

          current_hash.each_pair do |current_key, current_value|
            key_sym = current_key.to_sym
Severity: Minor
Found in lib/sinatra/swagger-exposer/configuration/swagger-info.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 to_swagger has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def to_swagger
          result = {}

          if @type
            if @type == TYPE_ARRAY

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 16 (exceeds 5 allowed). Consider refactoring.
Open

        def to_swagger
          result = {
            :name => @name,
            :in => @how_to_pass,
            :required => @required

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

        def run(app, block_params, &block)
          parsed_body = {}
          if JSON_CONTENT_TYPE.like?(app.env['CONTENT_TYPE'])
            body = app.request.body.read
            unless body.empty?
Severity: Minor
Found in lib/sinatra/swagger-exposer/processing/swagger-request-processor.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 to_swagger has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def to_swagger
          result = @other_properties.clone

          if @type
            if @type == TYPE_ARRAY
Severity: Minor
Found in lib/sinatra/swagger-exposer/configuration/swagger-type-property.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 route has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def route(verb, path, options = {}, &block)
      no_swagger = options[:no_swagger]
      options.delete(:no_swagger)
      if (verb == 'HEAD') || no_swagger
        super(verb, path, options, &block)
Severity: Minor
Found in lib/sinatra/swagger-exposer/swagger-exposer.rb - About 1 hr to fix

    Method validate_limit_parameter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def validate_limit_parameter(type, params, limit_param_name, exclusive_limit_param_name)
              parameter_value = nil
              if params.key? limit_param_name
                unless [TYPE_INTEGER, TYPE_NUMBER].include? @type
                  raise SwaggerInvalidException.new("Parameter #{limit_param_name} can only be specified for types #{TYPE_INTEGER} or #{TYPE_NUMBER} and not for [#{@type}]")

    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 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def to_swagger
              result = {}
    
              if @type
                if @type == TYPE_ARRAY

      Method to_swagger has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def to_swagger
                result = {
                  :name => @name,
                  :in => @how_to_pass,
                  :required => @required

        Method create_request_processor has 30 lines of code (exceeds 25 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 1 hr to fix

          Method create_parameter_value_processor has 29 lines of code (exceeds 25 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 1 hr to fix

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

                    def initialize(type, sinatra_path, parameters, responses, summary, description, tags, explicit_path, produces)
            Severity: Major
            Found in lib/sinatra/swagger-exposer/configuration/swagger-endpoint.rb - About 1 hr to fix

              Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def run(app, block_params, &block)
                        parsed_body = {}
                        if JSON_CONTENT_TYPE.like?(app.env['CONTENT_TYPE'])
                          body = app.request.body.read
                          unless body.empty?
              Severity: Minor
              Found in lib/sinatra/swagger-exposer/processing/swagger-request-processor.rb - About 1 hr to fix

                Method process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def process(current_hash, current_field_name, current_fields, top_level_hash)
                          result = {}
                
                          current_hash.each_pair do |current_key, current_value|
                            key_sym = current_key.to_sym
                Severity: Minor
                Found in lib/sinatra/swagger-exposer/configuration/swagger-info.rb - About 1 hr to fix

                  Method to_swagger has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def to_swagger
                          result = {
                            swagger: '2.0',
                            consumes: ['application/json'],
                            produces: ['application/json'],
                  Severity: Minor
                  Found in lib/sinatra/swagger-exposer/swagger-content-creator.rb - About 1 hr to fix

                    Method validate_response_content_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def validate_response_content_type(content_type, response_status)
                              if content_type.nil? && (response_status == 204)
                                # No content and no content type => everything is OK
                              elsif @produces
                                # if there is no content type Sinatra will default to html so we simulate it here
                    Severity: Minor
                    Found in lib/sinatra/swagger-exposer/processing/swagger-request-processor.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 validate_length_parameter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def validate_length_parameter(type, params, length_param_name)
                              if params.key? length_param_name
                                if type == TYPE_STRING
                                  parameter_value = params[length_param_name]
                                  unless parameter_value.is_a? Integer

                    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 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def initialize(name, description, how_to_pass, required, type, params, known_types)
                              check_name(name)
                              @name = name
                    
                              if description
                    Severity: Minor
                    Found in lib/sinatra/swagger-exposer/configuration/swagger-endpoint-parameter.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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def initialize(name, description, how_to_pass, required, type, params, known_types)
                    Severity: Major
                    Found in lib/sinatra/swagger-exposer/configuration/swagger-endpoint-parameter.rb - About 50 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language