Showing 272 of 272 total issues
File sql_helper.rb
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Msip
module SqlHelper
# Pone cotejación dada a una columna tipo varchar (longitud long)
# Si la cotejación es nil o "" quita la posible cotejación
# que la columna tuviera
Method index_msip
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index_msip(c = nil)
if !c.nil?
if c.class.to_s.end_with?("ActiveRecord_Relation")
if clase.constantize.to_s != c.klass.to_s
Rails.logger.debug do
Method fecha_local_colombia_estandar
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def fecha_local_colombia_estandar(f, menserror = nil)
# Date.strptime(f, '%d-%M-%Y') no ha funcionado,
# %b debe ser en ingles
# rails-i18n I18n.localize con %b produce mes en minuscula
unless f
- 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 genera_asociabasica
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
def genera_asociabasica
if ENV["DISABLE_SPRING"].to_i != 1
# http://makandracards.com/makandra/24525-disabling-spring-when-debugging
Rails.logger.debug("Ejecutar con DISABLE_SPRING=1")
return
Method update_gen
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_gen(registro = nil)
@registro = if registro
registro
else
clase.constantize.find(params[:id])
Similar blocks of code found in 3 locations. Consider refactoring. Open
def validar_conjunto_veredas_biyeccion(validaciones)
if Msip::Vereda.all.count != Msip::Ubicacionpre.
where(lugar: nil).where.not(vereda_id: nil).
where(centropoblado_id: nil).count
validaciones << {
- 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 115.
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 3 locations. Consider refactoring. Open
def validar_conjunto_departamentos_biyeccion(validaciones)
if Msip::Departamento.all.count != Msip::Ubicacionpre.
where(lugar: nil).where.not(departamento_id: nil).
where(municipio_id: nil).count
validaciones << {
- 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 115.
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 3 locations. Consider refactoring. Open
def validar_conjunto_centrospoblados_biyeccion(validaciones)
if Msip::Centropoblado.all.count != Msip::Ubicacionpre.
where(lugar: nil).where.not(centropoblado_id: nil).
where(vereda_id: nil).count
validaciones << {
- 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 115.
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 vfechanac
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def vfechanac
anioactual = Time.now.strftime("%Y").to_i
if anionac && anionac > anioactual
errors.add(:anionac, "Año debe ser menor al actual")
end
- 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 copiar_asociaciones
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def copiar_asociaciones(foranea_id, excepciones)
self.class.reflect_on_all_associations.each do |ua|
if ((ua.macro == :has_many && !ua.options[:through]) ||
ua.macro == :has_and_belongs_to_many ) &&
!excepciones.include?(ua.name)
- 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
File modelo_helper.rb
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Msip
module ModeloHelper
include ActionView::Helpers::TextHelper
MESES = [
Method escapar_param
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def escapar_param(params, p, poromision = "")
if p.is_a?(String) || p.is_a?(Symbol)
params[p] ? escapar(params[p]) : ""
elsif p.is_a?(Array) && p.length == 1
params[p[0]] ? espacar_cadena(params[p[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 create_gen
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def create_gen(registro = nil)
c2 = clase.demodulize.underscore
if registro
@registro = registro
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
File personas_controller.rb
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Msip
module Concerns
module Controllers
module PersonasController
extend ActiveSupport::Concern
Method fecha_local_colombia_estandar
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fecha_local_colombia_estandar(f, menserror = nil)
# Date.strptime(f, '%d-%M-%Y') no ha funcionado,
# %b debe ser en ingles
# rails-i18n I18n.localize con %b produce mes en minuscula
unless f
Method destroy_gen
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def destroy_gen(mens = "", verifica_tablas_union = true)
@registro = clase.constantize.find(params[:id])
if @registro.respond_to?("current_usuario=")
@registro.current_usuario = current_usuario
end
Function ponerTema
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
static ponerTema(root, tema) {
console.log("entro a msip_ pone_tema")
document.querySelectorAll('.table-striped>tbody>tr:nth-child(odd)').forEach((element) => {
element.style.backgroundColor = tema.fondo_lista;
});
Method presenta_gen_msip
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def presenta_gen_msip(atr)
clf = self.class.clase_llave_foranea(atr)
if self.class.columns_hash && self.class.columns_hash[atr.to_s] &&
self.class.columns_hash[atr.to_s].type == :boolean
if self[atr.to_s]
Method barra_navegacion_prosidebar
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def barra_navegacion_prosidebar(opciones, &bloque)
fondo = "".html_safe
if opciones[:imagen_barra_lateral]
fondo = content_tag(
:div, class: "image-wrapper"
Method create
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@respaldo7z = Respaldo7z.new(respaldo7z_params)
respond_to do |format|
if @respaldo7z.valid?
Rake::Task["msip:vuelca"].reenable