opengovernment/askthem

View on GitHub

Showing 84 of 154 total issues

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

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

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

      Method perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def perform(id)
          self.person = Person.find(id.to_s)
          return unless person.photo_url.present?
      
          unless ImageLinkChecker.new(person.photo_url).accessible?
      Severity: Minor
      Found in app/workers/person_check_photo_url_worker.rb - About 35 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 find_site_key_and_video_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_site_key_and_video_id
          VIDEO_SITE_URL_PATTERNS.each do |key, value|
            value.each do |pattern|
              if original_url =~ pattern
                key = :youtube_full if key == :youtube
      Severity: Minor
      Found in app/models/video_src_url.rb - About 35 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 state_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def state_name
          if state? || federal?
            @jurisdiction['name']
          elsif local?
            state = Metadatum.where(abbreviation: state_abbreviation).first
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def new
          new! do
            if params[:twitter_id]
              screen_name = params[:twitter_id]
              twitter_api = TwitterPersonService.new(screen_name, false)
      Severity: Minor
      Found in app/controllers/candidates_controller.rb - About 35 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 legacy_skip_for_now has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def legacy_skip_for_now(office, division)
          (office.level == "county" && (office.name.downcase != "mayor" &&
                                        !office.name.downcase.include?("council"))) ||
            (office.level == "federal" && division.scope == "national") ||
            ((office.level == "city" || office.level == "other") &&
      Severity: Minor
      Found in app/models/cached_officials_from_google.rb - About 35 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 most_recent_session has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def most_recent_session(type)
          session_details = read_attribute(:session_details)
          read_attribute(:terms).last["sessions"].reverse.each do |session|
            # OpenStates doesn't always declare the session type.
            return session if session_details[session].key?("type") && session_details[session]["type"] == type ||
      Severity: Minor
      Found in app/models/metadatum.rb - About 35 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 too many return statements within this function.
      Open

                  return;
      Severity: Major
      Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return options.message;
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return options.messages.odd;
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return options.messages.even;
            Severity: Major
            Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return options.messages[check];
              Severity: Major
              Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

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

                  def district_or_office_for(person)
                    district_or_office = person['district']
                
                    # reset if federal
                    if person.state == 'us'
                Severity: Minor
                Found in app/models/project_vote_smart_person_detail.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 jurisdiction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def jurisdiction(object)
                    if @jurisdiction
                      @jurisdiction
                    else
                      @jurisdictions ||= {}
                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 id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def id
                    raise "Must specify state" unless state
                    raise "Only municipality or county, not both" if municipality && county
                
                    id = state.downcase
                Severity: Minor
                Found in app/models/jurisdiction_id.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 jurisdiction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def jurisdiction
                      return jurisdiction_from_scope if legacy?
                
                      jurisdiction = state
                      if division.is_county?
                Severity: Minor
                Found in app/models/cached_officials_from_google.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