mepatterson/grape_ape_rails

View on GitHub

Showing 17 of 21 total issues

Method setup has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
Open

          def self.setup(options)
            defaults = {
              target_class: nil,
              mount_path: '/swagger_doc',
              mount_with_version: false,
Severity: Minor
Found in lib/swagger/grape_swagger_modified.rb - About 1 day 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 parse_params has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
Open

            def parse_params(params, path, method)
              params ||= []
              params.map do |param, value|
                value[:type] = 'File' if value.is_a?(Hash) && value[:type] == 'Rack::Multipart::UploadedFile'
                items = {}
Severity: Minor
Found in lib/swagger/grape_swagger_modified.rb - About 1 day 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_documentation_class has 348 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create_documentation_class
        Class.new(Grape::API) do
          class << self
            def name
              @@class_name
Severity: Major
Found in lib/swagger/grape_swagger_modified.rb - About 1 day to fix

    File grape_swagger_modified.rb has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'kramdown'
    module Grape
      class API
        class << self
          attr_reader :combined_routes, :combined_namespaces
    Severity: Minor
    Found in lib/swagger/grape_swagger_modified.rb - About 5 hrs to fix

      Method parse_entity_models has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

                  def parse_entity_models(models)
                    result = {}
                    models.each do |model|
                      name       = parse_entity_name(model)
                      properties = {}
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.rb - About 4 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 parse_header_params has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

                  def parse_header_params(params)
                    params ||= []
      
                    params.map do |param, value|
                      data_type     = 'String'
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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_swagger_documentation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_swagger_documentation(options = {})
              documentation_class = create_documentation_class
              documentation_class.setup({ target_class: self }.merge(options))
              mount(documentation_class)
      
      
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 parse_base_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

                  def parse_base_path(base_path, request)
                    if base_path.is_a?(Proc)
                      base_path.call(request)
                    elsif base_path.is_a?(String)
                      URI(base_path).relative? ? URI.join(request.base_url, base_path).to_s : base_path
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 parse_http_codes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

                  def parse_http_codes(codes, models)
                    codes ||= {}
                    codes.map do |k, v, m|
                      models << m if m
                      http_code_hash = {
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 combine_namespaces has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def combine_namespaces(app)
              app.endpoints.each do |endpoint|
                ns = if endpoint.respond_to?(:namespace_stackable)
                       endpoint.namespace_stackable(:namespace).last
                     else
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 parse_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                  def parse_path(path, version)
                    # adapt format to swagger format
                    parsed_path = path.gsub('(.:format)', @@hide_format ? '' : '.{format}')
                    # This is attempting to emulate the behavior of
                    # Rack::Mount::Strexp. We cannot use Strexp directly because
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 content_types_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                  def content_types_for(target_class)
                    content_types = (target_class.settings[:content_types] || {}).values
      
                    if content_types.empty?
                      formats       = [target_class.settings[:format], target_class.settings[:default_format]].compact.uniq
      Severity: Minor
      Found in lib/swagger/grape_swagger_modified.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 layout_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def layout_template
                set_layouts_base unless env['api.tilt.layouts_base']
                ver = env['rack.routing_args'][:route_info].route_version
                layout_path = "#{env['api.tilt.layouts_base']}/#{ver}.json.haml"
                if File.exist?(layout_path)
      Severity: Minor
      Found in lib/grape_ape_rails/handlers/formatters.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 configure_tilt_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def configure_tilt_root
              say "\n\nConfiguring Tilt for RABL templates..."
              say ("-"*80)
      
              if yes?("Will you be using RABL templates? (y/n)")
      Severity: Minor
      Found in lib/generators/grape_ape_rails/setup_generator.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 error! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def error!(message, status = nil, headers = nil)
          if defined?(::Rails) && Rails.respond_to?(:logger)
            api_version = "[#{env['rack.routing_args'][:route_info].route_version}]" rescue nil
            Rails.logger.warn "[API]#{api_version} Responding with #{status} #{message}"
          end
      Severity: Minor
      Found in lib/grape_ape_rails/api.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 self.call(message, backtrace, options, env)
              err = { error: { code: 'ERROR', message: message } }
              if message.is_a?(Hash) && message[:code].present? && message[:message].present?
                full_msg = "[#{message[:code]}] #{message[:message]}"
                err = { error: { code: message[:code], message: full_msg } }
      Severity: Minor
      Found in lib/grape_ape_rails/handlers/formatters.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(object, env)
                @env = env
                @endpoint = env['api.endpoint']
                if rablable?
                  rabl do |template|
      Severity: Minor
      Found in lib/grape_ape_rails/handlers/formatters.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