ciudadanointeligente/partidopublico

View on GitHub

Showing 182 of 182 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  Raphael.fn.no_data_chart = function(){
    this.text(20 , 20, "No hay datos")
         .attr({
           "font-family" : "Karla-Regular, Karla",
           "font-size" : 30,
Severity: Major
Found in app/assets/javascripts/raphael_frontend.js and 1 other location - About 1 hr to fix
app/assets/javascripts/raphael_compare.js on lines 374..382

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 62.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def aggregate_egresos_campanas
    datos_by_partido = EgresoCampana.where partido: @partido
    fechas_distintas = datos_by_partido.uniq.pluck(:fecha_datos)
    @datos = []
    fechas_distintas.each do |fecha|
Severity: Major
Found in app/controllers/egreso_campanas_controller.rb and 1 other location - About 1 hr to fix
app/controllers/ingreso_campanas_controller.rb on lines 12..22

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 57.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def aggregate_ingresos_campanas
    datos_by_partido = IngresoCampana.where partido: @partido
    fechas_distintas = datos_by_partido.uniq.pluck(:fecha_datos)
    @datos = []
    fechas_distintas.each do |fecha|
Severity: Major
Found in app/controllers/ingreso_campanas_controller.rb and 1 other location - About 1 hr to fix
app/controllers/egreso_campanas_controller.rb on lines 12..22

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 57.

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

Further Reading

Method show has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show

    @datos_region = []
    @datos_sedes = []
    @datos_cargos = []
Severity: Minor
Found in app/controllers/partidos_controller.rb - About 1 hr to fix

    Method afiliados has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def afiliados
          @fechas_datos = Afiliacion.where(Afiliacion.arel_table[:partido_id].in(@partido_ids)).uniq.pluck(:fecha_datos).sort
    
          @regiones_datos = Afiliacion.joins(:region).where(Afiliacion.arel_table[:partido_id].in(@partido_ids)).uniq.pluck(:nombre, :region_id).sort
    
    
    Severity: Minor
    Found in app/controllers/comparisons_controller.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

    Function donutChart has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        Raphael.fn.donutChart = function (cx, cy, r, rin, values, labels, stroke, legend, legendElement, colors) {
    Severity: Major
    Found in app/assets/javascripts/raphael_frontend.js - About 1 hr to fix

      Method completed_percentage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def completed_percentage
            total = 0
      
            if self.nombre
              total = total + 2
      Severity: Minor
      Found in app/models/partido.rb - About 1 hr to fix

        Function representantes_compare_bar has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Raphael.fn.representantes_compare_bar = function(max, val, text){
            var paper = this;
            var width = (val / max) * bar_width;
            var color = 0;
            switch (text) {
        Severity: Minor
        Found in app/assets/javascripts/raphael_compare.js - About 1 hr to fix

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

              def show
          
                  # @user = current_user
                  # @partido = Partido.find_by_user_id(current_user.id)
          
          
          Severity: Minor
          Found in app/controllers/partido_steps_controller.rb - About 1 hr to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def create
                PaperTrail.whodunnit = current_admin.email
                @tipo_cargo = TipoCargo.new(tipo_cargo_params)
            
                respond_to do |format|
            Severity: Major
            Found in app/controllers/tipo_cargos_controller.rb and 2 other locations - About 1 hr to fix
            app/controllers/cargos_controller.rb on lines 28..38
            app/controllers/sedes_controller.rb on lines 29..39

            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 51.

            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

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def create
                PaperTrail.whodunnit = current_admin.email
                @cargo = Cargo.new(cargo_params)
            
                respond_to do |format|
            Severity: Major
            Found in app/controllers/cargos_controller.rb and 2 other locations - About 1 hr to fix
            app/controllers/sedes_controller.rb on lines 29..39
            app/controllers/tipo_cargos_controller.rb on lines 28..38

            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 51.

            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

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def create
                PaperTrail.whodunnit = current_admin.email
                @sede = Sede.new(sede_params)
            
                respond_to do |format|
            Severity: Major
            Found in app/controllers/sedes_controller.rb and 2 other locations - About 1 hr to fix
            app/controllers/cargos_controller.rb on lines 28..38
            app/controllers/tipo_cargos_controller.rb on lines 28..38

            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 51.

            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

            Further Reading

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

                def completed_percentage
                  total = 0
            
                  if self.nombre
                    total = total + 2
            Severity: Minor
            Found in app/models/partido.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 intereses_patrimonios has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def intereses_patrimonios
                @intereses_patrimonios = []
                tc_candidatos = @partido.tipo_cargos#.where(candidato:true)
                tc_candidatos.each do |tc|
                  filter_by = @partido.cargos.where(tipo_cargo_id:tc)
            Severity: Minor
            Found in app/controllers/partidos_controller.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 tutorial_progress_bar has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def tutorial_progress_bar
                  content_tag(:section, class: "content") do
                    content_tag(:div, class: "navigator") do
                      content_tag(:ol, class: "steps_list") do
                        wizard_steps.collect do |every_step|
            Severity: Minor
            Found in app/helpers/partido_steps_helper.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

            Function egreso_ord_front_bar has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Raphael.fn.egreso_ord_front_bar = function(dato){
                var paper = this;
                var bar_width = 300;
                var bar_height = 30;
                var publico_percentage = dato.value_publico / dato.value;
            Severity: Minor
            Found in app/assets/javascripts/raphael_frontend.js - About 1 hr to fix

              Method ingresos_ordianrios has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def ingresos_ordianrios
                    @datos = []
              
                    @fechas_datos = IngresoOrdinario.where(IngresoOrdinario.arel_table[:partido_id].in(@partido_ids)).uniq.pluck(:fecha_datos).sort
              
              
              Severity: Minor
              Found in app/controllers/comparisons_controller.rb - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def aggregate_contrataciones
                    datos_by_partido = Contratacion.where partido: @partido
                    fechas_distintas = datos_by_partido.uniq.pluck(:fecha_datos)
                    @datos = []
                    fechas_distintas.each do |fecha|
                Severity: Major
                Found in app/controllers/contratacions_controller.rb and 1 other location - About 1 hr to fix
                app/controllers/transferencias_controller.rb on lines 12..21

                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 49.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def aggregate_transferencias
                    datos_by_partido = Transferencia.where partido: @partido
                    fechas_distintas = datos_by_partido.uniq.pluck(:fecha_datos)
                    @datos = []
                    fechas_distintas.each do |fecha|
                Severity: Major
                Found in app/controllers/transferencias_controller.rb and 1 other location - About 1 hr to fix
                app/controllers/contratacions_controller.rb on lines 12..21

                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 49.

                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

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                  def update
                    PaperTrail.whodunnit = current_admin.email
                    respond_to do |format|
                      if @cargo.update(cargo_params)
                        format.html { redirect_to @cargo, notice: 'Cargo was successfully updated.' }
                Severity: Major
                Found in app/controllers/cargos_controller.rb and 3 other locations - About 1 hr to fix
                app/controllers/partidos_controller.rb on lines 125..133
                app/controllers/sedes_controller.rb on lines 46..54
                app/controllers/tipo_cargos_controller.rb on lines 45..53

                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 48.

                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

                Further Reading

                Severity
                Category
                Status
                Source
                Language