MakeYourLaws/MakeYourLaws

View on GitHub

Showing 56 of 56 total issues

Avoid deeply nested control flow statements.
Open

                for (j=0; j < files.length; j++) {
                    a.push({name: n, value: files[j], type: el.type});
                }
Severity: Major
Found in app/assets/javascripts/jquery.form.js - About 45 mins to fix
  • Create a ticket

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

      def identity_card identity, size = :slim
        div_for identity, class: size do
          content = provider_image identity.provider # , ((size == :slim) ? 16 : 32)
          content += content_tag :div, OmniAuth::Utils.camelize(identity.provider),
                                 class: 'provider_name' if size != :slim
    Severity: Minor
    Found in app/helpers/identities_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        notify = OffsitePayments::Integrations::PaypalAdaptivePayment::Notification.new(request.raw_post)
    
        @subtransaction = Payments::Paypal::Subtransaction.find_by_paypal_transaction_id(notify.params['txn_id']) ||
         Payments::Paypal::Subtransaction.find_by_paypal_transaction_id(notify.params['parent_txn_id'])
    Severity: Minor
    Found in app/controllers/paypal/transaction_notifications_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

    Avoid too many return statements within this function.
    Open

        return this;
    Severity: Major
    Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
    • Create a ticket

      Avoid too many return statements within this function.
      Open

          return $(el).val();
      Severity: Major
      Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
      • Create a ticket

        Avoid too many return statements within this function.
        Open

                return this;
        Severity: Major
        Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
        • Create a ticket

          Avoid too many return statements within this function.
          Open

                                  return;
          Severity: Major
          Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
          • Create a ticket

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

                    new_v = v.strip.chars.select { |i| i.valid_encoding? }.join # drop invalid UTF-8 chars
                    new_v = nil if new_v.blank? || %w(. NONE UNK 0).include?(new_v)
                    [k, new_v] if v != new_v
            Severity: Minor
            Found in app/models/fec/committee.rb and 1 other location - About 25 mins to fix
            app/models/fec/candidate.rb on lines 58..60

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

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

                    new_v = v.strip.chars.select { |i| i.valid_encoding? }.join # drop invalid UTF-8 chars
                    new_v = nil if new_v.blank? || %w(. NONE UNK 0).include?(new_v)
                    [k, new_v] if v != new_v
            Severity: Minor
            Found in app/models/fec/candidate.rb and 1 other location - About 25 mins to fix
            app/models/fec/committee.rb on lines 41..43

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

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

              def display_name
                if name
                  nickname ? "#{name} (#{nickname})" : name
                else
                  email || uid
            Severity: Minor
            Found in app/models/identity.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

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

              def method_missing page
                if Dir.glob(File.join(Rails.root, 'app', 'views', 'main', 'press', "#{page}.*")).blank?
                  head status: 404
                else
                  track! 'page load', page: page unless tor?
            Severity: Minor
            Found in app/controllers/main/press_controller.rb and 1 other location - About 25 mins to fix
            app/controllers/main/fec_controller.rb on lines 2..7

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

            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 method_missing page
                if Dir.glob(File.join(Rails.root, 'app', 'views', 'main', 'fec', "#{page}.*")).blank?
                  head status: 404
                else
                  track! 'page load', page: page unless tor?
            Severity: Minor
            Found in app/controllers/main/fec_controller.rb and 1 other location - About 25 mins to fix
            app/controllers/main/press_controller.rb on lines 2..7

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

            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

                  image_tag("authbuttons/#{provider.to_s.downcase.gsub(/[^a-z]/, '')}_#{size}.png",
                            alt: "#{OmniAuth::Utils.camelize provider}", size: "#{size}x#{size}")
            Severity: Minor
            Found in app/helpers/identities_helper.rb and 1 other location - About 20 mins to fix
            app/helpers/identities_helper.rb on lines 12..13

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

            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

                  image_tag("#{provider.to_s.downcase.gsub(/[^a-z]/, '')}_#{size}.png",
                            alt: "#{OmniAuth::Utils.camelize provider}", size: "#{size}x#{size}")
            Severity: Minor
            Found in app/helpers/identities_helper.rb and 1 other location - About 20 mins to fix
            app/helpers/identities_helper.rb on lines 9..10

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

            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 committee_params
                params.require(:committee).permit(:jurisdiction, :legal_id, :acronym, :short_name, :full_name,
                                                  :type, :foreign_contributions_okay, :corporation_full_name,
                                                  :corporation_acronym, :corporation_type, :corporation_ein,
                                                  :contact_name, :contact_title, :email, :phone, :url, :party,
            Severity: Minor
            Found in app/controllers/committees_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/initiatives_controller.rb on lines 43..49

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

            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 initiative_params
                params.require(:initiative).permit(:jurisdiction, :election_date, :filing_date, :summary_date,
                                                   :circulation_deadline, :full_check_deadline, :election_type,
                                                   :initiator_type, :initiative_type, :indirect,
                                                   :initiative_name, :proposition_name, :title,
            Severity: Minor
            Found in app/controllers/initiatives_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/committees_controller.rb on lines 43..48

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

            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