ciudadanointeligente/partidopublico

View on GitHub

Showing 182 of 182 total issues

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

  Raphael.fn.ingreso_ord_front_footer = function(dato){
    var paper = this;
    var bar_width = 300;
    var bar_height = 30;
    var publico_width = (dato.publicos / (dato.publicos + dato.privados)) * bar_width;
Severity: Major
Found in app/assets/javascripts/raphael_frontend.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/raphael_frontend.js on lines 280..297

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

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

  Raphael.fn.egreso_ord_front_footer = function(dato){
    var paper = this;
    var bar_width = 300;
    var bar_height = 30;
    var publico_width = (dato.publicos / (dato.publicos + dato.privados)) * bar_width;
Severity: Major
Found in app/assets/javascripts/raphael_frontend.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/raphael_frontend.js on lines 196..213

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

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

Class PartidosController has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class PartidosController < ApplicationController
  before_action :authenticate_admin!, only: [:new, :edit, :create, :update, :destroy, :admin]
  before_filter :authenticate_superadmin, only: [:new, :edit, :create, :update, :destroy]
  before_action :set_partido, except: [:index, :new, :create, :admin]
  before_action :get_partidos, except: [:index, :new, :create, :admin]
Severity: Minor
Found in app/controllers/partidos_controller.rb - About 4 hrs to fix

    Function sedesController has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function sedesController($scope,$http,$location,$aside,$attrs){
      $scope.sedes = [];
      $scope.partido_id = $location.path().split("/")[2];
      $scope.pageSize = 5;
    
    
    Severity: Major
    Found in app/assets/javascripts/angular/angular_app.js - About 3 hrs to fix

      Function donutChart has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Raphael.fn.donutChart = function (cx, cy, r, rin, values, labels, stroke, legend, legendElement, colors) {
          var paper = this,
            rad = Math.PI / 180,
            chart = this.set();
      
      
      Severity: Major
      Found in app/assets/javascripts/raphael_frontend.js - About 3 hrs to fix

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

          $scope.getComunas = function(partido_id, region_id) {
            $http.get('partidos/'+partido_id+'/regions/'+region_id+'/comunas')
              .success( function(data){
                $scope.comunas = data;
              })
        Severity: Major
        Found in app/assets/javascripts/angular/angular_app.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/angular/angular_app.js on lines 324..332

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

        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

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

          $scope.getComunas = function(partido_id, region_id) {
            $http.get('partidos/'+partido_id+'/regions/'+region_id+'/comunas')
              .success( function(data){
                $scope.comunas = data;
              })
        Severity: Major
        Found in app/assets/javascripts/angular/angular_app.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/angular/angular_app.js on lines 152..160

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

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

          def regiones
            rangos = [[14,17],[18,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,59],[60,64],[65,69],[70,100]]
            @datos_region = []
            @datos_nacional = []
            @rangos_edad = []
        Severity: Major
        Found in app/controllers/partidos_controller.rb - About 3 hrs to fix

          File raphael_compare.js has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          $(document).ready(function(){
            var bar_width = 300;
            var bar_height = 30;
            var colors_x_edad = ["#FF0000", "#F00000", "#00F000", "#00FF00", "#0000F0", "#0000FF",
                                 "#0F0F00", "#FF00F0", "#FF000F", "#FF0F00", "#0FF000", "#FF00FF"]
          Severity: Minor
          Found in app/assets/javascripts/raphael_compare.js - About 3 hrs to fix

            Function personasController has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function personasController($scope,$http,$location,$aside,$attrs){
              $scope.persona = {};
              $scope.personas = [];
              $scope.partido_id = $location.path().split("/")[2];
              $scope.pageSize = 5;
            Severity: Major
            Found in app/assets/javascripts/angular/angular_app.js - About 3 hrs to fix

              Method afiliados_x_edad has a Cognitive Complexity of 22 (exceeds 5 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: Minor
              Found in app/controllers/comparisons_controller.rb - About 3 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

              Function tipoCargosController has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function tipoCargosController($scope,$http,$location,$aside,$attrs){
                $scope.tipo_cargos = [];
                $scope.partido_id = $location.path().split("/")[2];
              
                function getTipoCargosByPartido(partido_id) {
              Severity: Major
              Found in app/assets/javascripts/angular/angular_app.js - About 3 hrs to fix

                Function regiones_compare_chart has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  Raphael.fn.regiones_compare_chart = function(datos){
                    var paper = this;
                    var header_height = 40;
                    var line_height = 50;
                    var chart_width = 800;
                Severity: Major
                Found in app/assets/javascripts/raphael_compare.js - About 2 hrs to fix

                  Function actividad_publicasController has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function actividad_publicasController($scope,$http,$location,$aside,$attrs){
                    $scope.actividad_publicas = [];
                    $scope.partido_id = $location.path().split("/")[2];
                  
                    var save_or_update_actividad_publica = function() {
                  Severity: Major
                  Found in app/assets/javascripts/angular/angular_app.js - About 2 hrs to fix

                    Function representantes_compare_header has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      Raphael.fn.representantes_compare_header = function(){
                        var paper = this;
                        paper.circle(12, 15, 9 )
                        .attr({
                          "fill" : colors_representantes[0],
                    Severity: Major
                    Found in app/assets/javascripts/raphael_compare.js - About 2 hrs to fix

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

                        $scope.removeSede = function (sede) {
                          if (confirm('Seguro desea eliminar esta Sede?')) {
                            $http.delete('/partidos/' + $scope.partido_id + '/sedes/' + sede.id);
                            $scope.sedes.splice($scope.sedes.indexOf(sede), 1);
                          }
                      Severity: Major
                      Found in app/assets/javascripts/angular/angular_app.js and 3 other locations - About 2 hrs to fix
                      app/assets/javascripts/angular/angular_app.js on lines 95..100
                      app/assets/javascripts/angular/angular_app.js on lines 268..273
                      app/assets/javascripts/angular/angular_app.js on lines 592..597

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

                      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

                        $scope.removeTipoCargo = function (tipo_cargo) {
                          if (confirm('Seguro desea eliminar este tipo de cargo?')) {
                            $http.delete('/partidos/' + $scope.partido_id + '/tipo_cargos/' + tipo_cargo.id);
                            $scope.tipo_cargos.splice($scope.tipo_cargos.indexOf(tipo_cargo), 1);
                          }
                      Severity: Major
                      Found in app/assets/javascripts/angular/angular_app.js and 3 other locations - About 2 hrs to fix
                      app/assets/javascripts/angular/angular_app.js on lines 95..100
                      app/assets/javascripts/angular/angular_app.js on lines 268..273
                      app/assets/javascripts/angular/angular_app.js on lines 385..390

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

                      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

                        $scope.removeCargo = function(cargo) {
                          if (confirm('Seguro desea eliminar este Cargo?')) {
                            $http.delete('/partidos/' + $scope.partido_id + '/cargos/' + cargo.id);
                            $scope.cargos.splice($scope.cargos.indexOf(cargo), 1);
                          }
                      Severity: Major
                      Found in app/assets/javascripts/angular/angular_app.js and 3 other locations - About 2 hrs to fix
                      app/assets/javascripts/angular/angular_app.js on lines 95..100
                      app/assets/javascripts/angular/angular_app.js on lines 385..390
                      app/assets/javascripts/angular/angular_app.js on lines 592..597

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

                      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

                        $scope.removePersona = function (persona) {
                          if (confirm('Seguro desea eliminar esta Persona?')) {
                            $http.delete('/partidos/' + $scope.partido_id + '/personas/' + persona.id);
                            $scope.personas.splice($scope.personas.indexOf(persona), 1);
                          }
                      Severity: Major
                      Found in app/assets/javascripts/angular/angular_app.js and 3 other locations - About 2 hrs to fix
                      app/assets/javascripts/angular/angular_app.js on lines 268..273
                      app/assets/javascripts/angular/angular_app.js on lines 385..390
                      app/assets/javascripts/angular/angular_app.js on lines 592..597

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

                      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 getCircunscripciones() {
                          $http.get('circunscripcions')
                            .success( function(data){
                              $scope.circunscripcions = 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 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

                      Severity
                      Category
                      Status
                      Source
                      Language