zipmark/rspec_api_documentation

View on GitHub

Showing 19 of 25 total issues

Method initialize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(opts = {})
        return unless opts

        opts.each do |name, value|
          if name.to_s == 'hide'
Severity: Minor
Found in lib/rspec_api_documentation/open_api/node.rb - About 3 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 extract_schema has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_schema(fields)
        schema = {type: 'object', properties: {}}

        fields.each do |field|
          current = schema
Severity: Minor
Found in lib/rspec_api_documentation/writers/open_api_writer.rb - About 3 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 as_json has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def as_json
        existing_settings.inject({}) do |hash, name|
          value = setting(name)
          case
          when value.is_a?(Node)
Severity: Minor
Found in lib/rspec_api_documentation/open_api/node.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 fields has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def fields(property_name, examples)
        examples
          .map { |example| example.metadata[property_name] }
          .flatten
          .compact
Severity: Minor
Found in lib/rspec_api_documentation/views/api_blueprint_index.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 add_setting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def add_setting(name, opts = {})
        return false if setting_exist?(name)

        instance_settings << name

Severity: Minor
Found in lib/rspec_api_documentation/open_api/node.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 do_request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def do_request(extra_params = {})
      @extra_params = extra_params

      params_or_body = nil
      path_or_query = path
Severity: Minor
Found in lib/rspec_api_documentation/dsl/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 add_paths! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def add_paths!
        specs.safe_assign_setting(:paths, OpenApi::Paths.new)
        examples.each do |example|
          specs.paths.add_setting example.route, :value => OpenApi::Path.new

Severity: Minor
Found in lib/rspec_api_documentation/writers/open_api_writer.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 extended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def extended
          example.metadata.fetch(:parameters, {}).map do |param|
            p = Marshal.load(Marshal.dump(param))
            p[:value] = SetParam.new(self, nil, p).value
            unless p[:value]
Severity: Minor
Found in lib/rspec_api_documentation/dsl/endpoint/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 add_setting has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def self.add_setting(name, opts = {})
        class_settings << name

        define_method("#{name}_schema") { opts[:schema] || NilClass }
        define_method("#{name}=") { |value| settings[name] = value }
Severity: Minor
Found in lib/rspec_api_documentation/open_api/node.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 process_responses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def process_responses(responses, example)
        schema = extract_schema(example.respond_to?(:response_fields) ? example.response_fields : [])
        example.requests.each do |request|
          response = OpenApi::Response.new(
            description: example.description,
Severity: Minor
Found in lib/rspec_api_documentation/writers/open_api_writer.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 clean_out_uploaded_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_out_uploaded_data(params, request_body)
      params.each do |value|
        if [Hash, Array].member? value.class
          request_body = if value.respond_to?(:has_key?) && value.has_key?(:tempfile)
                           data = value[:tempfile].read
Severity: Minor
Found in lib/rspec_api_documentation/client_base.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 headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def headers
      return unless example.metadata[:headers]
      example.metadata[:headers].inject({}) do |hash, (header, value)|
        if value.is_a?(Symbol)
          hash[header] = send(value) if respond_to?(value)
Severity: Minor
Found in lib/rspec_api_documentation/dsl/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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def write
        index.examples.each do |rspec_example|
          example = CombinedTextExample.new(rspec_example)
          FileUtils.mkdir_p(configuration.docs_dir.join(example.resource_name))
          File.open(configuration.docs_dir.join(example.resource_name, "index.txt"), "a+") do |f|
Severity: Minor
Found in lib/rspec_api_documentation/writers/combined_text_writer.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 method_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def method_name
          if custom_method_name
            custom_method_name if example_group.respond_to?(custom_method_name)
          elsif scoped_key && example_group.respond_to?(scoped_key)
            scoped_key
Severity: Minor
Found in lib/rspec_api_documentation/dsl/endpoint/set_param.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_example has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def document_example(method, path)
      return unless metadata[:document]

      request_body = read_request_body

Severity: Minor
Found in lib/rspec_api_documentation/client_base.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 requests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def requests
        super.map do |hash|
          if @host
            if hash[:curl].is_a? RspecApiDocumentation::Curl
              hash[:curl] = hash[:curl].output(@host, @filter_headers)
Severity: Minor
Found in lib/rspec_api_documentation/writers/json_writer.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 remap_headers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def remap_headers(requests, key, headers_to_include)
      return requests unless headers_to_include
      requests.each.with_index do |request_hash, index|
        next unless request_hash.key?(key)
        headers = request_hash[key]
Severity: Minor
Found in lib/rspec_api_documentation/example.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 extract_items has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_items(value, opts = {})
        result = {type: extract_type(value)}
        if result[:type] == :array
          result[:items] = extract_items(value[0], opts)
        else
Severity: Minor
Found in lib/rspec_api_documentation/open_api/helper.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 requests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def requests
        super.map do |hash|
          hash[:request_headers_text] = format_hash(hash[:request_headers])
          hash[:request_query_parameters_text] = format_hash(hash[:request_query_parameters])
          hash[:response_headers_text] = format_hash(hash[:response_headers])
Severity: Minor
Found in lib/rspec_api_documentation/views/markup_example.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