18F/e-manifest

View on GitHub

Showing 12 of 761 total issues

Class UserSession has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class UserSession
  attr_reader :session, :token

  TTL = 4 * 60 * 60
  @@ttl = TTL
Severity: Minor
Found in app/services/user_session.rb - About 3 hrs to fix

    Class Manifest has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Manifest < ActiveRecord::Base
      include Searchable
    
      validate :tracking_number, :validate_tracking_number_unique
      validates :user_id, presence: true
    Severity: Minor
    Found in app/models/manifest.rb - About 3 hrs to fix

      Class QueryDSL has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class QueryDSL
          include Elasticsearch::DSL
      
          MAX_RESULTS = 100
      
      
      Severity: Minor
      Found in app/search/query_dsl.rb - About 2 hrs to fix

        Method us_states has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def us_states
            [
              ['Alabama', 'AL'],
              ['Alaska', 'AK'],
              ['Arizona', 'AZ'],
        Severity: Major
        Found in app/helpers/states_helper.rb - About 2 hrs to fix

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

              def to_h
                hash = {}
                if field_pairs
                  field_pairs.each do |k, v|
                    next if v.nil?
          Severity: Minor
          Found in app/search/fielded_query.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 to_s has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_s
                clauses = []
                if field_pairs
                  field_pairs.each do |k, v|
                    next if v.nil?
          Severity: Minor
          Found in app/search/fielded_query.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 deep_reject! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def deep_reject!(hash, &block)
              hash.each do |k, v|
                if (v.is_a?(Hash) || v.is_a?(ActionController::Parameters))
                  deep_reject!(v, &block)
                elsif v.is_a?(Array)
          Severity: Minor
          Found in app/controllers/concerns/manifest_params.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 mexican_states has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def mexican_states
              [
                ['Aguascalientes', 'MX - AG'],
                ['Baja California', 'MX - BN'],
                ['Baja California Sur', 'MX - BS'],
          Severity: Minor
          Found in app/helpers/states_helper.rb - About 1 hr to fix

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

              def profile_field(json_xpath)
                fields = json_xpath.split('.')
                if profile && fields.inject(profile) { |h,k| h[k] if h } 
                  fields.inject(profile) { |h,k| h[k] if h } 
                end 
            Severity: Minor
            Found in app/models/concerns/json_profile.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 content_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def content_field(json_xpath)
                fields = json_xpath.split('.')
                if content && fields.inject(content) { |h,k| h[k] if h }
                  fields.inject(content) { |h,k| h[k] if h }
                end
            Severity: Minor
            Found in app/models/manifest.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                authenticate_user!
            
                unless performed?
                  @manifest = Manifest.new(content: manifest_params, user: current_user)
            Severity: Minor
            Found in app/controllers/manifests_controller.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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def show
                manifest = find_manifest
                if has_permission_to_view?(manifest)
                  unless performed?
                    render json: ManifestSerializer.new(manifest).to_json
            Severity: Minor
            Found in app/controllers/api/v0/manifests_controller.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