Apipie/apipie-rails

View on GitHub

Showing 68 of 91 total issues

File bootstrap.js has 1517 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* ===================================================
 * bootstrap-transition.js v2.3.2
 * http://getbootstrap.com/2.3.2/javascript.html#transitions
 * ===================================================
 * Copyright 2013 Twitter, Inc.
Severity: Major
Found in app/public/apipie/javascripts/bundled/bootstrap.js - About 4 days to fix

    Method _apipie_define_validators has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

          def _apipie_define_validators(description)
    
            # [re]define method only if validation is turned on
            if description && (Apipie.configuration.validate == true ||
                               Apipie.configuration.validate == :implicitly ||
    Severity: Minor
    Found in lib/apipie/dsl_definition.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 index has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        def index
          params[:version] ||= Apipie.configuration.default_version
    
          get_format
    
    
    Severity: Minor
    Found in app/controllers/apipie/apipies_controller.rb - About 6 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

    File validator.rb has 429 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Apipie
    
      module Validator
    
        # to create new validator, inherit from Apipie::Validator::BaseValidator
    Severity: Minor
    Found in lib/apipie/validator.rb - About 6 hrs to fix

      Class Application has 44 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Application
          # we need engine just for serving static assets
          class Engine < Rails::Engine
            initializer "static assets", :before => :build_middleware_stack do |app|
              app.middleware.use ::Apipie::StaticDispatcher, "#{root}/app/public"
      Severity: Minor
      Found in lib/apipie/application.rb - About 6 hrs to fix

        File dsl_definition.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Apipie
        
          # DSL is a module that provides #api, #error, #param, #returns.
          module DSL
        
        
        Severity: Minor
        Found in lib/apipie/dsl_definition.rb - About 5 hrs to fix

          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

            File application.rb has 359 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'apipie/static_dispatcher'
            require 'apipie/routes_formatter'
            require 'yaml'
            require 'digest/sha1'
            require 'json'
            Severity: Minor
            Found in lib/apipie/application.rb - About 4 hrs to fix

              Method refine_params_description has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                    def refine_params_description(params_desc, recorded_params)
                      recorded_params.each do |key, value|
                        params_desc[key] ||= {}
                        param_desc = params_desc[key]
              
              
              Severity: Minor
              Found in lib/apipie/extractor/collector.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 to_swagger has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                def to_swagger
                  return if @param_descriptions.blank?
              
                  @param_descriptions.each do |param_description|
                    validate(param_description)
              Severity: Minor
              Found in lib/apipie/generator/swagger/param_description/composite.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 initialize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
              
                    if desc_or_options.is_a?(Hash)
                      options = options.merge(desc_or_options)
                    elsif desc_or_options.is_a?(String)
              Severity: Minor
              Found in lib/apipie/param_description.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 returns has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                    def returns(pgroup_or_options, desc_or_options = nil, options = {}, &block) #:doc:
                      return unless Apipie.active_dsl?
              
              
                      if desc_or_options.is_a? Hash
              Severity: Minor
              Found in lib/apipie/dsl_definition.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

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

                class MethodDescription
                  attr_reader :full_description, :method, :resource, :apis, :examples, :see, :formats, :headers, :show
                  attr_accessor :metadata
              
                  def initialize(method, resource, dsl_data)
              Severity: Minor
              Found in lib/apipie/method_description.rb - About 2 hrs to fix

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

                  class ParamDescription
                
                    attr_reader :method_description, :name, :desc, :allow_nil, :allow_blank, :validator, :options, :metadata, :show, :as, :validations, :response_only, :request_only
                    attr_reader :additional_properties, :is_array
                    attr_accessor :parent, :required
                Severity: Minor
                Found in lib/apipie/param_description.rb - About 2 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 index has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def index
                          params[:version] ||= Apipie.configuration.default_version
                    
                          get_format
                    
                    
                    Severity: Major
                    Found in app/controllers/apipie/apipies_controller.rb - About 2 hrs to fix

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

                        def to_swagger
                          return if @param_descriptions.blank?
                      
                          @param_descriptions.each do |param_description|
                            validate(param_description)
                      Severity: Major
                      Found in lib/apipie/generator/swagger/param_description/composite.rb - About 2 hrs to fix

                        Method validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def validate(value)
                                return false if !value.is_a? Hash
                        
                                BaseValidator.raise_if_missing_params do |missing|
                                  @hash_params&.each do |k, p|
                        Severity: Minor
                        Found in lib/apipie/validator.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 get_resource_description has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_resource_description(resource, version = nil)
                              if resource.is_a?(String)
                                crumbs = resource.split('#')
                                if crumbs.size == 2
                                  version = crumbs.first
                        Severity: Minor
                        Found in lib/apipie/application.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 initialize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
                        
                              if desc_or_options.is_a?(Hash)
                                options = options.merge(desc_or_options)
                              elsif desc_or_options.is_a?(String)
                        Severity: Minor
                        Found in lib/apipie/param_description.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language