unepwcmc/SAPI

View on GitHub

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

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

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

        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(', ')}"
        Severity: Minor
        Found in app/models/trade/inclusion_validation_rule.rb - About 2 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 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}")
        Severity: Minor
        Found in app/services/nomenclature_change/reassignment_copy_processor.rb - About 2 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 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
        Severity: Major
        Found in lib/modules/sapi_module/indexes.rb - About 2 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 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
            Severity: Minor
            Found in app/controllers/api/v1/documents_controller.rb - About 2 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 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
            Severity: Major
            Found in app/models/trade/sandbox_template.rb - About 2 hrs to fix

              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 (
              Severity: Major
              Found in lib/tasks/elibrary/citations_cop_importer.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 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
                        )
                  Severity: Major
                  Found in app/serializers/species/show_taxon_concept_serializer_cites.rb - About 2 hrs to fix

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

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

                        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)
                        Severity: Minor
                        Found in app/models/trade/validation_rule.rb - About 2 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 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)
                        Severity: Minor
                        Found in app/services/nomenclature_change/output_taxon_concept_processor.rb - About 2 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 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

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

                            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]
                            Severity: Major
                            Found in app/services/checklist/pdf/index_query.rb - About 2 hrs to fix

                              Method nomenclature_change_status_to_synonym_params has 61 lines of code (exceeds 25 allowed). 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,
                                Severity
                                Category
                                Status
                                Source
                                Language