MakeYourLaws/MakeYourLaws

View on GitHub

Showing 56 of 56 total issues

Method fix_errors has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.fix_errors record_type = 'C', recs = []
    if record_type == 'C'
      files_dir = FILES_DIR
    elsif record_type == 'S'
      files_dir = SENATE_FILES_DIR
Severity: Minor
Found in app/models/fec/filing.rb - About 1 hr to fix
  • Create a ticket

    Method search has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.search search
        search.update_attribute :status, 'processing'
        begin
          [
            lambda do |s|
    Severity: Minor
    Found in app/models/tweet.rb - About 1 hr to fix
    • Create a ticket

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

        def self.new_from_line line
          new change_type:        (line[0].blank? ? nil : line[0]),
              ssn:                line[1..9].to_i,
              last_name:          (line[10..29].blank? ? nil : line[10..29].strip),
              name_suffix:        (line[30..33].blank? ? nil : line[30..33].strip),
      Severity: Minor
      Found in app/models/govt/ssn_death_record.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 validate_each has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_each object, attribute, value
          # alternate format:
          # /(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix
          configuration = { nonresponse_message: 'is invalid or not responding',
            bad_format_message: 'does not appear to be a valid URI', nil_message: 'is not present',
      Severity: Minor
      Found in app/validators/uri_validator.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 fieldValue has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      $.fieldValue = function(el, successful) {
          var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
          if (successful === undefined) {
              successful = true;
          }
      Severity: Minor
      Found in app/assets/javascripts/jquery.form.js - About 1 hr to fix
      • Create a ticket

        Function footnoteover has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            footnoteover: function() {
                clearTimeout(Footnotes.footnotetimeout);
                $('#footnotediv').stop();
                $('#footnotediv').remove();
                
        Severity: Minor
        Found in app/assets/javascripts/footnotes.js - About 1 hr to fix
        • Create a ticket

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

            def self.by_omniauth auth
              uid = (auth.provider == 'coinbase' ? auth.info.id  : auth.uid)
              id = Identity.find_or_initialize_by(provider: auth.provider, uid: uid)
          
              %w(name email nickname first_name last_name location description image phone urls).each do |x|
          Severity: Minor
          Found in app/models/identity.rb - About 1 hr to fix
          • Create a ticket

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

              def self.update_database record_type = 'C'
                if record_type == 'C'
                  record_number = Fec::Filing::Hdr.maximum(:fec_record_number) || Fech::Filing::FIRST_V3_FILING
                  record_number -= 4
                  files_dir = Fec::Filing::FILES_DIR
            Severity: Minor
            Found in app/models/fec/filing.rb - About 1 hr to fix
            • Create a ticket

              Method import_file has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.import_file filename
                  file = File.open filename, encoding: 'UTF-8'
                  batch = []
                  columns = column_names[1..-4] # id ... lock, created, updated
              
              
              Severity: Minor
              Found in app/models/voter/ny.rb - About 1 hr to fix
              • Create a ticket

                Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def create
                    build_resource(sign_up_params)
                
                    if session['devise.identity'] && identity = Identity.find(session['devise.identity'])
                      resource.identities << identity
                Severity: Minor
                Found in app/controllers/users/registrations_controller.rb - About 1 hr to fix
                • Create a ticket

                  Method charge has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def charge options
                      fail ArgumentError unless options[:amount] >= 50 && # 50 cents minimum
                        (!!options[:token] ^ !!options[:customer]) # boolean-coerced xor
                  
                      begin
                  Severity: Minor
                  Found in app/models/payments/stripe/charge.rb - About 1 hr to fix
                  • Create a ticket

                    Method update_with_password has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update_with_password params, *options
                        current_password = params.delete(:current_password)
                    
                        if params[:password].blank?
                          params.delete(:password)
                    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 search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.search search
                        search.update_attribute :status, 'processing'
                        begin
                          [
                            lambda do |s|
                    Severity: Minor
                    Found in app/models/tweet.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 sanitize_date has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.sanitize_date date
                        return [nil, nil] if date.to_i == 0 || date.blank? || date.to_i == 1900
                    
                        # Format: MMDDYYYY
                        error, month, day, year = nil, date[0..1].to_i, date[2..3].to_i, date[4..7].to_i
                    Severity: Minor
                    Found in app/models/govt/ssn_death_record.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 (elements)
                                    elements.push(el);
                    Severity: Major
                    Found in app/assets/javascripts/jquery.form.js - About 45 mins to fix
                    • Create a ticket

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

                        def self.import_from_file filename, after = 0
                          file = File.open(filename, 'r')
                          batch = []
                          while line = file.gets
                            fail 'Unknown data' unless line[81..-1].blank?
                      Severity: Minor
                      Found in app/models/govt/ssn_death_record.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

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

                                      a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
                      Severity: Minor
                      Found in app/assets/javascripts/jquery.form.js and 1 other location - About 45 mins to fix
                      app/assets/javascripts/jquery.form.js on lines 941..941

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

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

                        def self.add_with_hint short, long = nil
                          bestlink = nil
                          shortlink = Link.add_by_url(short)
                          if long
                            uncoiled = Uncoil.expand(long).long_url
                      Severity: Minor
                      Found in app/models/link.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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.get name, environment = nil
                          environment ||= (defined?(Rails) ? Rails.env : 'production')
                      
                          file = File.join(@keys_dir, name + '.' + environment)
                          file = File.join(@keys_dir, name) unless File.exist?(file)
                      Severity: Minor
                      Found in lib/keys.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

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

                                  a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
                      Severity: Minor
                      Found in app/assets/javascripts/jquery.form.js and 1 other location - About 45 mins to fix
                      app/assets/javascripts/jquery.form.js on lines 901..901

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language