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
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
File base_claim_presenter.rb
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Claim::BaseClaimPresenter < BasePresenter
presents :claim
include InjectionAttemptErrorable
Class BaseFeeValidator
has 28 methods (exceeds 24 allowed). Consider refactoring. Open
class BaseFeeValidator < BaseValidator
def self.fields
%i[
amount
warrant_issued_date
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
- 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
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)
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
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?
- 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 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.
- 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 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)
- 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 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)
- 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 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
- 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 ==
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
- 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 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
- 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 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)
- 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 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)
- 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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(attribute, long_message, short_message, api_message, sequence = 99_999)
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: [],
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76