holderdeord/hdo-site

View on GitHub

Showing 302 of 302 total issues

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

      def each_parliament_issue(parliament_issues, limit = nil)
        count = 0

        parliament_issues.each_with_index do |parliament_issue, index|
          details = parsing_data_source.parliament_issue_details(parliament_issue.external_id)
Severity: Minor
Found in lib/hdo/import/cli.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

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

  function get(url, params, callbacks) {
    var options = getOptions.call(this, url, params);
    var cbs = getCallbacks.call(this, callbacks);
    JZ.ajax.get(options, cbs);
  }
Severity: Major
Found in app/assets/javascripts/lib/server-facade.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/lib/server-facade.js on lines 32..36
app/assets/javascripts/lib/server-facade.js on lines 44..48

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

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 getJSON(url, params, callbacks) {
    var options = getOptions.call(this, url, params);
    var cbs = getCallbacks.call(this, callbacks);
    JZ.ajax.getJSON(options, cbs);
  }
Severity: Major
Found in app/assets/javascripts/lib/server-facade.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/lib/server-facade.js on lines 32..36
app/assets/javascripts/lib/server-facade.js on lines 38..42

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

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

    loading: function (callback) {
      callback = callback || function () { };

      this.$element
        .toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
Severity: Minor
Found in app/assets/javascripts/twitter/bootstrap/bootstrap-modalmanager.js - About 1 hr to fix

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

      def auto_title
        title = plain_body.gsub("\n", " ")
    
        TITLE_RULES.each do |rx, replacement|
          title.sub!(rx, replacement)
    Severity: Minor
    Found in app/models/proposition.rb - About 1 hr to fix

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

            def import_api_representatives
              representatives = {}
              representatives_today = []
      
              # the information in 'representatives_today' is more complete,
      Severity: Minor
      Found in lib/hdo/import/cli.rb - About 1 hr to fix

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

            commandProto.doAutoindent = function (chunk, postProcessing) {
        
                var commandMgr = this,
                    fakeSelection = false;
        
        Severity: Minor
        Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

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

              Chunks.prototype.findTags = function (startRegex, endRegex) {
          
                  var chunkObj = this;
                  var regex;
          
          Severity: Minor
          Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

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

                    this.setInputAreaSelectionStartEnd = function () {
            
                        if (!panels.ieCachedRange && (inputArea.selectionStart || inputArea.selectionStart === 0)) {
            
                            stateObj.start = inputArea.selectionStart;
            Severity: Minor
            Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

              Method init has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.init
                    ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
                      event      = ActiveSupport::Notifications::Event.new(*args)
                      controller = event.payload[:controller]
                      action     = event.payload[:action]
              Severity: Minor
              Found in lib/hdo/instrumentation.rb - About 1 hr to fix

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

                        init: function (opts) {
                            var districtSelect, representativeSelect, representatives, selectedRepresentatives;
                
                            districtSelect       = opts.districtSelect;
                            representativeSelect = opts.representativeSelect;
                Severity: Minor
                Found in app/assets/javascripts/representativeSelector.js - About 1 hr to fix

                  Function handleCtrlYZ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          var handleCtrlYZ = function (event) {
                  
                              var handled = false;
                  
                              if ((event.ctrlKey || event.metaKey) && !event.altKey) {
                  Severity: Minor
                  Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

                    Function ProgramNode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        ProgramNode: function(statements, inverseStrip, inverse, locInfo) {
                          var inverseLocationInfo, firstInverseNode;
                          if (arguments.length === 3) {
                            locInfo = inverse;
                            inverse = null;
                    Severity: Minor
                    Found in app/assets/javascripts/lib/handlebars-v1.3.0.js - About 1 hr to fix

                      Function __module0__ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
                        "use strict";
                        var __exports__;
                        /*globals Handlebars: true */
                        var Handlebars = __dependency1__;
                      Severity: Minor
                      Found in app/assets/javascripts/lib/handlebars-v1.3.0.js - About 1 hr to fix

                        Function writeImageTag has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                function writeImageTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
                                    var whole_match = m1;
                                    var alt_text = m2;
                                    var link_id = m3.toLowerCase();
                                    var url = m4;
                        Severity: Minor
                        Found in app/assets/javascripts/lib/pagedown/Markdown.Converter.js - About 1 hr to fix

                          Function getPageSize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              position.getPageSize = function () {
                          
                                  var scrollWidth, scrollHeight;
                                  var innerWidth, innerHeight;
                          
                          Severity: Minor
                          Found in app/assets/javascripts/lib/pagedown/Markdown.Editor.js - About 1 hr to fix

                            Method autocomplete has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def autocomplete
                                response = Hdo::Search::Searcher.new(params[:query]).autocomplete
                                @results = []
                            
                                representative_icon = view_context.asset_path("representative.png")
                            Severity: Minor
                            Found in app/controllers/search_controller.rb - About 1 hr to fix

                              Method fetch_proposition_counts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def fetch_proposition_counts
                                  labels = []
                                  data   = []
                              
                                  result = {labels: labels, data: data}
                              Severity: Minor
                              Found in app/controllers/admin/dashboard_controller.rb - About 1 hr to fix

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

                                  def update
                                    update_issues || return
                                
                                    if @proposition.update_attributes(normalize_blanks(params[:proposition]))
                                      update_proposers
                                Severity: Minor
                                Found in app/controllers/admin/propositions_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 expand has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                      def expand(existing, membership)
                                        updates = {}
                                
                                        if membership.start_date < existing.start_date
                                          updates[:start_date] = membership.start_date
                                Severity: Minor
                                Found in lib/hdo/import/party_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

                                Severity
                                Category
                                Status
                                Source
                                Language