Method has too many lines. [90/25] Open
def self.generate(otu, project_members, reference_csv = nil)
name_total = 0
::CSV.generate(col_sep: "\t") do |csv|
csv << %w{
ID
- 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 has too many lines. [65/25] Open
def self.add_original_combination(t, csv, origin_citation, name_remarks_vocab_id, project_members)
e = t.original_combination_elements
infraspecific_element = t.original_combination_infraspecific_element(e, remove_sic: true)
- 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 add_original_combination
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def self.add_original_combination(t, csv, origin_citation, name_remarks_vocab_id, project_members)
e = t.original_combination_elements
infraspecific_element = t.original_combination_infraspecific_element(e, remove_sic: true)
- 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 generate
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def self.generate(otu, project_members, reference_csv = nil)
name_total = 0
::CSV.generate(col_sep: "\t") do |csv|
csv << %w{
ID
- 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 generate
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate(otu, project_members, reference_csv = nil)
name_total = 0
::CSV.generate(col_sep: "\t") do |csv|
csv << %w{
ID
Method add_original_combination
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.add_original_combination(t, csv, origin_citation, name_remarks_vocab_id, project_members)
e = t.original_combination_elements
infraspecific_element = t.original_combination_infraspecific_element(e, remove_sic: true)
Method nom_status_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.nom_status_field(taxon_name)
case taxon_name.type
when 'Combination'
nil # This is *not* 'chresonym' sensu CoL (which is this: [correct: 'Aus bus Smith 1920', chresonym: 'Aus bus Jones 1922'])
else
- 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_original_combination
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.add_original_combination(t, csv, origin_citation, name_remarks_vocab_id, project_members)
Use t.cached_original_combination.present?
instead of !t.cached_original_combination.blank?
. Open
if !t.cached_original_combination.blank? && (is_genus_species && !t.is_combination? && (!t.is_valid? || t.has_alternate_original?))
- Read upRead up
- Exclude checks
This cop checks for code that can be written with simpler conditionals
using Object#present?
defined by Active Support.
Interaction with Style/UnlessElse
:
The configuration of NotBlank
will not produce an offense in the
context of unless else
if Style/UnlessElse
is inabled. This is
to prevent interference between the auto-correction of the two cops.
Example: NotNilAndNotEmpty: true (default)
# Converts usages of `!nil? && !empty?` to `present?`
# bad
!foo.nil? && !foo.empty?
# bad
foo != nil && !foo.empty?
# good
foo.present?
Example: NotBlank: true (default)
# Converts usages of `!blank?` to `present?`
# bad
!foo.blank?
# bad
not foo.blank?
# good
foo.present?
Example: UnlessBlank: true (default)
# Converts usages of `unless blank?` to `if present?`
# bad
something unless foo.blank?
# good
something if foo.present?
TODO found Open
# TODO: Subgenus as Genus combination may break this
- Exclude checks
TODO found Open
name&.gsub(/\s+\[sic\]/, '') # TODO: remove `&` once cached_original_combination is re-indexed
- Exclude checks
TODO found Open
# TODO: handle > quadranomial names (e.g. super species like `Bus (Dus aus aus) aus eus var. fus`
- Exclude checks
TODO found Open
# TODO: consider faster ways to check for misspellings
- Exclude checks
Use 2 (not 3) spaces for indentation. Open
name_total = 0
- Read upRead up
- Exclude checks
This cop checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end