unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method nomenclature_change_split_params has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def nomenclature_change_split_params
    params.require(:nomenclature_change_split).permit(
      :event_id, :status,
      input_attributes: [
        :id, :_destroy,
Severity: Major
Found in app/controllers/admin/nomenclature_changes/split_controller.rb - About 2 hrs to fix

    Method index has 52 lines of code (exceeds 25 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: Major
    Found in app/controllers/api/v1/documents_controller.rb - About 2 hrs to fix

      Method summarise_filters has 52 lines of code (exceeds 25 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: Major
      Found in app/services/checklist/checklist.rb - About 2 hrs to fix

        Method cms_listing_changes has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cms_listing_changes
            MCmsListingChange.from('cms_listing_changes_mview AS listing_changes_mview').
              where(
                'listing_changes_mview.taxon_concept_id' => object_and_children,
                'listing_changes_mview.show_in_history' => true
        Severity: Major
        Found in app/serializers/species/show_taxon_concept_serializer_cms.rb - About 2 hrs to fix

          Method call has 50 lines of code (exceeds 25 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 2 hrs to fix

            Method query has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def query
                rel = EuDecision.from("#{table_name} AS eu_decisions").
                  select(sql_columns).
                  order(:taxonomic_position, :party, :ordering_date)
                return rel.where('srg_history = ?', @eu_decision_filter) if @eu_decision_filter == 'In consultation'
            Severity: Minor
            Found in app/services/species/eu_decisions_export.rb - About 1 hr 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 transferred_object_before_save has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def transferred_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} transfer to #{new_taxon_concept.full_name}")
            Severity: Minor
            Found in app/services/nomenclature_change/reassignment_transfer_processor.rb - About 1 hr 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 has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.run(params)
                params['taxon_concepts_ids'] =
                  if params['taxon_name'].present?
                    exact_match = MTaxonConcept.where("LOWER(full_name) = ?", params['taxon_name'].downcase)
                                               .where(taxonomy_id: 1)
            Severity: Minor
            Found in lib/modules/material_doc_ids_retriever.rb - About 1 hr to fix

              Method admin_new_modal has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def admin_new_modal(options = {})
                  resource = options[:resource] || controller_name.singularize
                  id = options[:id] || "new-#{resource}"
                  title = options[:title] || "Add new #{resource.titleize}"
                  content_tag(
              Severity: Minor
              Found in app/helpers/admin_helper.rb - About 1 hr to fix

                Method taxonomy_kingdom_stats has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.taxonomy_kingdom_stats(taxonomy, kingdom)
                      stats = {}
                      t = Taxonomy.find_by_name(taxonomy)
                      k = TaxonConcept.find_by_full_name_and_taxonomy_id(kingdom, t.id)
                      stats[:accepted_taxa] = TaxonConcept.where(
                Severity: Minor
                Found in lib/modules/sapi_module/summary.rb - About 1 hr to fix

                  Method import_higher_taxa_distributions has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.import_higher_taxa_distributions
                  
                      sql = <<-SQL
                      WITH doc_taxon_tmp AS (
                        SELECT DISTINCT(dc.id) doc_cit_id, UNNEST(d.taxon_concept_ids)tc_ids
                  Severity: Minor
                  Found in lib/tasks/elibrary/identification_docs_distributions_importer.rb - About 1 hr to fix

                    Method listing_change_before_save_callback has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def listing_change_before_save_callback
                        # check if annotation should be deleted
                        if annotation &&
                           annotation.short_note_en.blank? &&
                           annotation.short_note_fr.blank? &&
                    Severity: Minor
                    Found in app/models/listing_change.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 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 run_queries has 45 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, taxon_concept_id INT)')
                              ApplicationRecord.connection.execute(
                          Severity: Minor
                          Found in lib/tasks/elibrary/citations_manual_importer.rb - About 1 hr to fix

                            Method cites_suspensions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def cites_suspensions
                                CitesSuspension.from('api_cites_suspensions_view AS trade_restrictions').
                                  where("
                                        trade_restrictions.taxon_concept_id IN (:object_and_children)
                                        OR (
                            Severity: Minor
                            Found in app/serializers/species/show_taxon_concept_serializer_cites.rb - About 1 hr to fix

                              Method apply_taxon_concept_options_to_rel has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def apply_taxon_concept_options_to_rel
                                  @taxon_concept_id = @taxon_concept_options && @taxon_concept_options[:id]
                                  if @taxon_concept_id
                                    @taxon_concept_scope = @taxon_concept_options[:scope] || ''
                                    taxon_concept = TaxonConcept.find(@taxon_concept_id) if @taxon_concept_scope
                              Severity: Minor
                              Found in app/services/taxon_concept_prefix_matcher.rb - About 1 hr to fix

                                Method tmp_taxon_concept has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def tmp_taxon_concept
                                    name_status_to_save = (new_name_status.present? ? new_name_status : name_status)
                                
                                    scientific_name =
                                      if ['A', 'N'].include?(name_status_to_save) && display_full_name
                                Severity: Minor
                                Found in app/models/nomenclature_change/output.rb - About 1 hr 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 format_values has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def format_values(key, values)
                                    case key
                                    when 'sources', 'purposes'
                                      values.map do |value|
                                        value = JSON.parse(value['data'])
                                Severity: Minor
                                Found in lib/modules/trade/trade_plus_filters.rb - About 1 hr 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 descendents_for_note_cascading has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def descendents_for_note_cascading(taxon_concept)
                                    unless [Rank::GENUS, Rank::SPECIES].include? taxon_concept.rank.try(:name)
                                      return []
                                    end
                                    # if it is a genus or a species, we want taxon-level nomenclature notes,
                                Severity: Minor
                                Found in app/services/nomenclature_change/cascading_notes_processor.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language