opengovernment/askthem

View on GitHub

Showing 154 of 154 total issues

Function length has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      length: function(element, options) {
        var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
        tokenizer = options.js_tokenizer || "split('')";
        tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
        CHECKS = {
Severity: Minor
Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

      function addMetaTags(tagId, options) {
        this._createMetaTag = function(name, content) {
          var metaTag = jQuery("<meta>", {
            name: name,
            content: content
    Severity: Minor
    Found in public/widgets/person/widget.js - About 1 hr to fix

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

        function addMetaTags(tagId, options) {
          this._createMetaTag = function(name, content) {
            var metaTag = jQuery("<meta>", {
              name: name,
              content: content
      Severity: Minor
      Found in public/widgets/address/widget.js - About 1 hr to fix

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

          function addMetaTags(tagId, options) {
            this._createMetaTag = function(name, content) {
              var metaTag = jQuery("<meta>", {
                name: name,
                content: content
        Severity: Minor
        Found in public/widgets/widget-builder/widget.js - About 1 hr to fix

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

            def self.for_location(location)
              location = LocationFormatter.new(location).format
              return where(id: []) unless location
          
              city = location.city
          Severity: Major
          Found in app/models/councilmember.rb and 1 other location - About 1 hr to fix
          app/models/mayor.rb on lines 2..13

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

          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

            def self.for_location(location)
              location = LocationFormatter.new(location).format
              return where(id: []) unless location
          
              city = location.city
          Severity: Major
          Found in app/models/mayor.rb and 1 other location - About 1 hr to fix
          app/models/councilmember.rb on lines 8..18

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

          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 person_match_official? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def person_match_official?(person, official)
              return false unless district_or_office_for(person) ==
                pvs_district_or_office_for(official)
          
              return false unless NameComparison.new(comparable_family_name_for(person),
          Severity: Minor
          Found in app/models/project_vote_smart_person_detail.rb - About 55 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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def run(twitter_user)
              data = twitter_user.as_json
          
              data.each do |key, value|
                case key
          Severity: Minor
          Found in lib/twitter_person_adapter.rb - About 55 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 tab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def tab(tab)
              @governor = Governor.connected_to(@jurisdiction.abbreviation).active.first
              @mayor = Mayor.connected_to(@jurisdiction.abbreviation).active.first ||
                Councilmember.connected_to(@jurisdiction.abbreviation).active
                .where(district: "Mayor").first
          Severity: Minor
          Found in app/controllers/pages_controller.rb - About 55 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 match_to_person has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def match_to_person
              if person_id.present?
                add_attributes_to(person)
                return person
              end
          Severity: Minor
          Found in app/models/cached_official.rb - About 55 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 set_attributes_based_on_partner has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_attributes_based_on_partner
              return unless referring_partner_info.present?
              return if persisted?
          
              self.password = Devise.friendly_token.first(6)
          Severity: Minor
          Found in app/models/user.rb - About 55 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 new_with_session has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.new_with_session(params, session)
              super.tap do |user|
                data = session['devise.facebook_data']
                if data
                  user.email = data['info']['email'] if user.email.blank?
          Severity: Minor
          Found in app/models/user.rb - About 45 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

          Avoid deeply nested control flow statements.
          Open

                            if ($(this).data('notLocallyUnique')) {
                              return $(this).removeData('notLocallyUnique').data('changed', true);
                            }
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 45 mins to fix

            Method show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def show
                self.resource = resource_class.confirm_by_token(params[:confirmation_token])
            
                if resource.errors.empty?
                  set_flash_message(:notice, :confirmed) if is_navigational_format?
            Severity: Minor
            Found in app/controllers/confirmations_controller.rb - About 45 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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def show
                @blurb = Blurb.active.where(target_url: person_path(parent, resource)).first
                @questions = resource.questions.in(needs_confirmation: [nil, false])
                             .includes(:user).desc(:created_at).page(params[:page])
                tab "questions"
            Severity: Minor
            Found in app/controllers/people_controller.rb - About 45 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 officials_by_state_and_office has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def officials_by_state_and_office(state_id, office_ids)
                office_ids.each_with_index do |office_id, index|
                  begin
                    state_id = state_id == 'us' ? 'NA' : state_id.upcase
                    return get('Officials.getByOfficeState',
            Severity: Minor
            Found in lib/project_vote_smart.rb - About 45 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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def perform(id)
                question = Question.find(id)
                user = question.user
            
                if user && question.coordinates.blank?
            Severity: Minor
            Found in app/workers/question_coordinates_worker.rb - About 45 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 office_ids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def office_ids(options)
                # Chairman, Councilmember
                return [347, 368] if options[:state] == 'dc'
            
                office_ids = []
            Severity: Minor
            Found in lib/project_vote_smart.rb - About 45 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

            Consider simplifying this complex logical expression.
            Open

                  return session if session_details[session].key?("type") && session_details[session]["type"] == type ||
                    type == "primary" && !session_details[session]["display_name"][/Budget|Called|Extraordinary|Fiscal|Special/] ||
                    type == "special" &&  session_details[session]["display_name"][/Budget|Called|Extraordinary|Fiscal|Special/]
            Severity: Major
            Found in app/models/metadatum.rb - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                    if (width.blank? || height.blank?) ||
                      (opts[:state] && opts[:state] == Metadatum::Unaffiliated::ABBREVIATION) ||
                      api_key.blank? ||
                      Rails.env.development?
              
              
              Severity: Major
              Found in app/helpers/application_helper.rb - About 40 mins to fix
                Severity
                Category
                Status
                Source
                Language