Method has too many lines. [64/25] Open
def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)
# Until we have RC5 articulations we are simplifying handling the fact
# that one taxon name can be used for many OTUs. Track to see that
# an OTU with a given taxon name does not already exist
- 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 generate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)
# Until we have RC5 articulations we are simplifying handling the fact
# that one taxon name can be used for many OTUs. Track to see that
# an OTU with a given taxon name does not already exist
- 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 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate(otus, project_members, root_otu_id = nil, reference_csv = nil, prefer_unlabelled_otus: true)
# Until we have RC5 articulations we are simplifying handling the fact
# that one taxon name can be used for many OTUs. Track to see that
# an OTU with a given taxon name does not already exist
Do not write to stdout. Use Rails's logger if you want to log. Open
puts 'WARNING no parent!!'
- Read upRead up
- Exclude checks
This cop checks for the use of output calls like puts and print
Example:
# bad
puts 'A debug message'
pp 'A debug message'
print 'A debug message'
# good
Rails.logger.debug 'A debug message'
TODO found Open
# TODO: This was excluding OTUs that were being excluded downstream previously
- Exclude checks
TODO found Open
# TODO: optional Taxon.alternativeID field allows inclusion of external identifiers: https://github.com/CatalogueOfLife/coldp#alternativeid-1 https://github.com/CatalogueOfLife/coldp#identifiers
- Exclude checks
TODO found Open
# TODO: alter way parent is set to conform to CoLDP status
- Exclude checks
TODO found Open
# TODO: remove once RC5 better modelled
- Exclude checks
TODO found Open
# TODO: create map of all possible CoLDP used IRIs and ability to populate project with them automatically
- Exclude checks
TODO found Open
# TODO - reason in TW this is provisional name
- Exclude checks
TODO found Open
# TODO: Use o.coordinate_otus to summarize accross different instances of the OTU
- Exclude checks
Freeze mutable objects assigned to constants. Open
IRI_MAP = {
extinct: 'https://api.checklistbank.org/datapackage#Taxon.extinct', # 1,0
temporal_range_end: 'https://api.checklistbank.org/datapackage#Taxon.temporal_range_end', # from https://api.checklistbank.org/vocab/geotime
temporal_range_start: 'https://api.checklistbank.org/datapackage#Taxon.temporal_range_end', # from https://api.checklistbank.org/vocab/geotime
lifezone: 'https://api.checklistbank.org/datapackage#Taxon.lifezone', # from https://api.checklistbank.org/vocab/lifezone
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.
Example: EnforcedStyle: literals (default)
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
# good
CONST = <<~TESTING.freeze
This is a heredoc
TESTING
# good
CONST = Something.new
Example: EnforcedStyle: strict
# bad
CONST = Something.new
# bad
CONST = Struct.new do
def foo
puts 1
end
end
# good
CONST = Something.new.freeze
# good
CONST = Struct.new do
def foo
puts 1
end
end.freeze
Freeze mutable objects assigned to constants. Open
SKIPPED_RANKS = %w{
NomenclaturalRank::Iczn::SpeciesGroup::Superspecies
NomenclaturalRank::Iczn::SpeciesGroup::Supersuperspecies
}
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.
Example: EnforcedStyle: literals (default)
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
# good
CONST = <<~TESTING.freeze
This is a heredoc
TESTING
# good
CONST = Something.new
Example: EnforcedStyle: strict
# bad
CONST = Something.new
# bad
CONST = Struct.new do
def foo
puts 1
end
end
# good
CONST = Something.new.freeze
# good
CONST = Struct.new do
def foo
puts 1
end
end.freeze