zhandao/zero-params_processor

View on GitHub

Showing 6 of 8 total issues

Method if_is_in_range has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def if_is_in_range
        rg = @doc.range
        fmt = @doc.format.tr('-', '_').camelize.constantize if @doc.format&.match?('date')
        min = fmt ? parse_time!(fmt, rg[:min] || '1-1-1') : rg[:min]
        max = fmt ? parse_time!(fmt, rg[:max] || '9999-12-31') : rg[:max]
Severity: Minor
Found in lib/params_processor/validate.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 convert has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def convert
      return if blank?
      self.each do |_api, api_doc|
        @api_components = api_doc[:components]
        api_doc[:paths].each do |_path, path_doc|
Severity: Minor
Found in lib/params_processor/doc_converter.rb - About 1 hr to fix

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

      def process_params_by(*actions)
        return if params_doc.blank?
        pdocs = params_doc.map do |doc|
          param_doc = ParamDoc.new(doc) # TODO: performance
          _validate_param!(param_doc)  if actions.index(:validate!)
    Severity: Minor
    Found in lib/params_processor.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 check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def check msg
            return unless msg.is_a? Array
            @error_class.params_error! if @error_class.respond_to? :params_error
            @error_class.send("#{@doc.name}_#{msg.first}!") if @error_class.respond_to? "#{@doc.name}_#{msg.first}!"
            @error_class.send("#{msg.first}!") if @error_class.respond_to? msg.first
    Severity: Minor
    Found in lib/params_processor/validate.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 _string_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def _string_type
            # return false unless @input.is_a? String
            case @doc.format
            when 'date'      then parse_time!(Date)
            when 'date-time' then parse_time!(DateTime)
    Severity: Minor
    Found in lib/params_processor/validate.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 type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def type
            case @doc.type
            when 'integer' then @str_input.match?(/^-?\d*$/)
            when 'boolean' then @str_input.in? %w[ true 1 false 0 ]
            when 'array'   then @input.is_a?(Array) || (@input.is_a?(String) && @input['['])
    Severity: Minor
    Found in lib/params_processor/validate.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

    Severity
    Category
    Status
    Source
    Language