app/models/organisation.rb
Class has too many lines. [165/100] Open
Open
class Organisation < BaseOrganisation
has_many :volunteer_ops
has_many :users
has_many :edits, class_name: 'ProposedOrganisationEdit', dependent: :destroy
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Class Organisation
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Organisation < BaseOrganisation
has_many :volunteer_ops
has_many :users
has_many :edits, class_name: 'ProposedOrganisationEdit', dependent: :destroy
Method has too many lines. [11/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
Open
def self.import(filename, limit, validation)
csv_text = File.open(filename, 'r:ISO-8859-1')
count = 0
CSV.parse(csv_text, headers: true).each do |row|
break if count >= limit
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method create_and_validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.create_and_validate(attributes)
# create!(attributes.select{|k,v| !v.nil?})
create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
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
TODO found Open
Open
accepts_nested_attributes_for :users # TODO check if needed
- Exclude checks
Line is too long. [113/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
.having(organisation_id.count.eq category_ids.size) # and return the orgs with correct number of duplicates
- Exclude checks
Replace class var @@column_mappings with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars) Open
Open
@@column_mappings = {
- Read upRead up
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Line is too long. [122/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
error_msg = ('Error: Email is invalid' == error_msg) ? "The user email you entered,'#{email}', is invalid" : error_msg
- Exclude checks
Ternary operators must not be nested. Prefer if
or else
constructs instead. (https://github.com/bbatsov/ruby-style-guide#no-nested-ternary) Open
Open
create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
- Exclude checks
Line is too long. [93/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
# Alternative => :joins('LEFT OUTER JOIN users ON users.organisation_id = organisations.id)
- Exclude checks
Line is too long. [134/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
- Exclude checks
Line is too long. [95/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
raise CSV::MalformedCSVError, "No expected column with name #{column_name} in CSV file"
- Exclude checks
Line is too long. [124/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
.where(category_id.in category_ids) # at this point, orgs in multiple categories show up as duplicates
- Exclude checks
Line is too long. [96/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
Open
create!(attributes.each { |k, v| attributes[k] = v.empty? ? 'NO INFORMATION RECORDED' : v })
- Exclude checks