mtarnovan/romanianvalidators

View on GitHub

Showing 3 of 5 total issues

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

    def enumerator(start, direction = :up)
      Enumerator.new do |yielder|
        memo = direction == :up ? next_valid_cif(start + 1) : prev_valid_cif(start - 1)
        loop do
          yielder << memo
Severity: Minor
Found in lib/romanianvalidators/cif.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_each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def validate_each(record, attribute, value)
          allow_blank = options.fetch(:allow_blank, false)
          allow_nil = options.fetch(:allow_nil, false)
          message = options.fetch(:message, :invalid)
          record.errors.add_on_empty(attribute) && return if value.nil? && !allow_nil
Severity: Minor
Found in lib/romanianvalidators/active_model.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

Method valid_birthdate? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def valid_birthdate?(cnp)
      year_code = cnp[0].chr.to_i
      year =
        case year_code
        when 1..2 then '19'
Severity: Minor
Found in lib/romanianvalidators/cnp.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