Brunomm/br_boleto

View on GitHub

Showing 55 of 92 total issues

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

    def validate_each(record, attribute, value)
        is_value = max_value = min_value = nil
        max_value = options[:maximum].is_a?(Symbol) ? record.send(options[:maximum]).to_i : options[:maximum]
        min_value = options[:minimum].is_a?(Symbol) ? record.send(options[:minimum]).to_i : options[:minimum]
        is_value  = options[:is].is_a?(Symbol) ? record.send(options[:is]).to_i : options[:is]
Severity: Minor
Found in lib/br_boleto/validations.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 monta_segmento_r has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                    def monta_segmento_r(pagamento, nr_lote, sequencial)
                        segmento_r = ''
                        segmento_r << segmento_r_posicao_001_a_003 
                        segmento_r << segmento_r_posicao_004_a_007(nr_lote)
                        segmento_r << segmento_r_posicao_008_a_008
Severity: Minor
Found in lib/br_boleto/remessa/cnab240/helper/segmento_r.rb - About 1 hr to fix

    Method detalhe_fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    def detalhe_fields #:doc:
                        { #    ATRIBUTO               POSIÇÃO DA LINHA
    
                            sacado_documento:              4..17,
                            agencia_sem_dv:                18..21,
    Severity: Minor
    Found in lib/br_boleto/retorno/cnab400/caixa.rb - About 1 hr to fix

      Method set_regras_tamanho_e_validations! has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def set_regras_tamanho_e_validations!
                  @conta ||= conta_class.new()
                  @conta.valid_conta_corrente_length   = valid_conta_corrente_length   if "#{valid_conta_corrente_length}".present?
                  @conta.valid_conta_corrente_minimum  = valid_conta_corrente_minimum  if "#{valid_conta_corrente_minimum}".present?
                  @conta.valid_conta_corrente_maximum  = valid_conta_corrente_maximum  if "#{valid_conta_corrente_maximum}".present?
      Severity: Minor
      Found in lib/br_boleto/association/have_conta.rb - About 1 hr to fix

        Method equivalent_codigo_motivo_ocorrencia_A_400 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        def equivalent_codigo_motivo_ocorrencia_A_400 codigo_movimento_gem
                            super.merge(
                                #  Padrão    Código para  
                                {# do Banco    a GEM
                                    '00'   =>   'A00',    # Ocorrência aceita
        Severity: Minor
        Found in lib/br_boleto/conta/bradesco.rb - About 1 hr to fix

          Method equivalent_codigo_movimento_retorno_400 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                          def equivalent_codigo_movimento_retorno_400
                              super.merge(
                                  #  Padrão    Código para  
                                  {# do Banco    a GEM
                                      '01'   =>   '02',      # Entrada Confirmada
          Severity: Minor
          Found in lib/br_boleto/conta/caixa.rb - About 1 hr to fix

            Method equivalent_codigo_motivo_ocorrencia_A_400 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            def equivalent_codigo_motivo_ocorrencia_A_400 codigo_movimento_gem
                                super.merge(
                                    #  Padrão    Código para  
                                    {# do Banco    a GEM
                                        '01'   =>   'A220',  # Movimento sem Beneficiário Correspondente
            Severity: Minor
            Found in lib/br_boleto/conta/caixa.rb - About 1 hr to fix

              Method segmento_t_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              def segmento_t_fields #:doc:
                                  { #    ATRIBUTO               POSIÇÃO DA LINHA
                                      codigo_movimento_retorno:      16..17,
                                      agencia_com_dv:                18..23,
                                      agencia_sem_dv:                18..22,
              Severity: Minor
              Found in lib/br_boleto/retorno/cnab240/base.rb - About 1 hr to fix

                Method detalhe_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                def detalhe_fields #:doc:
                                    { #    ATRIBUTO               POSIÇÃO DA LINHA
                
                                        carteira:                      14..14,
                                        codigo_pagador_cooperativa:    15..19,
                Severity: Minor
                Found in lib/br_boleto/retorno/cnab400/sicredi.rb - About 1 hr to fix

                  Method equivalent_codigo_motivo_ocorrencia_C_240 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                                  def equivalent_codigo_motivo_ocorrencia_C_240 codigo_movimento_gem
                                      super.merge(
                                          #  Padrão    Código para  
                                          {# do Banco    a GEM
                                              'AA'  =>   'C32',   # CAIXA ELETRÔNICO ITAÚ
                  Severity: Minor
                  Found in lib/br_boleto/conta/itau.rb - About 1 hr to fix

                    Method equivalent_codigo_movimento_retorno_400 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                                    def equivalent_codigo_movimento_retorno_400
                                        super.merge(
                                            #  Padrão    Código para  
                                            {# do Banco    a GEM
                                                '05'   =>   '17',   # Liquidado sem registro (carteira 17=tipo4)
                    Severity: Minor
                    Found in lib/br_boleto/conta/banco_brasil.rb - About 1 hr to fix

                      Method segmento_t_fields has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                      def segmento_t_fields #:doc:
                                          super.merge({ 
                                          #    ATRIBUTO                 POSIÇÃO DA LINHA
                                              agencia_com_dv:                18..22,
                                              agencia_sem_dv:                18..21,
                      Severity: Minor
                      Found in lib/br_boleto/retorno/cnab240/santander.rb - About 1 hr to fix

                        Method default_values has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                    def default_values
                                        {
                                            data_emissao:      Date.today,
                                            valor_desconto:    0.0,
                                            valor_iof:         0.0,
                        Severity: Minor
                        Found in lib/br_boleto/remessa/pagamento.rb - About 1 hr to fix

                          Method endereco_formatado has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def endereco_formatado
                                      addr = []
                                      addr << endereco unless endereco.blank?
                                      addr << bairro   unless bairro.blank?
                                      addr << @cep     unless cep.blank?
                          Severity: Minor
                          Found in lib/br_boleto/pagador.rb - About 45 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 get_codigo_motivo_ocorrencia has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                                          def get_codigo_motivo_ocorrencia(code, codigo_movimento_gem, cnab)
                                              return if code.blank? || codigo_movimento_gem.blank?
                          
                                              if codigo_movimento_gem.in? send("codigos_movimento_retorno_para_ocorrencia_A_#{cnab}")
                                                  send("equivalent_codigo_motivo_ocorrencia_A_#{cnab}", codigo_movimento_gem) [code] || 'OUTRO_A'
                          Severity: Minor
                          Found in lib/br_boleto/helper/default_codes.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

                          Severity
                          Category
                          Status
                          Source
                          Language