Apipie/apipie-rails

View on GitHub

Showing 68 of 91 total issues

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

            Method to_swagger has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_swagger
                @param_descriptions.each do |desc|
                  context = @context.dup
            
                  type = Apipie::Generator::Swagger::TypeExtractor.new(desc.validator).extract

            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

            Function applyPlacement has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              , applyPlacement: function(offset, placement){
                  var $tip = this.tip()
                    , width = $tip[0].offsetWidth
                    , height = $tip[0].offsetHeight
                    , actualWidth
            Severity: Minor
            Found in app/public/apipie/javascripts/bundled/bootstrap.js - About 1 hr to fix

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

                def to_swagger
                  @param_descriptions.each do |desc|
                    context = @context.dup
              
                    type = Apipie::Generator::Swagger::TypeExtractor.new(desc.validator).extract

                Method returns has 30 lines of code (exceeds 25 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 1 hr to fix

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

                      def initialize(method, resource, dsl_data)
                        @method = method.to_s
                        @resource = resource
                        @from_concern = dsl_data[:from_concern]
                        @apis = ApisService.new(resource, method, dsl_data).call
                  Severity: Minor
                  Found in lib/apipie/method_description.rb - About 1 hr to fix

                    Method populate_api_routes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def populate_api_routes
                            @apis_from_routes = Hash.new { |h, k| h[k] = [] }
                    
                            all_api_routes.each do |route|
                              controller_path, action = route[:controller], route[:action]
                    Severity: Minor
                    Found in lib/apipie/extractor.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 rails_routes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def rails_routes(route_set = nil, base_url = "")
                          return @_rails_routes if route_set.nil? && @_rails_routes
                    
                          route_set ||= Rails.application.routes
                          # ensure routes are loaded
                    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 get_language has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_language
                          return nil unless Apipie.configuration.translate
                          lang = Apipie.configuration.default_locale
                          [:resource, :method, :version].each do |par|
                            next unless params[par]
                    Severity: Minor
                    Found in app/controllers/apipie/apipies_controller.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

                    Severity
                    Category
                    Status
                    Source
                    Language