File user.rb
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.join(Rails.root, 'app/models/user')
require File.join(Rails.root, 'lib/importers/models/group')
class User
Method import_primary_corporation_from
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def import_primary_corporation_from( netenv_user )
corporation = netenv_user.primary_corporation
if netenv_user.ehrenphilister?(corporation)
- 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 import_secondary_corporations_from
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def import_secondary_corporations_from( netenv_user )
last_date_of_joining = netenv_user.aktivmeldungsdatum
netenv_user.secondary_corporations.each do |corporation|
- 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
Class User
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class User
# Allgemeine Attribute
# =======================================================================
Method import_exit_events_from
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def import_exit_events_from( netenv_user )
netenv_user.former_corporations.each do |corporation|
reason = netenv_user.reason_for_exit(corporation) || "ausgetreten"
date = netenv_user.date_of_exit(corporation)
- 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 create_template_profile_fields_where_non_existant
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_template_profile_fields_where_non_existant
if self.profile_fields.where(label: :personal_title).count == 0
self.profile_fields.create(label: :personal_title, type: "ProfileFieldTypes::General")
end
Method create_template_profile_fields_where_non_existant
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create_template_profile_fields_where_non_existant
if self.profile_fields.where(label: :personal_title).count == 0
self.profile_fields.create(label: :personal_title, type: "ProfileFieldTypes::General")
end
- 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 import_primary_corporation_from
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_primary_corporation_from( netenv_user )
corporation = netenv_user.primary_corporation
if netenv_user.ehrenphilister?(corporation)
Method import_stifter_status_from
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def import_stifter_status_from( netenv_user )
netenv_user.corporations.each do |corporation|
date = netenv_user.beitrittsdatum(corporation)
date ||= self.membership_in(corporation).valid_from
if netenv_user.stifter?(corporation)
- 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 import_death_from
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def import_death_from( netenv_user )
if netenv_user.verstorben?
date_of_death = netenv_user.netenv_org_membership_end_date
date_of_death ||= self.memberships.order(:valid_from).last.valid_from + 1.day
- 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 import_secondary_corporations_from
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_secondary_corporations_from( netenv_user )
last_date_of_joining = netenv_user.aktivmeldungsdatum
netenv_user.secondary_corporations.each do |corporation|
Method add_profile_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_profile_field( label, args )
raise 'no :type argument given' unless args[:type].present?
args[:type] = "ProfileFieldTypes::#{args[:type]}" unless args[:type].start_with? "ProfileFieldTypes::"
if (args[:force] or one_argument_present?(args))
args.delete(:force)
- 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 import_contact_profile_fields_from
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def import_contact_profile_fields_from( netenv_user )
add_profile_field :home_email, value: netenv_user.home_email, type: 'Email' unless netenv_user.home_email == netenv_user.email
add_profile_field :work_email, value: netenv_user.work_email, type: 'Email' unless netenv_user.work_email == netenv_user.email
home_address_field = add_profile_field netenv_user.home_address_label, value: netenv_user.home_address, type: 'Address'
- 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 import_bv_membership_from
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def import_bv_membership_from( netenv_user )
reset_bv_memberships
if netenv_user.bv
membership = netenv_user.bv.assign_user self, at: netenv_user.bv_beitrittsdatum
membership.needs_review! if netenv_user.bv_beitrittsdatum_geschätzt?
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if netenv_user.burschungsdatum
burschen = corporation.status_group("Aktive Burschen")
current_membership = self.reload.current_status_membership_in corporation
membership_burschen = current_membership.promote_to burschen, at: netenv_user.burschungsdatum
membership_burschen.needs_review! if netenv_user.burschungsdatum_geschätzt?
- 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 26.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if netenv_user.philistrationsdatum
philister = corporation.status_group("Philister")
current_membership = self.reload.current_status_membership_in corporation
membership_philister = current_membership.promote_to philister, at: netenv_user.philistrationsdatum
membership_philister.needs_review! if netenv_user.philistrationsdatum_geschätzt?
- 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 26.
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