app/validators/claim/base_claim_validator.rb
Class BaseClaimValidator
has 53 methods (exceeds 24 allowed). Consider refactoring. Open
Open
class BaseClaimValidator < BaseValidator
def self.mandatory_fields
%i[external_user_id creator amount_assessed evidence_checklist_ids earliest_representation_order_date]
end
File base_claim_validator.rb
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
Wontfix
module Claim
class BaseClaimValidator < BaseValidator
def self.mandatory_fields
%i[external_user_id creator amount_assessed evidence_checklist_ids earliest_representation_order_date]
end
Method validate_retrial_start_and_end
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_retrial_start_and_end(start_attribute, end_attribute, inverse: false)
return unless @record&.requires_retrial_dates?
start_attribute, end_attribute = end_attribute, start_attribute if inverse
# TODO: this condition is a temproary workaround for live data that existed prior to addition of retrial details
validate_presence(start_attribute, :blank) if @record.editable?
- Read upRead up
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 step_fields_for_validation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def step_fields_for_validation
# NOTE: keeping existent validation for API purposes
# The form validations just validate the fields for the current step
return self.class.fields_for_steps[@record.form_step] || [] unless @record.from_api? || @record.form_step.nil?
return self.class.fields_for_steps.values.flatten if !@record.from_api? && @record.form_step.nil?
- Read upRead up
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"