Apipie/apipie-rails

View on GitHub
lib/apipie/param_description.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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

    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

      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 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 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 is_required? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def is_required?
              if @options.key?(:required)
                if (@options[:required] == true) || (@options[:required] == false)
                  @options[:required]
                else
        Severity: Minor
        Found in lib/apipie/param_description.rb - About 25 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

        There are no issues that match your filters.

        Category
        Status