Showing 362 of 362 total issues
File shipment_report_queries.rb
has 725 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Trade::ShipmentReportQueries
def raw_query(options)
"SELECT
shipments.id,
File application.js
has 724 lines of code (exceeds 250 allowed). Consider refactoring. Open
$(document).ready(function(){
var ajaxFail, initExpctyImpcty, initTerms, initSources, initPurposes,
countries = {}, units = {}, terms = {}, purposes = {}, sources = {},
euId = '',
Method initialize_query
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
def initialize_query
@query = Trade::Shipment.from("#{@shipments_view} AS trade_shipments")
unless @taxon_concepts_ids.empty?
cascading_ranks =
- 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
File taxon_concept.rb
has 495 lines of code (exceeds 250 allowed). Consider refactoring. Open
class TaxonConcept < ApplicationRecord
include Deletable
extend Mobility
include TrackWhoDoesIt
has_paper_trail versions: { class_name: "TaxonConceptVersion" }, on: :destroy,
File helpers_for_import.rb
has 485 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'csv'
class CsvToDbMap
include Singleton
Class TaxonConcept
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
class TaxonConcept < ApplicationRecord
include Deletable
extend Mobility
include TrackWhoDoesIt
has_paper_trail versions: { class_name: "TaxonConceptVersion" }, on: :destroy,
Method summarise_filters
has a Cognitive Complexity of 36 (exceeds 5 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]) }
- 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 call
has a Cognitive Complexity of 35 (exceeds 5 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
- 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
File show_taxon_concept_serializer_cites.rb
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerializer
attributes :cites_listing, :eu_listing
has_many :quotas, :serializer => Species::QuotaSerializer, :key => :cites_quotas
has_many :cites_suspensions, :serializer => Species::CitesSuspensionSerializer
Class TradePlusStatic
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
attr_reader :country_ids, :locale
def initialize(attributes, opts={})
# exporter or importer
Similar blocks of code found in 2 locations. Consider refactoring. Open
def nomenclature_change_status_to_synonym_params
params.require(:nomenclature_change_status_to_synonym).permit(
:event_id, :status,
primary_output_attributes: [
:id, :_destroy,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 147.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def nomenclature_change_status_swap_params
params.require(:nomenclature_change_status_swap).permit(
:event_id, :status,
primary_output_attributes: [
:id, :_destroy,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 147.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File nomenclature_changes_helper.rb
has 332 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Admin::NomenclatureChangesHelper
def nomenclature_change_form(submit_label = 'Next', &block)
nested_form_for @nomenclature_change, url: wizard_path, method: :put,
html: { class: 'form-horizontal' } do |f|
Method comptab_query
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def comptab_query(options)
"SELECT
year,
appendix,
taxon_concept_id,
Method initialize_query
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize_query
@query = Trade::Shipment.from("#{@shipments_view} AS trade_shipments")
unless @taxon_concepts_ids.empty?
cascading_ranks =
Method initialize
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@query = TaxonConcept.from(<<-SQL
(
WITH cites_species (
id, legacy_id,
Method listed_taxa
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def listed_taxa(tex, listed_taxa_ary, kingdom_name = 'FAUNA')
tex << "\\listingtable#{kingdom_name.downcase}{"
rows = []
listed_taxa_ary.each do |tc|
listed_taxon_name = listed_taxon_name(tc)
- 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_queries
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_queries
# insert master documents
sql = <<-SQL
WITH rows_to_insert AS (
#{rows_to_insert_sql}
Method prepare_chain
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def prepare_chain
chain = []
input_is_one_of_outputs = @outputs.reject { |o| o.will_create_taxon? }.
map(&:taxon_concept_id).include?(@input.taxon_concept_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
File trade_plus_static.rb
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Trade::Grouping::TradePlusStatic < Trade::Grouping::Base
attr_reader :country_ids, :locale
def initialize(attributes, opts={})
# exporter or importer