Showing 28 of 58 total issues
Class Person
has 78 methods (exceeds 20 allowed). Consider refactoring. 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
require 'sorting_name_calculator'
class Person < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
Class AssetsDeclaration
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class AssetsDeclaration < ActiveRecord::Base
include DateHelper
include ParseDataRows
scope :for_year, -> (year) { where ["declaration_date >= ? and declaration_date <= ?", Date.new(year,1,1), Date.new(year,12,31)] }
Method import_row!
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_row!(row, _row_index)
person_query = Person.where(personal_code: row[:n_personal])
job_level = JOB_LEVELS.fetch(row[:tipo_de_vinculacion])
if job_level == 'councillor'
Method import
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import
declarations = Declarations.new(@path_to_file,
@period,
logger: @logger,
sheet_name: '1.DatosPersonales')
Method headers
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def headers
unless @headers
if @header_field.present?
sheet.each_with_index do |row, row_index|
if row.first == @header_field
- 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_row!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def import_row!(row, _row_index)
person_query = Person.where(personal_code: row[:n_personal])
job_level = JOB_LEVELS.fetch(row[:tipo_de_vinculacion])
if job_level == 'councillor'
- 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!
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import!
each_row(col_sep: ",") do |row|
person = Person.new
if row[:n_personal].present?
person = Person.where(councillor_code: row[:n_personal]).first!
Method person_params
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def person_params
params.require(:person).permit(
:first_name, :last_name, :job_level, :area, :councillor_code, :personal_code,
:twitter, :facebook, :role, :secondary_role, :unit, :party_id,
:studies_comment, :courses_comment, :career_comment, :political_posts_comment,
Method import!
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import!
each_row do |row|
center = parse_text(row[:descripcion_centro])
organism = parse_text(row[:organismo])
contract_number = row[:numero_contrato]
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
attrs = assets_upload_params.merge(author: current_administrator,
check_for_file: true)
@assets_upload = AssetsUpload.new(attrs)
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
attrs = activities_upload_params.merge(author: current_administrator,
check_for_file: true)
@activities_upload = ActivitiesUpload.new(attrs)
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
attrs = profile_upload_params.merge(author: current_administrator,
check_for_file: true)
@profile_upload = ProfileUpload.new(attrs)
Method import
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import
declarations = Declarations.new(@path_to_file,
@period,
logger: @logger,
sheet_name: '1.DatosPersonales')
Method add_real_estate_property
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_real_estate_property(kind, type, description, municipality, share, purchase_date, tax_value, notes)
Method import!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def import!
each_row(col_sep: ",") do |row|
person = Person.new
if row[:n_personal].present?
person = Person.where(councillor_code: row[:n_personal]).first!
- 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 add_private_activity
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_private_activity(kind, description, entity, position, start_date, end_date)
Method add_item
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_item(collection, description, entity, start_year, end_year)
Method each_row
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def each_row(&_block)
sheet.each_with_index do |row, row_index|
next if row_index <= headers_row # skip header row
row_hash = row_to_hash(row, row_index)
next if row_hash.values.all?(&:blank?)
- 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
Avoid too many return
statements within this method. Open
return 'V' if spokesperson?