opengovernment/askthem

View on GitHub

Showing 154 of 154 total issues

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

      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

        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

              Function inclusion has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    inclusion: function(element, options) {
                      var lower, message, option, upper, _ref;
                      message = this.presence(element, options);
                      if (message) {
                        if (options.allow_blank === true) {
              Severity: Minor
              Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                  def show
                    @user = user_signed_in? ? current_user : User.new
                    if params[:code]
                      confirmed_question = Question.where(id: params[:id])
                                           .where(confirm_code: params[:code]).first
                Severity: Minor
                Found in app/controllers/questions_controller.rb - About 1 hr to fix

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

                            if (jQuery(this).data('tag-id') && jQuery(this).data('tag-id').length > 0) tagId = jQuery(this).data('tag-id');
                  Severity: Major
                  Found in public/widgets/widget-builder/widget.js and 3 other locations - About 1 hr to fix
                  public/widgets/address/widget.js on lines 176..176
                  public/widgets/person/widget.js on lines 176..176
                  public/widgets/zip/widget.js on lines 108..108

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

                  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 4 locations. Consider refactoring.
                  Open

                            if (jQuery(this).data('tag-id') && jQuery(this).data('tag-id').length > 0) tagId = jQuery(this).data('tag-id');
                  Severity: Major
                  Found in public/widgets/address/widget.js and 3 other locations - About 1 hr to fix
                  public/widgets/person/widget.js on lines 176..176
                  public/widgets/widget-builder/widget.js on lines 176..176
                  public/widgets/zip/widget.js on lines 108..108

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

                  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 4 locations. Consider refactoring.
                  Open

                            if (jQuery(this).data('tag-id') && jQuery(this).data('tag-id').length > 0) tagId = jQuery(this).data('tag-id');
                  Severity: Major
                  Found in public/widgets/person/widget.js and 3 other locations - About 1 hr to fix
                  public/widgets/address/widget.js on lines 176..176
                  public/widgets/widget-builder/widget.js on lines 176..176
                  public/widgets/zip/widget.js on lines 108..108

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

                  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 4 locations. Consider refactoring.
                  Open

                            if (jQuery(this).data('tag-id') && jQuery(this).data('tag-id').length > 0) tagId = jQuery(this).data('tag-id');
                  Severity: Major
                  Found in public/widgets/zip/widget.js and 3 other locations - About 1 hr to fix
                  public/widgets/address/widget.js on lines 176..176
                  public/widgets/person/widget.js on lines 176..176
                  public/widgets/widget-builder/widget.js on lines 176..176

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

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

                        exclusion: function(element, options) {
                          var lower, message, option, upper, _ref;
                          message = this.presence(element, options);
                          if (message) {
                            if (options.allow_blank === true) {
                  Severity: Minor
                  Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                      def cdn_image_tag(url, opts = {})
                        if opts[:size]
                          width, height = opts[:size].split('x')
                        else
                          width, height = opts[:width], opts[:height]
                    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 most_recent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def most_recent(attribute)
                        if read_attribute(attribute)
                          read_attribute(attribute)
                        else
                          read_attribute(:old_roles).to_a.reverse.each do |_, roles|
                    Severity: Minor
                    Found in app/models/person.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 set_candidates_if_referring_partner has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def set_candidates_if_referring_partner
                        return unless @has_partner
                    
                        extra_state_candidates = []
                        people_collections.each do |name, ids|
                    Severity: Minor
                    Found in app/controllers/pages_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

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

                          uniqueness: function(element, options) {
                            var form, matches, name, name_prefix, name_suffix, valid, value;
                            name = element.attr('name');
                            if (/_attributes\]\[\d/.test(name)) {
                              matches = name.match(/^(.+_attributes\])\[\d+\](.+)$/);
                    Severity: Minor
                    Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language