ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub

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

          Identical blocks of code found in 2 locations. 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: Major
          Found in app/models/claim/advocate_claim.rb and 1 other location - About 1 hr to fix
          app/models/claim/advocate_hardship_claim.rb on lines 148..158

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

          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

              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: Major
          Found in app/models/claim/advocate_hardship_claim.rb and 1 other location - About 1 hr to fix
          app/models/claim/advocate_claim.rb on lines 171..181

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

          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

          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 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 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 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 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 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 == 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 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 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

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

                    def has_many_association_names_for_steps
                      {
                        case_details: [],
                        defendants: [{ name: :defendants, options: { presence: true } }],
                        offence_details: [],
                app/validators/claim/litigator_claim_sub_model_validator.rb on lines 14..23

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

                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