app/models/person.rb
Class Person
has 78 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Person < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
include ParseDataRows
File person.rb
has 341 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'sorting_name_calculator'
class Person < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
Method add_item
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def add_item(collection, description, entity, start_year, end_year)
Avoid too many return
statements within this method. Open
Open
return 'L' if labour?
Avoid too many return
statements within this method. Open
Open
return 'V' if spokesperson?
Method job_level_code
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def job_level_code
return 'C' if councillor?
return 'D' if director?
return 'E' if temporary_worker?
return 'F' if public_worker?
- 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"