Apipie/apipie-rails

View on GitHub
lib/apipie/extractor/writer.rb

Summary

Maintainability
D
1 day
Test Coverage

File writer.rb has 378 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'set'

module Apipie
  module Extractor
    class Writer
Severity: Minor
Found in lib/apipie/extractor/writer.rb - About 5 hrs to fix

    Class Writer has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Writer
          class << self
            def compressed
              Apipie.configuration.compress_examples
            end
    Severity: Minor
    Found in lib/apipie/extractor/writer.rb - About 2 hrs to fix

      Method lines_above_method has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def lines_above_method
              added_lines = []
              lines_to_add = []
              block_level = 0
              ensure_line_breaks(controller_content.lines).first(action_line).reverse_each do |line|
      Severity: Minor
      Found in lib/apipie/extractor/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 generate_params_code has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def generate_params_code(params, indent = "")
              code = ""
              params.sort_by {|n,_| n }.each do |(name, desc)|
                desc[:type] = (desc[:type] && desc[:type].first) || Object
                code << "#{indent}param"
      Severity: Minor
      Found in lib/apipie/extractor/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 deep_merge_examples has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def deep_merge_examples(new_examples, old_examples)
              new_examples.map do |new_example|
                # Use ordered to get compareble output (mainly for the :query)
                new_example_ordered = ordered_call(new_example.dup)
      
      
      Severity: Minor
      Found in lib/apipie/extractor/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 ensure_line_breaks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def ensure_line_breaks(lines)
              if lines.to_a.size > 1 && lines.first !~ /\n\Z/
                lines.map { |l| !/\n\Z/.match?(l) ? (l << "\n") : l }.to_enum
              else
                lines
      Severity: Minor
      Found in lib/apipie/extractor/writer.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 merge_old_new_examples has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge_old_new_examples
              new_examples = self.load_new_examples
              old_examples = self.load_recorded_examples
              merged_examples = []
              (new_examples.keys + old_examples.keys).uniq.each do |key|
      Severity: Minor
      Found in lib/apipie/extractor/writer.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 ordered_call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def ordered_call(call)
              call = call.stringify_keys
              ordered_call = OrderedHash.new
              %w[title verb path versions query request_data response_data code show_in_doc recorded].each do |k|
                next unless call.key?(k)
      Severity: Minor
      Found in lib/apipie/extractor/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

      There are no issues that match your filters.

      Category
      Status