Apipie/apipie-rails

View on GitHub

Showing 91 of 91 total issues

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

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

              def to_json(version, resource_id, method_name, lang)
          
                return unless valid_search_args?(version, resource_id, method_name)
          
                _resources = if resource_id.blank?
          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 validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate(value)
                return true if allow_nil && value.nil?
                return true if allow_blank && value.blank?
                value = normalized_value(value)
                if (!allow_nil && value.nil?) || (blank_forbidden? && value.blank?) || !validator.valid?(value)
          Severity: Minor
          Found in lib/apipie/param_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 initialize has 27 lines of code (exceeds 25 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

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

              Function keydown has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                , keydown: function (e) {
                    var $this
                      , $items
                      , $active
                      , $parent
              Severity: Minor
              Found in app/public/apipie/javascripts/bundled/bootstrap.js - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      this.timeout = setTimeout(function() {
                        if (self.hoverState == 'in') self.show()
                      }, self.options.delay.show)
                Severity: Major
                Found in app/public/apipie/javascripts/bundled/bootstrap.js and 1 other location - About 1 hr to fix
                app/public/apipie/javascripts/bundled/bootstrap.js on lines 1158..1160

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 55.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      this.timeout = setTimeout(function() {
                        if (self.hoverState == 'out') self.hide()
                      }, self.options.delay.hide)
                Severity: Major
                Found in app/public/apipie/javascripts/bundled/bootstrap.js and 1 other location - About 1 hr to fix
                app/public/apipie/javascripts/bundled/bootstrap.js on lines 1146..1148

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 55.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method action_awareness has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def action_awareness
                      if action_aware?
                        if !@options.key?(:allow_nil)
                          if @required
                            @allow_nil = false
                Severity: Minor
                Found in lib/apipie/param_description.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def initialize(args)
                      if args.first.is_a? Hash
                        args = args.first
                      elsif args.count == 2
                        if args.last.is_a? Hash
                Severity: Minor
                Found in lib/apipie/see_description.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 get_format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_format
                      [:resource, :method, :version].each do |par|
                        next unless params[par]
                        [:html, :json].each do |format|
                          extension = ".#{format}"
                Severity: Minor
                Found in app/controllers/apipie/apipies_controller.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
                Severity: Minor
                Found in lib/apipie/param_description.rb - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language