Class has too many lines. [104/100] Open
class Question < ApplicationRecord
belongs_to :questionnaire # each question belongs to a specific questionnaire
belongs_to :review_of_review_score # ditto
has_many :question_advices, dependent: :destroy # for each question, there is separate advice about each possible score
has_many :signup_choices # ?? this may reference signup type questionnaires
- 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.
Assignment Branch Condition size for import is too high. [43.57/15] Open
def self.import(row, _row_header, _session, q_id = nil)
if row.length != 5
raise ArgumentError, 'Not enough items: expect 3 columns: your login name, your full name' \
'(first and last name, not separated with the delimiter), and your email.'
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [34/10] Open
def self.import(row, _row_header, _session, q_id = nil)
if row.length != 5
raise ArgumentError, 'Not enough items: expect 3 columns: your login name, your full name' \
'(first and last name, not separated with the delimiter), and your email.'
end
- 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 import
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import(row, _row_header, _session, q_id = nil)
if row.length != 5
raise ArgumentError, 'Not enough items: expect 3 columns: your login name, your full name' \
'(first and last name, not separated with the delimiter), and your email.'
end
Method import
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.import(row, _row_header, _session, q_id = nil)
if row.length != 5
raise ArgumentError, 'Not enough items: expect 3 columns: your login name, your full name' \
'(first and last name, not separated with the delimiter), and your email.'
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
Missing top-level class documentation comment. Open
class Question < ApplicationRecord
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Do not prefix reader method names with get_
. Open
def get_formatted_question_type
- Read upRead up
- Exclude checks
This cop makes sure that accessor methods are named properly.
Example:
# bad
def set_attribute(value)
end
# good
def attribute=(value)
end
# bad
def get_attribute
end
# good
def attribute
end