dvinciguerra/business-br

View on GitHub

Showing 4 of 123 total issues

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

    def validate(cnpj)
      return false unless cnpj
      return false unless cnpj.length == 14 || cnpj.length == 18
      return false unless cnpj =~ %r{^\d{2}\.?\d{3}\.?\d{3}/?\d{4}-?\d{2}$}

Severity: Minor
Found in lib/business-br/cnpj.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 12 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(cpf)
      return false unless cpf
      return false unless cpf.length == 11 || cpf.length == 14
      return false unless cpf =~ /^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/

Severity: Minor
Found in lib/business-br/cpf.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

Avoid too many return statements within this method.
Open

      return false unless cpf[9..10] == "#{first_num}#{second_num}"
Severity: Major
Found in lib/business-br/cpf.rb - About 30 mins to fix

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

        def type(cep)
          cep = normalize(cep)
          suffix = cep.slice(5, 3).to_i
          if suffix < 900 then 'LOGRADOURO'
          elsif suffix < 960 then 'ESPECIAL'
    Severity: Minor
    Found in lib/business-br/cep.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