holderdeord/hdo-site

View on GitHub

Showing 195 of 302 total issues

Avoid too many return statements within this method.
Open

            return
Severity: Major
Found in lib/hdo/import/persister.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return
    Severity: Major
    Found in lib/hdo/import/persister.rb - About 30 mins to fix

      Method awesome_truncate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def awesome_truncate(text, length = 30, truncate_string = "...")
          return if text.nil?
          l = length - truncate_string.chars.to_a.size
          text.chars.to_a.size > length ? text[/\A.{#{l}}\w*\;?/m][/.*[\w\;]/m] + truncate_string : text
        rescue => ex
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 25 mins 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 vote has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 age has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def age
          dob = date_of_birth or return -1
      
          if date_of_death
            now = date_of_death
      Severity: Minor
      Found in app/models/representative.rb - About 25 mins 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 bind has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          Function.prototype.bind = function (oThis) {
              if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 internal IsCallable function
                  throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable");
              }
              var aArgs = Array.prototype.slice.call(arguments, 1),
      Severity: Minor
      Found in app/assets/javascripts/lib/function.bind.js - About 25 mins 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 transitionEnd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        transitionEnd : function(callback) {
          var a = this
          var el = a.wrapper
          var events = ['webkitTransitionEnd','transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
          if (callback) {
      Severity: Minor
      Found in app/assets/javascripts/lib/idangerous.swiper-1.8.7.js - About 25 mins 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 autocomplete has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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_issues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_issues
          issues = Array(params[:proposition].delete(:issues))
          issues.each do |issue_id|
            next if issue_id.empty?
      
      
      Severity: Minor
      Found in app/controllers/admin/propositions_controller.rb - About 25 mins 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_or_create_promise_connection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_or_create_promise_connection(promise_id, data)
            existing = PromiseConnection.where(promise_id: promise_id, issue_id: @issue.id).first
            status   = data.fetch(:status)
      
            if status == 'unrelated'
      Severity: Minor
      Found in lib/hdo/issue_updater.rb - About 25 mins 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 search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def search
              q = {}
      
              query_string = params[:q].present? ? params[:q] : '*'
      
      
      Severity: Minor
      Found in lib/hdo/search/admin_proposition_search.rb - About 25 mins 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 import_api_representatives has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 handle_intersections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def handle_intersections(intersections, membership)
              if intersections.size == 1
                existing = intersections.first
      
                if existing.party == party_for(membership)
      Severity: Minor
      Found in lib/hdo/import/party_membership_updater.rb - About 25 mins 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 parse_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_options(args)
              options = {
                :period  => ParliamentPeriod.current ? ParliamentPeriod.current.external_id : nil,
                :session => ParliamentSession.current ? ParliamentSession.current.external_id : nil
              }
      Severity: Minor
      Found in lib/hdo/import/cli.rb - About 25 mins 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 distance_between has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def distance_between(cluster,other)
            if Array === cluster
              if Array === other
                distance_between_array_and_array cluster, other
              else
      Severity: Minor
      Found in lib/hdo/one_dimensional_hierarchical_clusterer.rb - About 25 mins 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