MakeYourLaws/MakeYourLaws

View on GitHub

Showing 56 of 56 total issues

Function ajaxSubmit has 544 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.ajaxSubmit = function(options) {
    /*jshint scripturl:true */

    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
    if (!this.length) {
Severity: Major
Found in app/assets/javascripts/jquery.form.js - About 2 days to fix
  • Create a ticket

    File jquery.form.js has 835 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * jQuery Form Plugin
     * version: 3.36.0-2013.06.16
     * @requires jQuery v1.5 or later
     * Copyright (c) 2013 M. Alsup
    Severity: Major
    Found in app/assets/javascripts/jquery.form.js - About 2 days to fix
    • Create a ticket

      Function fileUploadIframe has 360 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function fileUploadIframe(a) {
              var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
              var deferred = $.Deferred();
      
              if (a) {
      Severity: Major
      Found in app/assets/javascripts/jquery.form.js - About 1 day to fix
      • Create a ticket

        Method download_and_save has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.download_and_save record_number, record_type = 'C'
            case record_type
            when 'C'
              files_dir = Fec::Filing::FILES_DIR
              filing = Fech::Filing.new(record_number, Fec::Filing::FECH_OPTIONS.merge(download_dir: files_dir))
        Severity: Minor
        Found in app/models/fec/filing.rb - About 6 hrs 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 cb has 127 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function cb(e) {
                    if (xhr.aborted || callbackProcessed) {
                        return;
                    }
                    
        Severity: Major
        Found in app/assets/javascripts/jquery.form.js - About 5 hrs to fix
        • Create a ticket

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

            def self.update!
              # New years' "master" files may or may not include previous years' orgs. Bah.
              %w(80 82 84 86 88 90 92 94 96 98 00 02 04 06 08 10 12).each do |year|
                prev_mtime = File.mtime(File.join(FILES_DIR, "cm#{year}.zip")) rescue nil
                # wget -N preserves the ftp server's date
          Severity: Major
          Found in app/models/fec/committee.rb and 1 other location - About 4 hrs to fix
          app/models/fec/candidate.rb on lines 103..140

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

          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

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

            def self.update!
              %w(80 82 84 86 88 90 92 94 96 98 00 02 04 06 08 10 12).each do |year|
                prev_mtime = File.mtime(File.join(FILES_DIR, "cn#{year}.zip")) rescue nil
                # wget -N preserves the ftp server's date
                `cd #{FILES_DIR} && wget -N ftp://ftp.fec.gov/FEC#{year.to_i >= 80 ?
          Severity: Major
          Found in app/models/fec/candidate.rb and 1 other location - About 4 hrs to fix
          app/models/fec/committee.rb on lines 81..119

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

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

            def self.parsefile file
              while line = file.gets
                fields = []
                unless line == "\n"
                  loop do
          Severity: Minor
          Found in app/models/voter/ny.rb - About 3 hrs 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

              if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
                  (t == 'checkbox' || t == 'radio') && !el.checked ||
                  (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
                  tag == 'select' && el.selectedIndex == -1)) {
                      return null;
          Severity: Critical
          Found in app/assets/javascripts/jquery.form.js - About 3 hrs to fix
          • Create a ticket

            Function doSubmit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function doSubmit() {
                        // make sure form attrs are set
                        var t = $form.attr2('target'), a = $form.attr2('action');
            
                        // update form attrs in IE friendly way
            Severity: Major
            Found in app/assets/javascripts/jquery.form.js - About 2 hrs to fix
            • Create a ticket

              Method update! has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.update!
                  %w(80 82 84 86 88 90 92 94 96 98 00 02 04 06 08 10 12).each do |year|
                    prev_mtime = File.mtime(File.join(FILES_DIR, "cn#{year}.zip")) rescue nil
                    # wget -N preserves the ftp server's date
                    `cd #{FILES_DIR} && wget -N ftp://ftp.fec.gov/FEC#{year.to_i >= 80 ?
              Severity: Minor
              Found in app/models/fec/candidate.rb - About 2 hrs 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 update! has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.update!
                  # New years' "master" files may or may not include previous years' orgs. Bah.
                  %w(80 82 84 86 88 90 92 94 96 98 00 02 04 06 08 10 12).each do |year|
                    prev_mtime = File.mtime(File.join(FILES_DIR, "cm#{year}.zip")) rescue nil
                    # wget -N preserves the ftp server's date
              Severity: Minor
              Found in app/models/fec/committee.rb - About 2 hrs 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 update_database has a Cognitive Complexity of 21 (exceeds 5 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 2 hrs 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 fix_errors has a Cognitive Complexity of 20 (exceeds 5 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 2 hrs 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 download_and_save has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.download_and_save record_number, record_type = 'C'
                  case record_type
                  when 'C'
                    files_dir = Fec::Filing::FILES_DIR
                    filing = Fech::Filing.new(record_number, Fec::Filing::FECH_OPTIONS.merge(download_dir: files_dir))
              Severity: Major
              Found in app/models/fec/filing.rb - About 2 hrs to fix
              • Create a ticket

                Function formToArray has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                $.fn.formToArray = function(semantic, elements) {
                    var a = [];
                    if (this.length === 0) {
                        return a;
                    }
                Severity: Major
                Found in app/assets/javascripts/jquery.form.js - About 2 hrs to fix
                • Create a ticket

                  Method create has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 by_omniauth has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 fileUploadXhr has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function fileUploadXhr(a) {
                          var formdata = new FormData();
                  
                          for (var i=0; i < a.length; i++) {
                              formdata.append(a[i].name, a[i].value);
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.form.js - About 1 hr to fix
                  • Create a ticket

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

                      def validate_password_strength
                        # only set if setting the password; it's stored as encrypted_password
                        return true unless password_required?
                    
                        errors.add :password_confirmation, 'must match' unless password == password_confirmation
                    Severity: Minor
                    Found in app/models/user.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

                    Severity
                    Category
                    Status
                    Source
                    Language