Showing 13 of 13 total issues
Method modelo_generico_rodape
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modelo_generico_rodape(doc, boleto)
#INICIO Segunda parte do BOLETO BB
# LOGOTIPO do BANCO
doc.image(boleto.logotipo, :x => '0.4 cm', :y => '16.85 cm', :zoom => 80)
doc.moveto :x => '5.05 cm', :y => '16.9 cm'
Similar blocks of code found in 2 locations. Consider refactoring. Open
fixed_width_layout do |parse|
parse.field :tipo_registro, 13..13
parse.field :sequencial,8..12
parse.field :agencia_com_dv,17..22
parse.field :beneficiario_com_dv,23..35
- Read upRead up
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 80.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
fixed_width_layout do |parse|
# Todos os campos descritos no documento em ordem
# :tipo_de_registro, 0..0 # identificacao do registro transacao
# :codigo_de_inscricao, 1..2 # identificacao do tipo de inscrica/empresa
- Read upRead up
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 80.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method modelo_carne_build_data_right
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modelo_carne_build_data_right(doc, boleto,colunas,linhas)
# LOGOTIPO do BANCO
doc.image(boleto.logotipo, :x => colunas[2], :y => linhas[0], :zoom => 50)
Method modelo_generico_cabecalho
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modelo_generico_cabecalho(doc, boleto)
#INICIO Primeira parte do BOLETO
# LOGOTIPO do BANCO
doc.image(boleto.logotipo, x: '0.4 cm', y: '23.85 cm', zoom: 80)
# Dados
Method multiplicador
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def multiplicador(fatores, &block)
raise ArgumentError, 'Número inválido' unless self.is_number?
total = 0
multiplicador_posicao = 0
- 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 codigo_barras_segunda_parte
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def codigo_barras_segunda_parte
case self.convenio.to_s.size
when 8 # Nosso Número de 17 dígitos com Convenio de 8 dígitos e numero_documento de 9 dígitos
"000000#{self.convenio}#{self.numero_documento}#{self.carteira}"
when 7 # Nosso Número de 17 dígitos com Convenio de 7 dígitos e numero_documento de 10 dígitos
- 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 modelo_generico_multipage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def modelo_generico_multipage(boletos, options={})
doc=Document.new :paper => :A4 # 210x297
template_path = File.join(File.dirname(__FILE__),'..','..','arquivos','templates','modelo_generico.eps')
- 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 modulo_10_banespa
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def modulo_10_banespa
raise ArgumentError, 'Número inválido' unless self.is_number?
fatores = [7, 3, 1, 9, 7, 3, 1, 9, 7, 3]
total = 0
- 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 modelo_carne_multipage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def modelo_carne_multipage(boletos, options={})
doc=Document.new :paper => :A4
max_per_page = 3
- 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 modulo10
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def modulo10
raise ArgumentError, 'Número inválido' unless self.is_number?
total = 0
multiplicador = 2
- 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 to_currency
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_currency(options = {})
number = self
default = Brcobranca::Currency::DEFAULT
options = default.merge(options)
precision = options[:precision] || default[:precision]
- 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 numero_documento
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def numero_documento
quantidade = case @convenio.to_s.size
when 8
9
when 7
- 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"