opengovernment/askthem

View on GitHub

Showing 84 of 154 total issues

Method type has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def type
    @type ||=
      case office_level
      when "city", "other"
        case division_scope.downcase
Severity: Minor
Found in app/models/cached_official.rb - About 1 hr to fix

    Method add_attributes_to has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def add_attributes_to(person)
        unless person.read_attribute(:ocd_division_id)
          person.write_attribute(:ocd_division_id, ocd_division_id)
        end
    
    
    Severity: Minor
    Found in app/models/cached_official.rb - About 1 hr to fix

      Function numericality has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            numericality: function(element, options) {
              var CHECKS, check, check_value, fn, form, operator, val;
              val = jQuery.trim(element.val());
              if (!ClientSideValidations.patterns.numericality.test(val)) {
                if (options.allow_blank === true && this.presence(element, {
      Severity: Minor
      Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

        Function main has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function main() {
            jQuery(document).ready(function($) {
              // We can use jQuery here
        
              // load css, only if it hasn't been loaded
        Severity: Minor
        Found in public/widgets/widget-builder/widget.js - About 1 hr to fix

          Function form has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              form: function(form) {
                var $form, binding, event, _ref;
                $form = $(form);
                form.ClientSideValidations = {
                  settings: window.ClientSideValidations.forms[$form.attr('id')],
          Severity: Minor
          Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

            Function autogrow has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                $.fn.autogrow = function(options)
                {
                    return this.filter('textarea').each(function()
                    {
                        var self         = this;
            Severity: Minor
            Found in app/assets/javascripts/jquery.autogrow-textarea.js - About 1 hr to fix

              Method translate_arguments has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def translate_arguments
                  @translate_arguments ||= begin
                    args = {}
              
                    if @jurisdiction
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 1 hr to fix

                Method roles_from_api has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def roles_from_api(terms)
                    write_attribute(:roles, []) unless read_attribute(:roles)
                
                    terms.each do |term|
                      role = { term_years: [] }
                Severity: Minor
                Found in lib/sunlight_congress_legislator_adapter.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 guess_division_scope has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def guess_division_scope(office, division)
                    if office.is_governor? ||
                        (office.is_federal_legislator? &&
                         office.roles.include?("legislatorUpperBody"))
                      GoogleCivicInfo::Division::STATEWIDE
                Severity: Minor
                Found in app/models/cached_officials_from_google.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 tab has 38 lines of code (exceeds 25 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 1 hr to fix

                  Method og_image_tag has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def og_image_tag
                      urls = ["http://www.askthem.io/assets/mark.png"]
                  
                      if @question
                        if @question.media.present? && is_image?(@question.media.url)
                  Severity: Minor
                  Found in app/helpers/application_helper.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 people_and_committee_sponsors has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def people_and_committee_sponsors(opts = {})
                      sponsors = read_attribute(:sponsors)
                      case opts[:only]
                      when :people
                        sponsors.select!{|x| x['leg_id']}
                  Severity: Minor
                  Found in app/models/bill.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 htmlTemplate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function htmlTemplate(tagId, options) {
                      headline = options.headline;
                      summary = options.questionSummary;
                      body = options.questionBody;
                      name = options.partner.name;
                  Severity: Minor
                  Found in public/widgets/zip/widget.js - About 1 hr to fix

                    Method people_and_committee_sponsors has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def people_and_committee_sponsors(opts = {})
                        sponsors = read_attribute(:sponsors)
                        case opts[:only]
                        when :people
                          sponsors.select!{|x| x['leg_id']}
                    Severity: Minor
                    Found in app/models/bill.rb - About 1 hr to fix

                      Method copy_to_new_person has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def copy_to_new_person
                          unless Metadatum.where(id: state).first
                            copy_to_new_metadatum
                          end
                      
                      
                      Severity: Minor
                      Found in app/models/cached_official.rb - About 1 hr to fix

                        Function inWords has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            inWords: function(distanceMillis) {
                              var $l = this.settings.strings;
                              var prefix = $l.prefixAgo;
                              var suffix = $l.suffixAgo;
                              if (this.settings.allowFuture) {
                        Severity: Minor
                        Found in app/assets/javascripts/jquery.timeago.js - About 1 hr to fix

                          Method roles_from_api has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def roles_from_api(terms)
                              write_attribute(:roles, []) unless read_attribute(:roles)
                          
                              terms.each do |term|
                                role = { term_years: [] }
                          Severity: Minor
                          Found in lib/sunlight_congress_legislator_adapter.rb - About 1 hr to fix

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

                              def sentence(person = nil, metadatum = nil)
                                if ratingText?
                                  person ||= self.person # avoid N+1 query
                                  metadatum ||= self.metadatum # avoid N+1 query
                                  sentence = ratingText
                            Severity: Minor
                            Found in app/models/rating.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 local_jurisdiction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def local_jurisdiction
                                return @local_jurisdiction if @local_jurisdiction
                                if @jurisdiction && @jurisdiction.id.include?("-")
                                  return @local_jurisdiction = @jurisdiction
                                end
                            Severity: Minor
                            Found in app/controllers/application_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 get has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def get(endpoint, params = {})
                                begin
                                  result = JSON.parse(RestClient.get("http://api.votesmart.org/#{endpoint}", params: params.merge(key: @api_key, o: 'JSON')))
                            
                                  if result['error']
                            Severity: Minor
                            Found in lib/project_vote_smart.rb - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language