unepwcmc/SAPI

View on GitHub
app/services/trade/shipment_report_queries.rb

Summary

Maintainability
F
5 days
Test Coverage

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,
Severity: Major
Found in app/services/trade/shipment_report_queries.rb - About 1 day to fix

    Method comptab_query has 96 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def comptab_query(options)
        "SELECT
          year,
          appendix,
          taxon_concept_id,
    Severity: Major
    Found in app/services/trade/shipment_report_queries.rb - About 3 hrs to fix

      Method raw_query has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def raw_query(options)
          "SELECT
            shipments.id,
            year,
            appendix,
      Severity: Major
      Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

        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
        Severity: Major
        Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

          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,
          Severity: Major
          Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

            Method full_db_query has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.full_db_query(limit, offset)
                "SELECT
                  shipments.id AS id,
                  year AS year,
                  appendix AS appendix,
            Severity: Major
            Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

              Method full_db_query_by_kingdom has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.full_db_query_by_kingdom(year, kingdom)
                  "SELECT
                    shipments.id AS id,
                    year AS year,
                    appendix AS appendix,
              Severity: Major
              Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

                Method full_db_query_by_year has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.full_db_query_by_year(year)
                    "SELECT
                      shipments.id AS id,
                      year AS year,
                      appendix AS appendix,
                Severity: Major
                Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

                  Method full_db_query_single_file has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.full_db_query_single_file(limit, offset)
                      "SELECT
                        shipments.id AS id,
                        year AS year,
                        appendix AS appendix,
                  Severity: Major
                  Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

                    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,
                    Severity: Minor
                    Found in app/services/trade/shipment_report_queries.rb - About 1 hr to fix

                      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,
                      Severity: Minor
                      Found in app/services/trade/shipment_report_queries.rb - About 1 hr to fix

                        Method net_exports_subquery has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def net_exports_subquery
                            "SELECT
                              exports.year,
                              exports.appendix,
                              exports.taxon_concept_id,
                        Severity: Minor
                        Found in app/services/trade/shipment_report_queries.rb - About 1 hr to fix

                          Method net_imports_subquery has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def net_imports_subquery
                              "SELECT
                                imports.year,
                                imports.appendix,
                                imports.taxon_concept_id,
                          Severity: Minor
                          Found in app/services/trade/shipment_report_queries.rb - About 1 hr to fix

                            Method partial_db_query has a Cognitive Complexity of 7 (exceeds 5 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
                            Severity: Minor
                            Found in app/services/trade/shipment_report_queries.rb - About 35 mins to fix

                            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

                            There are no issues that match your filters.

                            Category
                            Status