tapajos/brazilian-rails

View on GitHub

Showing 11 of 16 total issues

Method por_extenso has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def Extenso.por_extenso(numero)
    negativo=(numero<0)? "menos " : ""
    n=numero.to_i.abs
    return case n
    when 0..9 then negativo + @@unidade[n].to_s
Severity: Minor
Found in brnumeros/lib/brnumeros/number_portuguese.rb - About 6 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 Dinheiro has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

class Dinheiro
  include Comparable

  attr_reader :quantia

Severity: Minor
Found in brdinheiro/lib/brdinheiro/dinheiro.rb - About 4 hrs to fix

    Method por_extenso_em_reais has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def ExtensoReal.por_extenso_em_reais(valor)
        negativo=(valor<0)? " negativo" : ""
        negativos=(valor<0)? " negativos" : ""
        valor = valor.abs
        return 'grátis' if valor == 0
    Severity: Minor
    Found in brnumeros/lib/brnumeros/number_portuguese.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

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

      def self.parser(diretorio)
        files = []
        feriados = []
        metodos = []
        raise FeriadoParserDiretorioInvalidoError unless File.directory?(diretorio)
    Severity: Minor
    Found in brdata/lib/brdata/feriado_parser.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 por_extenso has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def Extenso.por_extenso(numero)
        negativo=(numero<0)? "menos " : ""
        n=numero.to_i.abs
        return case n
        when 0..9 then negativo + @@unidade[n].to_s
    Severity: Minor
    Found in brnumeros/lib/brnumeros/number_portuguese.rb - About 1 hr to fix

      Method distance_of_time_in_words has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
          from_time = from_time.to_time if from_time.respond_to?(:to_time)
          to_time = to_time.to_time if to_time.respond_to?(:to_time)
          distance_in_minutes = (((to_time - from_time).abs)/60).round
          distance_in_seconds = ((to_time - from_time).abs).round
      Severity: Minor
      Found in brdata/lib/brdata/br_date_helper.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 por_extenso_em_reais has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def ExtensoReal.por_extenso_em_reais(valor)
          negativo=(valor<0)? " negativo" : ""
          negativos=(valor<0)? " negativos" : ""
          valor = valor.abs
          return 'grátis' if valor == 0
      Severity: Minor
      Found in brnumeros/lib/brnumeros/number_portuguese.rb - About 1 hr to fix

        Method usar_como_dinheiro has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def usar_como_dinheiro(*args)#:nodoc:
              unless args.size.zero?
                args.each do |name|
                  composed_of name, :class_name => 'Dinheiro', :mapping => [name.to_s, "valor_decimal"], :allow_nil => true
        
        
        Severity: Minor
        Found in brdinheiro/lib/brdinheiro/dinheiro_active_record.rb - About 1 hr to fix

          Method cep has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.cep(numero)
              cep = numero.to_s.gsub(/[\.-]/, '')
              raise "O CEP informado possui um formato inválido." unless cep.to_s.match(/^\d{8}$/)
              
              response = Net::HTTP.Proxy(self.proxy_addr, self.proxy_port).get_response(URI.parse("#{WEB_SERVICE_REPUBLICA_VIRTUAL_URL}#{cep}"))
          Severity: Minor
          Found in brcep/lib/brcep/busca_endereco.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 verifica_numero has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def verifica_numero
              limpo = @numero.gsub(/[\.\/-]/, "")
              if self.instance_of? Cpf
                return false if limpo.length != 11
              elsif self.instance_of? Cnpj
          Severity: Minor
          Found in brcpfcnpj/lib/brcpfcnpj/cpf_cnpj.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 decimal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def decimal(parte_fracionaria)
              unless parte_fracionaria.blank?
                return sem_delimitador_decimal(parte_fracionaria) if parte_fracionaria.length == 3
                return sem_delimitador_decimal(parte_fracionaria) + "0" if parte_fracionaria.length == 2
              end
          Severity: Minor
          Found in brdinheiro/lib/brdinheiro/dinheiro.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