mysociety/alaveteli

View on GitHub

Showing 210 of 632 total issues

Function setupTickGeneration has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function setupTickGeneration(axis) {
            var opts = axis.options;

            // estimate number of ticks
            var noTicks;
Severity: Major
Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

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

            if (ax[0].p2c(ax[0].max) < ax[0].p2c(ax[0].min)) {
                invertX = true;
                var tmp = err[0].lowerCap;
                err[0].lowerCap = err[0].upperCap;
                err[0].upperCap = tmp;
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.errorbars.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/jquery.flot.errorbars.js on lines 180..185

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

    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

            if (ax[1].p2c(ax[1].min) < ax[1].p2c(ax[1].max)) {
                invertY = true;
                var tmp = err[1].lowerCap;
                err[1].lowerCap = err[1].upperCap;
                err[1].upperCap = tmp;
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.errorbars.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/jquery.flot.errorbars.js on lines 172..177

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

    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

            if (errors == 'x' || errors == 'xy') {
                // lower / upper error
                if (series.points.xerr.asymmetric) {
                    format.push({ x: true, number: true, required: true });
                    format.push({ x: true, number: true, required: true });
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.errorbars.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/jquery.flot.errorbars.js on lines 96..103

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

    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

            if (errors == 'y' || errors == 'xy') {
                // lower / upper error
                if (series.points.yerr.asymmetric) {
                    format.push({ y: true, number: true, required: true });
                    format.push({ y: true, number: true, required: true });
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.errorbars.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/jquery.flot.errorbars.js on lines 88..95

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

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

            function parseOptions(opts) {
    
                $.extend(true, options, opts);
    
                // $.extend merges arrays, rather than replacing them.  When less
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

      Method new has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def new
          # All new requests are of normal_sort
          if !params[:outgoing_message].nil?
            params[:outgoing_message][:what_doing] = 'normal_sort'
          end
      Severity: Major
      Found in app/controllers/request_controller.rb - About 3 hrs to fix

        Method describe_state has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def describe_state
            info_request = InfoRequest.not_embargoed.find(params[:id].to_i)
            set_last_request(info_request)
        
            # If this is an external request, go to the request page - we don't allow
        Severity: Major
        Found in app/controllers/request_controller.rb - About 3 hrs to fix

          Method initialize has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(user)
              # Define abilities for the passed in user here. For example:
              #
              #   user ||= User.new # guest user (not logged in)
              #   if user.is_admin?
          Severity: Major
          Found in app/models/ability.rb - About 3 hrs to fix

            Method xapian_index has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def xapian_index(terms = true, values = true, texts = true)
                  # if we have a conditional function for indexing, call it and destroy object if failed
                  if self.class.xapian_options.include?(:if)
                    if_value = xapian_value(self.class.xapian_options[:if], :boolean)
                    if not if_value
            Severity: Major
            Found in lib/acts_as_xapian/acts_as_xapian.rb - About 3 hrs to fix

              Function insertLegend has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      function insertLegend() {
              
                          placeholder.find(".legend").remove();
              
                          if (!options.legend.show)
              Severity: Major
              Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

                Function drawBar has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        function drawBar(x, y, b, barLeft, barRight, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
                            var left, right, bottom, top,
                                drawLeft, drawRight, drawTop, drawBottom,
                                tmp;
                
                
                Severity: Major
                Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

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

                      function drawSeriesErrors(plot, ctx, s){
                  
                          var points = s.datapoints.points,
                                  ps = s.datapoints.pointsize,
                                  ax = [s.xaxis, s.yaxis],
                  Severity: Major
                  Found in app/assets/javascripts/jquery.flot.errorbars.js - About 3 hrs to fix

                    Function init has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function init(plot) {
                            // This is kind of a hack. There are no hooks in Flot between
                            // the creation and measuring of the ticks (setTicks, measureTickLabels
                            // in setupGrid() ) and the drawing of the ticks and plot box
                            // (insertAxisLabels in setupGrid() ).
                    Severity: Major
                    Found in app/assets/javascripts/jquery.flot.axislabels.js - About 3 hrs to fix

                      Function onKeyDown has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              onKeyDown: function(e) {
                                  var isInput = e.target === this.$control_input[0];
                                  var self = this;
                          
                                  if (self.isLocked) {
                      Severity: Major
                      Found in app/assets/javascripts/alaveteli_pro/selectize.js - About 3 hrs to fix

                        Function setUpCorrespondenceCollapsing has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        var setUpCorrespondenceCollapsing = function(){
                          $('.js-collapsable').each(function(){
                            var $collapsable = $(this);
                            var $triggers = $(this).find('.js-collapsable-trigger');
                            var $correspondenceHeader = $(this).find('.correspondence__header');
                        Severity: Major
                        Found in app/assets/javascripts/correspondence-collapse.js - About 3 hrs to fix

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

                                  if (self.settings.options) {
                                      for (i = 0, n = self.settings.options.length; i < n; i++) {
                                          self.registerOption(self.settings.options[i]);
                                      }
                                      delete self.settings.options;
                          Severity: Major
                          Found in app/assets/javascripts/alaveteli_pro/selectize.js and 1 other location - About 3 hrs to fix
                          app/assets/javascripts/alaveteli_pro/selectize.js on lines 1192..1197

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

                          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

                                  if (self.settings.optgroups) {
                                      for (i = 0, n = self.settings.optgroups.length; i < n; i++) {
                                          self.registerOptionGroup(self.settings.optgroups[i]);
                                      }
                                      delete self.settings.optgroups;
                          Severity: Major
                          Found in app/assets/javascripts/alaveteli_pro/selectize.js and 1 other location - About 3 hrs to fix
                          app/assets/javascripts/alaveteli_pro/selectize.js on lines 1184..1189

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

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

                            def up
                              default_locale = AlaveteliLocalization.default_locale
                          
                              fields = {:title => :text,
                                        :description => :text}
                          Severity: Major
                          Found in db/migrate/20140716131107_create_category_translation_tables.rb - About 2 hrs to fix

                            Function findNearbyItem has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    function findNearbyItem(mouseX, mouseY, seriesFilter) {
                                        var maxDistance = options.grid.mouseActiveRadius,
                                            smallestDistance = maxDistance * maxDistance + 1,
                                            item = null, foundPoint = false, i, j, ps;
                            
                            
                            Severity: Major
                            Found in app/assets/javascripts/jquery.flot.js - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language