Showing 253 of 368 total issues
Class Output
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class NomenclatureChange::Output < ApplicationRecord
include TrackWhoDoesIt
attr_accessor :output_type # New taxon, Existing subspecies, Existing taxon
# Migrated to controller (Strong Parameters)
# attr_accessible :nomenclature_change_id, :taxon_concept_id,
Class ShowTaxonConceptSerializer
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Species::ShowTaxonConceptSerializer < ActiveModel::Serializer
cached
root 'taxon_concept'
attributes :id, :parent_id, :full_name, :author_year, :standard_references,
:common_names, :distributions, :subspecies, :distribution_references,
Class MandatoryQuotasShipments
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Trade::MandatoryQuotasShipments
attr_reader :final_query
QUOTAS_PATH = 'lib/data/quotas.csv'.freeze
Method error_message
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def error_message(values_hash = nil)
scope_info = sanitized_sandbox_scope.map do |scope_column, scope_def|
tmp = []
if scope_def['inclusion']
tmp << "#{scope_column} = #{scope_def['inclusion'].join(', ')}"
- 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 copied_object_before_save
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def copied_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} copy 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 create_indexes_on_shipments
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_indexes_on_shipments
sql = <<-SQL
CREATE INDEX index_trade_shipments_on_appendix
ON trade_shipments
USING btree
Method raw_query
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def raw_query(options)
"SELECT
shipments.id,
year,
appendix,
Method index
has a Cognitive Complexity of 20 (exceeds 5 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
- 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 ar_klass
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.ar_klass(table_name)
klass_name = table_name.camelize
begin
"Trade::#{klass_name}".constantize
rescue NameError
Method run_final_queries
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_final_queries
# need to duplicate CoP documents, which are linked to more than one proposal
# that applies to old documents
sql = <<-SQL
WITH proposal_details AS (
Method partial_db_query
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.partial_db_query(limit, offset, updated_at: nil, created_at: nil)
full_db_query(limit, offset) unless updated_at || created_at
where = if updated_at && !created_at
"shipments.updated_at > '#{updated_at}'"
elsif created_at && !updated_at
Method cites_listing_changes
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cites_listing_changes
rel = MCitesListingChange.from('api_cites_listing_changes_view AS listing_changes_mview').
where(
'listing_changes_mview.taxon_concept_id' => object_and_children
)
Method eu_listing_changes
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def eu_listing_changes
rel = MEuListingChange.from('api_eu_listing_changes_view AS listing_changes_mview').
where(
'listing_changes_mview.taxon_concept_id' => object_and_children
)
Method run_queries
has 65 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, CitationId INT, CtyISO2 TEXT, splus_taxon_concept_id INT)')
ApplicationRecord.connection.execute(
<<-SQL
Method shipment_in_scope?
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def shipment_in_scope?(shipment)
shipment_in_scope = true
# check if shipment is in scope of this validation
sanitized_shipments_scope.each do |scope_column, scope_def|
value = shipment.send(scope_column)
- 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 summary
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def summary
res = []
rank_name = @output.new_rank.try(:name) || @output.taxon_concept.try(:rank).try(:name)
full_name = @output.display_full_name
name_status = @output.new_name_status || @output.taxon_concept.try(:name_status)
- 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 gross_net_query
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gross_net_query(options)
"SELECT
year,
appendix,
taxon_concept_id,
Class MTaxonConcept
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class MTaxonConcept < ApplicationRecord
extend Mobility
self.table_name = :taxon_concepts_mview
self.primary_key = :id
Method initialize
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(rel, options)
@rel = rel
@english_common_names = options[:english_common_names]
@spanish_common_names = options[:spanish_common_names]
@french_common_names = options[:french_common_names]
Method nomenclature_change_status_swap_params
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def nomenclature_change_status_swap_params
params.require(:nomenclature_change_status_swap).permit(
:event_id, :status,
primary_output_attributes: [
:id, :_destroy,