Showing 253 of 368 total issues
Method kingdom
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def kingdom(tex, fetcher, kingdom_name)
kingdom = fetcher.next
return if kingdom.empty?
@skip_ancestor_ids = nil
- 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 before_validate_full_name
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def before_validate_full_name
self.full_name =
if rank && parent && ['A', 'N'].include?(name_status)
rank_name = rank.name
parent_full_name = parent.full_name
- 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 sanitise_condition
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sanitise_condition
filtering_attributes = self.class.filtering_attributes
condition_attributes = @opts.keep_if do |k, v|
filtering_attributes.key?(k.to_sym) && v.present?
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
Method sanitise_column_names
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sanitise_column_names
return '' if @attributes.blank?
@attributes.map do |attribute|
next if attribute == 'year' || attribute.nil?
name = attribute.include?('id') ? 'id' : attribute.include?('iso') ? 'iso2' : attribute.include?('code') ? 'code' : 'name'
- 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 columns_with_type
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def columns_with_type
[
['EventTypeID', 'TEXT'],
['EventTypeName', 'TEXT'],
['splus_event_type', 'TEXT'],
Method get_condition_value
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_condition_value(key, value)
column_name = self.class.filtering_attributes[key.to_sym]
# It's not a number (positive number to be precise)
if !/\A\d+\z/.match(value)
Method initialize
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(params)
sanitized_params = {
taxon_concepts_ids: sanitise_integer_array(params[:taxon_concepts_ids]),
reported_taxon_concepts_ids: sanitise_integer_array(params[:reported_taxon_concepts_ids]),
appendices: sanitise_string_array(params[:appendices]),
Method summary
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def summary
[
output_children_summary,
output_names_summary,
output_distribution_summary,
Method zip_file_generator
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def zip_file_generator
missing_files = []
pdf_file_paths = []
tmp_dir_path = [Rails.root, "/tmp/", SecureRandom.hex(8)].join
FileUtils.mkdir tmp_dir_path
Method tmp_taxon_concept
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tmp_taxon_concept
name_status_to_save = (new_name_status.present? ? new_name_status : name_status)
scientific_name =
if ['A', 'N'].include?(name_status_to_save) && display_full_name
Method kingdom
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def kingdom(tex, fetcher, kingdom_name)
kingdom = fetcher.next
return if kingdom.empty?
@skip_ancestor_ids = nil
Method perform
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(aru_id, submitter_id)
submitter = User.find(submitter_id)
begin
aru = Trade::AnnualReportUpload.find(aru_id)
rescue ActiveRecord::RecordNotFound => e
Method run_queries
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_queries
# insert taxon names
sql = <<-SQL
WITH rows_to_insert AS (
#{rows_to_insert_sql}
Function handleDownloadRequest
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleDownloadRequest (ignoreWarning) {
var output_type = $( "input[name='outputType']:checked" ).val(),
report_type = $( "input[name='report']:checked" ).val(),
csv_separator = $( "select[name='csvSeparator']" ).val(),
query = location.search.substr(1);
Method process
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process
Rails.logger.debug "FULL REASSIGNMENT #{@old_taxon_concept.full_name} to #{@new_taxon_concept.full_name}"
update_timestamp = Time.now
update_attrs = {
taxon_concept_id: @new_taxon_concept.id,
Method run_summary
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run_summary
@expand_headers = false # use this only for collapsed headers
# such as the Checklist or Species+ website
res = []
current_higher_taxon = nil
- 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 dashboard_download
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.dashboard_download(params)
return taxonomic_download(params) if params[:type] == 'taxonomy'
query =
if params[:year].present?
if params[:type].present?
- 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 filter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def filter(data, params)
if params[:filter].present?
if params[:group_by].include?('commodity')
data = data[params[:year]].delete_if { |d| d['term'].index(/#{params[:filter]}/i).nil? }
- 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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def import(data)
# Array of CitesRstProcesses in current import we can use to
# destroy records no longer being returned from the RST API.
active_ids = []
data.map do |item|
- 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 convert
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.convert(input_str)
doc = Nokogiri::HTML(input_str)
output_str = ''
doc.at_css("body").traverse do |n|
if n.text?
- 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"