ciudadanointeligente/partidopublico

View on GitHub

Showing 182 of 182 total issues

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

  function getRegions() {
    $http.get('all_regions')
      .success( function(data){
        $scope.regions = data;
      })
Severity: Major
Found in app/assets/javascripts/angular/angular_app.js and 2 other locations - About 2 hrs to fix
app/assets/javascripts/angular/angular_app.js on lines 142..150
app/assets/javascripts/angular/angular_app.js on lines 162..170

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

Further Reading

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

  function getRegions() {
    $http.get('all_regions')
      .success( function(data){
        $scope.regions = data;
      })
Severity: Major
Found in app/assets/javascripts/angular/angular_app.js and 2 other locations - About 2 hrs to fix
app/assets/javascripts/angular/angular_app.js on lines 162..170
app/assets/javascripts/angular/angular_app.js on lines 314..322

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

Further Reading

Function process has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      process = function (j) {
        var value = values[j],
          angleplus = 360 * value / total,
          popangle = angle + (angleplus / 2),
          color = Raphael.hsb(start, .75, 1),
Severity: Major
Found in app/assets/javascripts/raphael_frontend.js - About 2 hrs to fix

    Method afiliados_x_edad has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def afiliados_x_edad
          rangos = rangos_etarios
    
          @fechas_datos = Afiliacion.where(Afiliacion.arel_table[:partido_id].in(@partido_ids)).uniq.pluck(:fecha_datos).sort
    
    
    Severity: Major
    Found in app/controllers/comparisons_controller.rb - About 2 hrs to fix

      Method acuerdos_organos has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def acuerdos_organos
          @acuerdos = []
          tipos = %w(Acta Programatico Electoral Funcionamiento\ Interno)
      
          tipos.each do |t|
      Severity: Minor
      Found in app/controllers/partidos_controller.rb - About 2 hrs 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

      File raphael_frontend.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      $(document).ready(function(){
        var green = "#1AC0A4";
        var green_light = "#23DBB8";
        var green_dark = "#19A58A";
        var sky_light = "#78EEE8";
      Severity: Minor
      Found in app/assets/javascripts/raphael_frontend.js - About 2 hrs to fix

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

          def self.import(file, partido_id, email)
            partido = Partido.find partido_id
            filas_importadas = 0
            errores = 0
            CSV.foreach(file.path, headers: true) do |row|
        Severity: Major
        Found in app/models/ingreso_campana.rb and 3 other locations - About 1 hr to fix
        app/models/contratacion.rb on lines 30..54
        app/models/egreso_campana.rb on lines 31..55
        app/models/egreso_ordinario.rb on lines 23..47

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

        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 self.import(file, partido_id, email)
            partido = Partido.find partido_id
            filas_importadas = 0
            errores = 0
            CSV.foreach(file.path, headers: true) do |row|
        Severity: Major
        Found in app/models/egreso_campana.rb and 3 other locations - About 1 hr to fix
        app/models/contratacion.rb on lines 30..54
        app/models/egreso_ordinario.rb on lines 23..47
        app/models/ingreso_campana.rb on lines 30..54

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

        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 self.import(file, partido_id, email)
            partido = Partido.find partido_id
            filas_importadas = 0
            errores = 0
            CSV.foreach(file.path, headers: true) do |row|
        Severity: Major
        Found in app/models/contratacion.rb and 3 other locations - About 1 hr to fix
        app/models/egreso_campana.rb on lines 31..55
        app/models/egreso_ordinario.rb on lines 23..47
        app/models/ingreso_campana.rb on lines 30..54

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

        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 self.import(file, partido_id, email)
            partido = Partido.find partido_id
            filas_importadas = 0
            errores = 0
            CSV.foreach(file.path, headers: true) do |row|
        Severity: Major
        Found in app/models/egreso_ordinario.rb and 3 other locations - About 1 hr to fix
        app/models/contratacion.rb on lines 30..54
        app/models/egreso_campana.rb on lines 31..55
        app/models/ingreso_campana.rb on lines 30..54

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

        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

              @datos_publicos = Partido.joins('left join ingreso_ordinarios on ingreso_ordinarios.partido_id = partidos.id and ingreso_ordinarios.fecha_datos in (\'' + @fecha.to_s + '\')')
              .where(Partido.arel_table[:id].in(@partido_ids))
              .where(IngresoOrdinario.arel_table[:concepto].eq('Aportes Estatales').or(IngresoOrdinario.arel_table[:concepto].eq(nil)))
              .where(IngresoOrdinario.arel_table[:fecha_datos].in(@fecha).or(IngresoOrdinario.arel_table[:fecha_datos].eq(nil)))
              .select(Partido.arel_table[:sigla],Partido.arel_table[:nombre], "fecha_datos, partido_id, sum(importe) as total_publico")
        Severity: Major
        Found in app/controllers/comparisons_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/comparisons_controller.rb on lines 190..196

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

        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

              @datos_privados = Partido.joins('left join ingreso_ordinarios on ingreso_ordinarios.partido_id = partidos.id and ingreso_ordinarios.fecha_datos in (\'' + @fecha.to_s + '\')')
              .where(Partido.arel_table[:id].in(@partido_ids))
              .where(IngresoOrdinario.arel_table[:concepto].not_eq('Aportes Estatales').or(IngresoOrdinario.arel_table[:concepto].eq(nil)))
              .where(IngresoOrdinario.arel_table[:fecha_datos].in(@fecha).or(IngresoOrdinario.arel_table[:fecha_datos].eq(nil)))
              .select(Partido.arel_table[:sigla],Partido.arel_table[:nombre], "fecha_datos, partido_id, sum(importe) as total_privado")
        Severity: Major
        Found in app/controllers/comparisons_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/comparisons_controller.rb on lines 182..188

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

        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 estructura_organica has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def estructura_organica
            organos_internos = @partido.organo_internos
            @datos = []
        
            organos_internos.each do |o|
        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

        Function regiones_compare_header has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function regiones_compare_header(){
        
              paper.circle(12, 15, 9 )
              .attr({
                "fill" : "#19A58A",
        Severity: Minor
        Found in app/assets/javascripts/raphael_compare.js - About 1 hr to fix

          Method afiliados has 37 lines of code (exceeds 25 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

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

                          case 'hombres':
                            legendElement.append('<li><i class="fa fa-circle" aria-hidden="true" data-id='+ bcolor +' style="color:' + bcolor + ';"></i> ' + labels[j] + " : " + Math.floor(values[j]) + '</li>');
                            break;
            Severity: Major
            Found in app/assets/javascripts/raphael_frontend.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/raphael_frontend.js on lines 55..57

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

            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

                          case 'mujeres':
                            legendElement.append('<li><i class="fa fa-circle" aria-hidden="true" data-id='+ bcolor +' style="color:' + bcolor + ';"></i> ' + labels[j] + " : " + Math.floor(values[j]) + '</li>');
                            break;
            Severity: Major
            Found in app/assets/javascripts/raphael_frontend.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/raphael_frontend.js on lines 52..54

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

            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 partido_params has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def partido_params
                      params.require(:partido).permit(:nombre, :sigla, :lema, :fecha_fundacion, :texto, :logo, :front_logo,
                                                                sedes_attributes: [:id, :region, :direccion, :contacto, :_destroy],
                                                                afiliacions_attributes: [:id, :region_id, :hombres, :mujeres, :otros, :fecha_datos, :ano_nacimiento, :_destroy],
                                                                tramites_attributes: [:id, :nombre, :descripcion, :persona_id, :documento, :_destroy,
            Severity: Minor
            Found in app/controllers/partido_steps_controller.rb - About 1 hr to fix

              Method initialize_transparency_settings has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def initialize_transparency_settings
              
                    superadmins = Admin.where is_superadmin: true
                    superadmins.each do |admin|
                      self.admins << admin
              Severity: Minor
              Found in app/models/partido.rb - About 1 hr to fix

                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

                Severity
                Category
                Status
                Source
                Language