tapajos/brazilian-rails

View on GitHub

Showing 16 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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              when 1_000_000_000_000..999_999_999_999_999
                tri,bi=n/1_000_000_000_000,n%1_000_000_000_000
                %(#{negativo}#{por_extenso(tri)} trilh#{tri > 1 ? 'ões':'ão'}#{bi > 0 ? " e #{por_extenso(bi)}" : ''})
          Severity: Major
          Found in brnumeros/lib/brnumeros/number_portuguese.rb and 2 other locations - About 40 mins to fix
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 88..90
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 91..93

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              when 1_000_000_000..999_999_999_999
                bi,mi=n/1_000_000_000,n%1_000_000_000
                %(#{negativo}#{por_extenso(bi)} bilh#{bi > 1 ? 'ões':'ão'}#{mi > 0 ? " e #{por_extenso(mi)}" : ''})
          Severity: Major
          Found in brnumeros/lib/brnumeros/number_portuguese.rb and 2 other locations - About 40 mins to fix
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 88..90
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 94..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              when 1_000_000..999_999_999
                mi,m=n/1_000_000,n%1_000_000
                %(#{negativo}#{por_extenso(mi)} milh#{mi > 1 ? 'ões':'ão'}#{m > 0 ? " e #{por_extenso(m)}" : ''})
          Severity: Major
          Found in brnumeros/lib/brnumeros/number_portuguese.rb and 2 other locations - About 40 mins to fix
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 91..93
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 94..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              when 101..999
                v=n % 100
                if  v== 0
                  negativo + @@centena[n].to_s
                else
          Severity: Minor
          Found in brnumeros/lib/brnumeros/number_portuguese.rb and 1 other location - About 25 mins to fix
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 69..74

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 30.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              when 20..99
                v=n % 10
                if  v== 0
                  negativo + @@dezena[n].to_s
                else
          Severity: Minor
          Found in brnumeros/lib/brnumeros/number_portuguese.rb and 1 other location - About 25 mins to fix
          brnumeros/lib/brnumeros/number_portuguese.rb on lines 78..83

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 30.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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