Brunomm/br_nfe

View on GitHub

Showing 28 of 56 total issues

Class Base has 49 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Base < BrNfe::ActiveModelBase
        include BrNfe::Association::HaveEmitente

        attr_accessor :certificate_pkcs12_password
        attr_accessor :certificate_pkcs12_path
Severity: Minor
Found in lib/br_nfe/base.rb - About 6 hrs to fix

    File nota_fiscal.rb has 375 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module BrNfe
        module Product
            class NotaFiscal  < BrNfe::ActiveModelBase
                # include BrNfe::Association::HaveCondicaoPagamento
    
    
    Severity: Minor
    Found in lib/br_nfe/product/nota_fiscal.rb - About 5 hrs to fix

      File br_nfe.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'br_nfe/version'
      require 'active_model'
      require 'active_support/core_ext/class'
      require 'active_support/core_ext/enumerable'
      require 'active_support/core_ext/object'
      Severity: Minor
      Found in lib/br_nfe.rb - About 3 hrs to fix

        File invoice_build.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module BrNfe
            module Service
                module Response
                    module Build
                        class InvoiceBuild  < BrNfe::Service::Response::Build::Base
        Severity: Minor
        Found in lib/br_nfe/service/response/build/invoice_build.rb - About 3 hrs to fix

          Class Base has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

                          class Base < BrNfe::ActiveModelBase
                              attr_accessor :savon_response
                              attr_accessor :operation
          
                              def original_xml
          Severity: Minor
          Found in lib/br_nfe/product/response/build/base.rb - About 3 hrs to fix

            Class Base has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

                        class Base < BrNfe::Base
                            include NfXmlValue
            
                            # Versão da NF-e que irá pegar as configurações
                            attr_accessor :nfe_version
            Severity: Minor
            Found in lib/br_nfe/product/operation/base.rb - About 3 hrs to fix

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

                                      def default_values
                                          super.merge({
                                              # invoices_path:                                       response_invoices_path,
                                              invoice_numero_nf_path:                              response_invoice_numero_nf_path,
                                              invoice_codigo_verificacao_path:                     response_invoice_codigo_verificacao_path,
              Severity: Major
              Found in lib/br_nfe/service/response/build/invoice_build.rb - About 2 hrs to fix

                Class NotaFiscal has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                        class NotaFiscal  < BrNfe::ActiveModelBase
                            # include BrNfe::Association::HaveCondicaoPagamento
                
                            # Identificação do emitente da NF-e
                            # Versão do XML
                Severity: Minor
                Found in lib/br_nfe/product/nota_fiscal.rb - About 2 hrs to fix

                  Method has_one has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                                  def has_one attr_name, class_name, *args
                                      options = {null: true, inverse_of: :reference}.merge(args.extract_options!)
                  
                                      define_method attr_name do |&block|
                                          block.call(send("#{attr_name}_force_instance")) if block
                  Severity: Minor
                  Found in lib/br_nfe/active_model/has_one.rb - About 2 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 populate! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                                      def populate!
                                          set_product_details
                                          set_icms            if @xml.css( @path[:icms][:root] ).present?
                                          set_ipi             if @xml.css( @path[:ipi][:root] ).present?
                                          set_pis             if @xml.css( @path[:pis][:root] ).present?
                  Severity: Minor
                  Found in lib/br_nfe/product/reader/item.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 set_product_details has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                                      def set_product_details
                                          @item.tipo_produto              = @xml.css( @path[:issqn][:root] ).present? ? :service : :product
                                          @item.codigo_produto            = @xml.css( @path[:codigo_produto] ).text
                                          @item.codigo_ean                = @xml.css( @path[:codigo_ean] ).text
                                          @item.descricao_produto         = @xml.css( @path[:descricao_produto] ).text
                  Severity: Minor
                  Found in lib/br_nfe/product/reader/item.rb - About 1 hr to fix

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

                                        def instance_invoice(invoice_hash)
                                            nfe = BrNfe::Service::Response::NotaFiscal.new({
                                                xml_nf:                           get_xml_nf.force_encoding('UTF-8'),
                                                numero_nf:                        find_value_for_keys(invoice_hash, invoice_numero_nf_path                       ),
                                                codigo_verificacao:               find_value_for_keys(invoice_hash, invoice_codigo_verificacao_path              ),
                    Severity: Minor
                    Found in lib/br_nfe/service/response/build/invoice_build.rb - About 1 hr to fix

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

                                      def get_gateway_by_normal_operation                
                                          case "#{ibge_code_of_issuer_uf}"
                                          when '13'
                                              :am
                                          when '29'
                      Severity: Minor
                      Found in lib/br_nfe/product/operation/base.rb - About 1 hr to fix

                        Method validate_has_many has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                        def validate_has_many attr_name, *args
                                            options = {
                                                message: "invalid_#{attr_name.to_s.singularize}".to_sym
                                            }.merge(args.extract_options!)
                                            if options[:if]
                        Severity: Minor
                        Found in lib/br_nfe/active_model/has_many.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 populate_invoice! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                        def populate_invoice!
                                            build_associations
                        
                                            # Totais
                                            build_product_total_values! if @xml_nfe.css(path[:total_icms][:root]).present?
                        Severity: Minor
                        Found in lib/br_nfe/product/reader/nfe.rb - About 1 hr to fix

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

                                              def set_icms
                                                  codigo_cst =  @xml.css( @path[:icms][:cst] ).text
                                                  codigo_cst =  @xml.css( @path[:icms][:csosn] ).text if codigo_cst.blank?
                                                  @item.icms = {
                                                      origem:                       @xml.css( @path[:icms][:origem] ).text,
                          Severity: Minor
                          Found in lib/br_nfe/product/reader/item.rb - About 1 hr to fix

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

                                            def validate_has_one attr_name, *args
                                                options = {message: "invalid_#{attr_name}".to_sym}
                                                options.merge!(args.extract_options!)
                                                if options[:if]
                                                    if options[:if].is_a?(Proc)
                            Severity: Minor
                            Found in lib/br_nfe/active_model/has_one.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 get_wsdl_by_city has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                                def get_wsdl_by_city
                                                    if ibge_code_of_issuer_city == '4205902' # Gaspar-SC
                                                        {
                                                            send:    "http://nfse#{'hml' if env == :test}.gaspar.sc.gov.br/nfse/services/NFSEremessa?wsdl",
                                                            consult: "http://nfse#{'hml' if env == :test}.gaspar.sc.gov.br/nfse/services/NFSEconsulta?wsdl",
                            Severity: Minor
                            Found in lib/br_nfe/service/thema/v1/base.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 convert_to_time has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                    def convert_to_time(value)
                                        return if value.blank?
                                        if value.class.in?([Time, DateTime])
                                            value.to_time.in_time_zone
                                        else
                            Severity: Minor
                            Found in lib/br_nfe/active_model_base.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 validar_lote_rps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                                        def validar_lote_rps
                                                            if lote_rps.empty?
                                                                errors.add(:base, "Deve conter ao menos 1 RPS")
                                                            else
                                                                lote_rps.each_with_index do |rps, i|
                            Severity: Minor
                            Found in lib/br_nfe/service/concerns/rules/recepcao_lote_rps.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