Apipie/apipie-rails

View on GitHub

Showing 68 of 91 total issues

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

        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

          Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(method_description, code, options, scope, block, adapter)
          Severity: Minor
          Found in lib/apipie/response_description.rb - About 45 mins to fix

            Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(controller_name, method_name, response_code, error_messages, schema, returned_object)
            Severity: Minor
            Found in lib/apipie/errors.rb - About 45 mins to fix

              Method reformat_multipart_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def reformat_multipart_data(form)
                      form.empty? and return ''
                      lines = ["Content-Type: multipart/form-data; boundary=#{MULTIPART_BOUNDARY}",'']
                      boundary = "--#{MULTIPART_BOUNDARY}"
                      form.each do |key, attrs|
              Severity: Minor
              Found in lib/apipie/extractor/recorder.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 body_params_schema has a Cognitive Complexity of 8 (exceeds 5 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(
              Severity: Minor
              Found in lib/apipie/generator/swagger/method_description/parameters_service.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 property has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def property(param_name, validator, desc_or_options = nil, options = {}, &block) #:doc:
              Severity: Minor
              Found in lib/apipie/dsl_definition.rb - About 35 mins to fix

                Method to_swagger_json has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def to_swagger_json(version, resource_id, method_name, language, clear_warnings = false)
                Severity: Minor
                Found in lib/apipie/application.rb - About 35 mins to fix

                  Method param has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def param(param_name, validator, desc_or_options = nil, options = {}, &block) #:doc:
                  Severity: Minor
                  Found in lib/apipie/dsl_definition.rb - About 35 mins to fix

                    Method json_schema_for_method_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def json_schema_for_method_response(version, controller_name, method_name, return_code, allow_nulls)
                    Severity: Minor
                    Found in lib/apipie/application.rb - About 35 mins to fix

                      Method to_swagger_json has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def self.to_swagger_json(version = nil, resource_id = nil, method_name = nil, lang = nil, clear_warnings = true)
                      Severity: Minor
                      Found in lib/apipie/apipie_module.rb - About 35 mins to fix

                        Method ensure_line_breaks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def ensure_line_breaks(lines)
                                if lines.to_a.size > 1 && lines.first !~ /\n\Z/
                                  lines.map { |l| !/\n\Z/.match?(l) ? (l << "\n") : l }.to_enum
                                else
                                  lines
                        Severity: Minor
                        Found in lib/apipie/extractor/writer.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 merge_old_new_examples has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def merge_old_new_examples
                                new_examples = self.load_new_examples
                                old_examples = self.load_recorded_examples
                                merged_examples = []
                                (new_examples.keys + old_examples.keys).uniq.each do |key|
                        Severity: Minor
                        Found in lib/apipie/extractor/writer.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

                        Severity
                        Category
                        Status
                        Source
                        Language