Showing 14 of 14 total issues

Method stop has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

      def stop(_notification = nil)
        @config.swagger_docs.each do |url_path, doc|
          unless doc_version(doc).start_with?('2')
            doc[:paths]&.each_pair do |_k, v|
              v.each_pair do |_verb, value|
Severity: Minor
Found in rswag-specs/lib/rswag/specs/swagger_formatter.rb - About 5 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 add_headers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_headers(request, metadata, swagger_doc, parameters, example)
        tuples = parameters
          .select { |p| p[:in] == :header }
          .map { |p| [p[:name], example.send(p[:name]).to_s] }

Severity: Minor
Found in rswag-specs/lib/rswag/specs/request_factory.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 stop has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def stop(_notification = nil)
        @config.swagger_docs.each do |url_path, doc|
          unless doc_version(doc).start_with?('2')
            doc[:paths]&.each_pair do |_k, v|
              v.each_pair do |_verb, value|
Severity: Minor
Found in rswag-specs/lib/rswag/specs/swagger_formatter.rb - About 1 hr to fix

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

          def upgrade_oauth!(swagger_doc)
            # find flow in securitySchemes (securityDefinitions will have been re-written)
            schemes = swagger_doc.dig(:components, :securitySchemes)
            return unless schemes&.any? { |_k, v| v.key?(:flow) }
    
    
    Severity: Minor
    Found in rswag-specs/lib/rswag/specs/swagger_formatter.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 validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def self.validate(current_schema, data, fragments, processor, validator, options = {})
    Severity: Minor
    Found in rswag-specs/lib/rswag/specs/extended_schema.rb - About 45 mins to fix

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

            def expand_parameters(metadata, swagger_doc, example)
              operation_params = metadata[:operation][:parameters] || []
              path_item_params = metadata[:path_item][:parameters] || []
              security_params = derive_security_params(metadata, swagger_doc)
      
      
      Severity: Minor
      Found in rswag-specs/lib/rswag/specs/request_factory.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 run_test! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def run_test!(&block)
              # NOTE: rspec 2.x support
              if RSPEC_VERSION < 3
                before do
                  submit_request(example.metadata)
      Severity: Minor
      Found in rswag-specs/lib/rswag/specs/example_group_helpers.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

      Consider simplifying this complex logical expression.
      Open

                      if is_hash && value.dig(:parameters)
                        schema_param = value.dig(:parameters)&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
                        mime_list = value.dig(:consumes) || doc[:consumes]
                        if value && schema_param && mime_list
                          value[:requestBody] = { content: {} } unless value.dig(:requestBody, :content)
      Severity: Major
      Found in rswag-specs/lib/rswag/specs/swagger_formatter.rb - About 40 mins to fix

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

              def add_path(request, metadata, swagger_doc, parameters, example)
        Severity: Minor
        Found in rswag-specs/lib/rswag/specs/request_factory.rb - About 35 mins to fix

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

                def add_headers(request, metadata, swagger_doc, parameters, example)
          Severity: Minor
          Found in rswag-specs/lib/rswag/specs/request_factory.rb - About 35 mins to fix

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

                  def example_group_finished(notification)
                    # NOTE: rspec 2.x support
                    metadata = if RSPEC_VERSION > 2
                      notification.group.metadata
                    else
            Severity: Minor
            Found in rswag-specs/lib/rswag/specs/swagger_formatter.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 parameter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parameter(attributes)
                    if attributes[:in] && attributes[:in].to_sym == :path
                      attributes[:required] = true
                    end
            
            
            Severity: Minor
            Found in rswag-specs/lib/rswag/specs/example_group_helpers.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 security_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def security_version(scheme_names, swagger_doc)
                    if doc_version(swagger_doc).start_with?('2')
                      (swagger_doc[:securityDefinitions] || {}).slice(*scheme_names).values
                    else # Openapi3
                      if swagger_doc.key?(:securityDefinitions)
            Severity: Minor
            Found in rswag-specs/lib/rswag/specs/request_factory.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call(env)
                    path = env['PATH_INFO']
                    filename = "#{@config.resolve_swagger_root(env)}/#{path}"
            
                    if env['REQUEST_METHOD'] == 'GET' && File.file?(filename)
            Severity: Minor
            Found in rswag-api/lib/rswag/api/middleware.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