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
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
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'
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
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
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
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,
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
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
- Read upRead up
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?
- Read upRead up
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
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 ),
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'
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]
- Read upRead up
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?
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,
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)
- Read upRead up
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",
- Read upRead up
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
- Read upRead up
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|
- Read upRead up
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"