opengovernment/askthem

View on GitHub

Showing 84 of 154 total issues

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

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

        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

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

            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

              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

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

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

                    Severity
                    Category
                    Status
                    Source
                    Language