holderdeord/hdo-site

View on GitHub

Showing 302 of 302 total issues

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

      def import_proposition(xprop, vote = nil)
        log_import xprop
        xprop.validate!

        return if xprop.external_id == "-1" # https://github.com/holderdeord/hdo-site/issues/138
Severity: Minor
Found in lib/hdo/import/persister.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def update
        # 1. all input memberships reflect the current state and should be added
        # 2. if one intersects an existing membership in the same committee, we
        #    adjust it to reflect the new data.
        # 3. if an existing, current membership is not present in the new data, it is
Severity: Minor
Found in lib/hdo/import/committee_membership_updater.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 block has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    block: function(block) {
      var mustache = block.mustache,
          program = block.program,
          inverse = block.inverse;

Severity: Minor
Found in app/assets/javascripts/lib/handlebars-v1.3.0.js - About 1 hr to fix

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

          def result
            @result ||= (
              result = Hash.new { |hash, key| hash[key] = {count: 0, total: 0} }
              count  = 0
    
    
    Severity: Minor
    Found in lib/hdo/stats/agreement_scorer.rb - About 1 hr to fix

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

            def fetch
              payload = {}
              payload[:size] = size
      
              payload.merge! facets
      Severity: Minor
      Found in lib/hdo/search/facet_search.rb - About 1 hr to fix

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

              def generate_agreement_for_category
                category_name = ENV['CATEGORY_NAME'] || abort('must set CATEGORY_NAME')
        
                pis_by_session = Category.where(name: category_name).first.parliament_issues.group_by { |pi| pi.parliament_session_name }
        
        
        Severity: Minor
        Found in lib/hdo/import/cli.rb - About 1 hr to fix

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

                            if (!e.shiftKey){
                                $next = $next.data('tabindex') < $(this).data('tabindex') ?
                                    $next = $(this) :
                                    $rollover = $(this);
                              } else {
          Severity: Major
          Found in app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js on lines 141..145

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

          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

                              } else {
                                $next = $next.data('tabindex') > $(this).data('tabindex') ?
                                    $next = $(this) :
                                  $rollover = $(this);
                              }
          Severity: Major
          Found in app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js on lines 137..141

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

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

              show: function () {
                var that = this,
                  e = $.Event('show');
          
                if (this.isShown) return;
          Severity: Minor
          Found in app/assets/javascripts/twitter/bootstrap/bootstrap-modal.js - About 1 hr to fix

            Function _ProcessListItems has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function _ProcessListItems(list_str, list_type) {
                        //
                        //  Process the contents of a single ordered or unordered list, splitting it
                        //  into individual list items.
                        //
            Severity: Minor
            Found in app/assets/javascripts/lib/pagedown/Markdown.Converter.js - About 1 hr to fix

              Function swipeReset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _this.swipeReset = function(prevention) {
                  _this.callPlugins('onSwipeReset');
              
                  var getTranslate = isHorizontal ? _this.getTranslate('x') : _this.getTranslate('y');
                  var newPosition = getTranslate<0 ? Math.round(getTranslate/slideSize)*slideSize : 0
              Severity: Minor
              Found in app/assets/javascripts/lib/idangerous.swiper-1.8.7.js - About 1 hr to fix

                Function IdNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    IdNode: function(parts, locInfo) {
                      LocationInfo.call(this, locInfo);
                      this.type = "ID";
                
                      var original = "",
                Severity: Minor
                Found in app/assets/javascripts/lib/handlebars-v1.3.0.js - About 1 hr to fix

                  Function handleTrailingParens has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function handleTrailingParens(wholeMatch, lookbehind, protocol, link) {
                              if (lookbehind)
                                  return wholeMatch;
                              if (link.charAt(link.length - 1) !== ")")
                                  return "<" + protocol + link + ">";
                  Severity: Minor
                  Found in app/assets/javascripts/lib/pagedown/Markdown.Converter.js - About 1 hr to fix

                    Function doClick has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function doClick(button) {
                    
                                inputBox.focus();
                    
                                if (button.textOp) {
                    Severity: Minor
                    Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

                      Method vote has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def vote
                          @vote = Vote.find(params[:id])
                          @header = @vote.subject
                      
                          if params[:proposition]
                      Severity: Minor
                      Found in app/controllers/widgets_controller.rb - About 1 hr to fix

                        Function equals has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            equals: function(other) {
                              var len = this.opcodes.length;
                              if (other.opcodes.length !== len) {
                                return false;
                              }
                        Severity: Minor
                        Found in app/assets/javascripts/lib/handlebars-v1.3.0.js - About 1 hr to fix

                          Method update_index_on_change_of has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  def update_index_on_change_of(*classes)
                                    if classes.last.kind_of?(Hash)
                                      opts = classes.pop
                                    else
                                      opts = {}
                          Severity: Minor
                          Found in lib/hdo/search/index.rb - About 1 hr to fix

                            Function writeAnchorTag has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
                            Severity: Major
                            Found in app/assets/javascripts/lib/pagedown/Markdown.Converter.js - About 1 hr to fix

                              Function writeImageTag has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      function writeImageTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
                              Severity: Major
                              Found in app/assets/javascripts/lib/pagedown/Markdown.Converter.js - About 1 hr to fix

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

                                      this.timeout = setTimeout(function() {
                                        if (self.hoverState == 'in') self.show()
                                      }, self.options.delay.show)
                                app/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js on lines 93..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 55.

                                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