Apipie/apipie-rails

View on GitHub

Showing 91 of 91 total issues

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

              Function slide has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                , slide: function (type, next) {
                    var $active = this.$element.find('.item.active')
                      , $next = next || $active[type]()
                      , isCycling = this.interval
                      , direction = type == 'next' ? 'left' : 'right'
              Severity: Minor
              Found in app/public/apipie/javascripts/bundled/bootstrap.js - About 1 hr 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 initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def initialize(method_description, code, options, scope, block, adapter)
                
                      @type_ref = options[:param_group]
                      @is_array_of = options[:array_of] || false
                      raise ReturnsMultipleDefinitionError, options if @is_array_of && @type_ref
                Severity: Minor
                Found in lib/apipie/response_description.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

                Function show has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  , show: function () {
                      var $tip
                        , pos
                        , actualWidth
                        , actualHeight
                Severity: Minor
                Found in app/public/apipie/javascripts/bundled/bootstrap.js - About 1 hr to fix

                  Method _apipie_define_validators has 41 lines of code (exceeds 25 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 hr to fix

                    Method get_resource_id has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_resource_id(klass)
                          if klass.class == String
                            klass
                          elsif @controller_to_resource_id.key?(klass)
                            @controller_to_resource_id[klass]
                    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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(code_or_options, desc = nil, options = {})
                          if code_or_options.is_a? Hash
                            code_or_options.symbolize_keys!
                            @code = code_or_options[:code]
                            @metadata = code_or_options[:meta]
                    Severity: Minor
                    Found in lib/apipie/error_description.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 valid_search_args? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def valid_search_args?(version, resource_id, method_name)
                          return false unless self.resource_descriptions.key?(version)
                          if resource_id
                            return false unless self.resource_descriptions[version].key?(resource_id)
                            if method_name
                    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 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 body_params_schema has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def body_params_schema
                        if params_in_body? && body_allowed_for_current_method?
                          composite = Apipie::Generator::Swagger::ParamDescription::Composite.new(
                            body_param_descriptions,
                            Apipie::Generator::Swagger::Context.new(

                      Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def initialize
                            @markup = Apipie::Markup::RDoc.new
                            @app_name = "Another API"
                            @app_info = ActiveSupport::HashWithIndifferentAccess.new
                            @copyright = nil
                      Severity: Minor
                      Found in lib/apipie/configuration.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language