Showing 410 of 410 total issues
Method genvic
has 194 lines of code (exceeds 25 allowed). Consider refactoring. Open
def genvic
authorize! :contar, Sivel2Gen::Caso
where1 = '';
@fechaini = '';
Method victimizaciones_individuales
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def victimizaciones_individuales
authorize! :contar, Sivel2Gen::Caso
## Valores de los filtros
@vic_fechaini = params[:filtro] ?
- 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 asignar_id_personatrelacion
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def asignar_id_personatrelacion(
params, victima_indice, victima_params, victimas_por_borrar
)
if victima_params[:persona_attributes]
if victima_params[:persona_attributes][:persona_trelacion1_attributes]
- 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 importa
has 189 lines of code (exceeds 25 allowed). Consider refactoring. Open
def importa(datosent, datossal, formato_sexo,
menserror, opciones = {})
if datosent['fecha'].nil?
self.fecha = Date.today
menserror << "Falta fecha. "
Method embeber_mapacalormuncol_svg
has 187 lines of code (exceeds 25 allowed). Consider refactoring. Open
def embeber_mapacalormuncol_svg(
depid, depcad, titulo, subtitulo, titulorangos, fuente,
cantidadesmun, opciones = {})
# Color más oscuro (para rango4)
cr = 0
Method embeber_mapacalordepcol_svg
has 186 lines of code (exceeds 25 allowed). Consider refactoring. Open
def embeber_mapacalordepcol_svg(titulo, subtitulo, titulorangos, fuente,
cantidadesdep, opciones = {})
# Color más oscuro (para rango4)
cr = 0
cv = 255
Method genconsulta_victimizaciones
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def genconsulta_victimizaciones(
pFini, pFfin, pTviolencia, pEtiqueta1, pEtiqueta2, pExcluirCateRep,
pSegun, pDepartamento, pMunicipio, pCategoria = nil)
tcons1 = 'cvt1'
- 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 importar_relato
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def self.importar_relato(doc, menserror, sintaxis_errores, mensexito, ids_importados,
usuario_id, formato_sexo)
if !Nokogiri::XML(doc).errors.empty?
Nokogiri::XML(doc).errors.each do |error|
sintaxis_errores.push(error.message)
- 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 recorrer_observaciones_v
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def recorrer_observaciones_v(ele, menserror)
case ele[0]
when 'filiacion'
if Sivel2Gen::Filiacion.where('TRIM(nombre)=?', ele[1].strip).count ==1
self.filiacion_id = Sivel2Gen::Filiacion.
- 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 mapaosm_controller.js
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Controller } from "@hotwired/stimulus"
import Msip__Motor from "../msip/motor"
Function cambiarficha
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
cambiarficha(){
if(event.target.dataset.enviarFichaCasoTarget == 'actos-pestana'){
document.getElementById("capa-cargando").style.display = 'flex';
if(this.requiereGuardar()){
let casoId = this.idcasoTarget.value
- 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 victimizaciones_individuales
has 151 lines of code (exceeds 25 allowed). Consider refactoring. Open
def victimizaciones_individuales
authorize! :contar, Sivel2Gen::Caso
## Valores de los filtros
@vic_fechaini = params[:filtro] ?
Method presenta_index
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def presenta_index
# Presentación
respond_to do |format|
if current_usuario || (Rails.configuration.x.sivel2_consweb_max &&
@conscaso.count <= Rails.configuration.x.sivel2_consweb_max.to_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"
Further reading
File vista_helper.rb
has 408 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Sivel2Gen
module VistaHelper
include Rails.application.routes.url_helpers
Method initialize_sivel2_gen
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def self.initialize_sivel2_gen(habilidad, usuario = nil)
# Sin autenticación puede consultarse información geográfica
habilidad.can :read, [Msip::Pais, Msip::Departamento, Msip::Municipio, Msip::Centropoblado, Msip::Ubicacionpre]
# Hacer conteos
- 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 genconsulta_victimizaciones
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
def genconsulta_victimizaciones(
pFini, pFfin, pTviolencia, pEtiqueta1, pEtiqueta2, pExcluirCateRep,
pSegun, pDepartamento, pMunicipio, pCategoria = nil)
tcons1 = 'cvt1'
Method importa
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
def importa(datosent, datossal, menserror, opciones = {})
v = datosent[1]
if v
if v['nombre']
self.nombre = v['nombre']
Method initialize_sivel2_gen
has 130 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.initialize_sivel2_gen(habilidad, usuario = nil)
# Sin autenticación puede consultarse información geográfica
habilidad.can :read, [Msip::Pais, Msip::Departamento, Msip::Municipio, Msip::Centropoblado, Msip::Ubicacionpre]
# Hacer conteos
Method importa
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
def importa(g, datossal, menserror, opciones = {})
#Se verifica que el grupo no sea un presunto responsable
gp = Msip::Grupoper.new
gp.nombre = g['nombre_grupo']
gp.save!
Similar blocks of code found in 3 locations. Consider refactoring. Open
window.Rails.ajax({
type: 'GET',
url: a,
data: d,
success: (resp, estado, xhr) => {
- 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 137.
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