app/services/trade/shipment_report_queries.rb
File shipment_report_queries.rb
has 725 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module Trade::ShipmentReportQueries
def raw_query(options)
"SELECT
shipments.id,
Method comptab_query
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def comptab_query(options)
"SELECT
year,
appendix,
taxon_concept_id,
Method raw_query
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def raw_query(options)
"SELECT
shipments.id,
year,
appendix,
Method partial_db_query
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 gross_net_query
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def gross_net_query(options)
"SELECT
year,
appendix,
taxon_concept_id,
Method full_db_query
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.full_db_query(limit, offset)
"SELECT
shipments.id AS id,
year AS year,
appendix AS appendix,
Method full_db_query_by_kingdom
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.full_db_query_by_kingdom(year, kingdom)
"SELECT
shipments.id AS id,
year AS year,
appendix AS appendix,
Method full_db_query_by_year
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.full_db_query_by_year(year)
"SELECT
shipments.id AS id,
year AS year,
appendix AS appendix,
Method full_db_query_single_file
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.full_db_query_single_file(limit, offset)
"SELECT
shipments.id AS id,
year AS year,
appendix AS appendix,
Method gross_imports_subquery
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def gross_imports_subquery
"SELECT
year,
appendix,
taxon_concept_id,
Method gross_exports_subquery
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def gross_exports_subquery
"SELECT
year,
appendix,
taxon_concept_id,
Method net_exports_subquery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def net_exports_subquery
"SELECT
exports.year,
exports.appendix,
exports.taxon_concept_id,
Method net_imports_subquery
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def net_imports_subquery
"SELECT
imports.year,
imports.appendix,
imports.taxon_concept_id,
Method partial_db_query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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
- 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"