unepwcmc/SAPI

View on GitHub

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

    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 = '',
    Severity: Major
    Found in app/assets/javascripts/cites_trade/application.js - About 1 day to fix

      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 =
      Severity: Minor
      Found in app/services/trade/filter.rb - About 1 day 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

      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,
      Severity: Minor
      Found in app/models/taxon_concept.rb - About 7 hrs to fix

        File helpers_for_import.rb has 485 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'csv'
        
        class CsvToDbMap
          include Singleton
        
        
        Severity: Minor
        Found in lib/tasks/helpers_for_import.rb - About 7 hrs to fix

          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,
          Severity: Minor
          Found in app/models/taxon_concept.rb - About 6 hrs to fix

            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]) }
            Severity: Minor
            Found in app/services/checklist/checklist.rb - About 5 hrs 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

            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
            Severity: Minor
            Found in lib/modules/trade/changelog_csv_generator.rb - About 5 hrs 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

            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
            Severity: Minor
            Found in app/serializers/species/show_taxon_concept_serializer_cites.rb - About 4 hrs to fix

              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
              Severity: Minor
              Found in lib/modules/trade/grouping/trade_plus_static.rb - About 4 hrs to fix

                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,
                app/controllers/admin/nomenclature_changes/status_swap_controller.rb on lines 56..129

                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

                Further Reading

                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,
                app/controllers/admin/nomenclature_changes/status_to_synonym_controller.rb on lines 55..128

                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

                Further Reading

                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|
                Severity: Minor
                Found in app/helpers/admin/nomenclature_changes_helper.rb - About 4 hrs 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 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 =
                    Severity: Major
                    Found in app/services/trade/filter.rb - About 3 hrs to fix

                      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,
                      Severity: Major
                      Found in lib/modules/trade/species_without_legislation_or_trade_report.rb - About 3 hrs to fix

                        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)
                        Severity: Minor
                        Found in app/services/checklist/pdf/history_content.rb - About 3 hrs 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

                        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}
                        Severity: Major
                        Found in lib/tasks/elibrary/documents_identification_importer.rb - About 3 hrs to fix

                          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)
                          
                          
                          Severity: Minor
                          Found in app/services/nomenclature_change/split/processor.rb - About 3 hrs 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

                          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
                          Severity: Minor
                          Found in lib/modules/trade/grouping/trade_plus_static.rb - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language