Showing 253 of 368 total issues
Method nomenclature_change_split_params
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def nomenclature_change_split_params
params.require(:nomenclature_change_split).permit(
:event_id, :status,
input_attributes: [
:id, :_destroy,
Method index
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if params[:taxon_concept_query].present?
exact_match = MTaxonConcept.where("LOWER(full_name) = ?", params[:taxon_concept_query].downcase)
.where(taxonomy_id: 1)
.first
Method summarise_filters
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.summarise_filters(params)
summary = []
options = Checklist::ChecklistParams.sanitize(params)
options.keys.each { |k| instance_variable_set("@#{k}", options[k]) }
Method cms_listing_changes
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cms_listing_changes
MCmsListingChange.from('cms_listing_changes_mview AS listing_changes_mview').
where(
'listing_changes_mview.taxon_concept_id' => object_and_children,
'listing_changes_mview.show_in_history' => true
Method call
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.call(aru, requester, duplicates=nil)
data_columns = if aru.reported_by_exporter?
Trade::SandboxTemplate::EXPORTER_COLUMNS
else
Trade::SandboxTemplate::IMPORTER_COLUMNS
Method query
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def query
rel = EuDecision.from("#{table_name} AS eu_decisions").
select(sql_columns).
order(:taxonomic_position, :party, :ordering_date)
return rel.where('srg_history = ?', @eu_decision_filter) if @eu_decision_filter == 'In consultation'
- 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 transferred_object_before_save
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def transferred_object_before_save(reassignment, reassignable)
return nil if conflicting_listing_change_reassignment?(reassignment, reassignable)
new_taxon_concept = @output.new_taxon_concept || @output.taxon_concept
Rails.logger.debug("Processing #{reassignable.class} #{reassignable.id} transfer to #{new_taxon_concept.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 run
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.run(params)
params['taxon_concepts_ids'] =
if params['taxon_name'].present?
exact_match = MTaxonConcept.where("LOWER(full_name) = ?", params['taxon_name'].downcase)
.where(taxonomy_id: 1)
Method admin_new_modal
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def admin_new_modal(options = {})
resource = options[:resource] || controller_name.singularize
id = options[:id] || "new-#{resource}"
title = options[:title] || "Add new #{resource.titleize}"
content_tag(
Method taxonomy_kingdom_stats
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.taxonomy_kingdom_stats(taxonomy, kingdom)
stats = {}
t = Taxonomy.find_by_name(taxonomy)
k = TaxonConcept.find_by_full_name_and_taxonomy_id(kingdom, t.id)
stats[:accepted_taxa] = TaxonConcept.where(
Method import_higher_taxa_distributions
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_higher_taxa_distributions
sql = <<-SQL
WITH doc_taxon_tmp AS (
SELECT DISTINCT(dc.id) doc_cit_id, UNNEST(d.taxon_concept_ids)tc_ids
Method listing_change_before_save_callback
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def listing_change_before_save_callback
# check if annotation should be deleted
if annotation &&
annotation.short_note_en.blank? &&
annotation.short_note_fr.blank? &&
Method gross_exports_subquery
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gross_exports_subquery
"SELECT
year,
appendix,
taxon_concept_id,
Method gross_imports_subquery
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gross_imports_subquery
"SELECT
year,
appendix,
taxon_concept_id,
Method run_queries
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_queries
ApplicationRecord.connection.execute('DROP TABLE IF EXISTS elibrary_citations_resolved_tmp')
ApplicationRecord.connection.execute('CREATE TABLE elibrary_citations_resolved_tmp (document_id INT, taxon_concept_id INT)')
ApplicationRecord.connection.execute(
Method cites_suspensions
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cites_suspensions
CitesSuspension.from('api_cites_suspensions_view AS trade_restrictions').
where("
trade_restrictions.taxon_concept_id IN (:object_and_children)
OR (
Method apply_taxon_concept_options_to_rel
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_taxon_concept_options_to_rel
@taxon_concept_id = @taxon_concept_options && @taxon_concept_options[:id]
if @taxon_concept_id
@taxon_concept_scope = @taxon_concept_options[:scope] || ''
taxon_concept = TaxonConcept.find(@taxon_concept_id) if @taxon_concept_scope
Method tmp_taxon_concept
has a Cognitive Complexity of 14 (exceeds 5 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
- 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 format_values
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def format_values(key, values)
case key
when 'sources', 'purposes'
values.map do |value|
value = JSON.parse(value['data'])
- 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 descendents_for_note_cascading
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def descendents_for_note_cascading(taxon_concept)
unless [Rank::GENUS, Rank::SPECIES].include? taxon_concept.rank.try(:name)
return []
end
# if it is a genus or a species, we want taxon-level nomenclature notes,