ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub

Showing 38 of 66 total issues

Class BaseClaimPresenter has 79 methods (exceeds 24 allowed). Consider refactoring.
Open

class Claim::BaseClaimPresenter < BasePresenter
  presents :claim

  include InjectionAttemptErrorable

Severity: Major
Found in app/presenters/claim/base_claim_presenter.rb - About 1 day to fix

    Class BaseClaimValidator has 53 methods (exceeds 24 allowed). Consider refactoring.
    Open

      class BaseClaimValidator < BaseValidator
        def self.mandatory_fields
          %i[external_user_id creator amount_assessed evidence_checklist_ids earliest_representation_order_date]
        end
    
    
    Severity: Major
    Found in app/validators/claim/base_claim_validator.rb - About 6 hrs to fix

      File base_claim_presenter.rb has 323 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Claim::BaseClaimPresenter < BasePresenter
        presents :claim
      
        include InjectionAttemptErrorable
      
      
      Severity: Minor
      Found in app/presenters/claim/base_claim_presenter.rb - About 3 hrs to fix

        Class BaseFeeValidator has 28 methods (exceeds 24 allowed). Consider refactoring.
        Open

          class BaseFeeValidator < BaseValidator
            def self.fields
              %i[
                amount
                warrant_issued_date
        Severity: Minor
        Found in app/validators/fee/base_fee_validator.rb - About 2 hrs to fix

          Method update_and_transition_state has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_and_transition_state
                event = Claims::InputEventMapper.input_event(state)
          
                claim.class.transaction do
                  update_assessment if assessment_params
          Severity: Minor
          Found in app/services/claims/case_worker_claim_updater.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

          Consider simplifying this complex logical expression.
          Open

                if ((isNaN(min) && isNaN(max)) ||
                  (isNaN(min) && claimAmount <= max) ||
                  (min <= claimAmount && isNaN(max)) ||
                  (min <= claimAmount && claimAmount <= max)) {
                  return true
          Severity: Critical
          Found in app/webpack/javascripts/modules/Modules.AllocationDataTable.js - About 1 hr to fix

            Method search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def search(term, states = [], *options)
                raise 'Invalid search option' if (options - QUERY_MAPPINGS_FOR_SEARCH.keys).any?
                term = term.to_s.strip.downcase
            
                if term.present?
            Severity: Minor
            Found in app/models/claims/search.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_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate_resource(model_klass, api_response, arg_builder_proc)
                      #
                      # basic fees (which are instantiated at claim creation)
                      # must be updated if they already exist.
                      # all other model class instances must be created.
            Severity: Minor
            Found in app/interfaces/api/helpers/api_helper.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 soft_delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def soft_delete
                  transaction do
                    before_soft_delete if respond_to?(:before_soft_delete)
                    result = if is_a?(Claim::BaseClaim)
                               update_attribute(:deleted_at, Time.zone.now)
            Severity: Minor
            Found in app/models/concerns/softly_deletable.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_fee_rate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate_fee_rate(code = nil)
                  if @record.quantity.positive? && @record.rate <= 0
                    add_error(:rate, code ? :"#{code.downcase}_invalid" : :invalid)
                  elsif @record.quantity <= 0 && @record.rate.positive?
                    add_error(:quantity, code ? :"#{code.downcase}_invalid" : :invalid)
            Severity: Minor
            Found in app/validators/fee/base_fee_validator.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 equal_for_scheme_ten has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def equal_for_scheme_ten(other)
                    return true unless other.fee_scheme_version == 10
                    return false if elected_case
            
                    if other.elected_case
            Severity: Minor
            Found in app/models/claim/transfer_brain/data_item.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 instantiate_basic_fees has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def instantiate_basic_fees
                  return unless case_type.present? && !case_type.is_fixed_fee?
                  return unless editable?
            
                  fee_type_ids = basic_fees.map(&:fee_type_id)
            Severity: Minor
            Found in app/models/claim/advocate_claim.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 == has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def ==(other)
                    return false unless litigator_type == other.litigator_type
                    return false unless equal_for_scheme_nine(other)
                    return false unless equal_for_scheme_ten(other)
                    return false unless transfer_stage_id == other.transfer_stage_id
            Severity: Minor
            Found in app/models/claim/transfer_brain/data_item.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 instantiate_basic_fees has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def instantiate_basic_fees
                  return unless case_type.present? && !case_type.is_fixed_fee?
                  return unless editable?
            
                  fee_type_ids = basic_fees.map(&:fee_type_id)
            Severity: Minor
            Found in app/models/claim/advocate_hardship_claim.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(object)
                  @error_messages = []
            
                  if VALID_MODEL_KLASSES.include?(object.class)
                    @model = object
            Severity: Minor
            Found in app/interfaces/api/error_response.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(attribute, long_message, short_message, api_message, sequence = 99_999)
            Severity: Minor
            Found in app/presenters/error_message/detail.rb - About 35 mins to fix

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
              Severity: Minor
              Found in lib/email_notification_cli.rb - About 35 mins to fix

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

                      def equal_for_scheme_nine(other)
                        return true unless other.fee_scheme_version == 9
                        return false unless elected_case == other.elected_case
                        return false unless elected_case || conclusion == other.conclusion
                
                
                Severity: Minor
                Found in app/models/claim/transfer_brain/data_item.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 test_editability has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def test_editability(model_instance)
                          return unless fee_classes.include?(model_instance.class)
                          model_instance.errors.add(:base, 'uneditable_state') unless model_instance.claim.editable?
                        rescue StandardError
                          true
                Severity: Minor
                Found in app/interfaces/api/helpers/api_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 validate_mileage_rate_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def validate_mileage_rate_id
                    if @record.car_travel? || @record.bike_travel?
                      validate_presence(:mileage_rate_id, :blank)
                      if @record.mileage_rate_id.present? && (car_travel_missing_milage_rates || bike_travel_missing_milage_rates)
                        add_error(:mileage_rate_id, :invalid)
                Severity: Minor
                Found in app/validators/expense_validator.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

                Severity
                Category
                Status
                Source
                Language