unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method initialize_query has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize_query
    @query = MAutoCompleteTaxonConcept.all

    @query =
      if @visibility == :trade
Severity: Major
Found in app/services/species/taxon_concept_prefix_matcher.rb - About 2 hrs to fix

    Method nomenclature_change_status_to_accepted_params has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def nomenclature_change_status_to_accepted_params
        params.require(:nomenclature_change_status_to_accepted).permit(
          :created_by_id, :updated_by_id, :event_id, :status,
          primary_output_attributes: [
            :id, :_destroy,

      Method nomenclature_change_status_swap_params has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def nomenclature_change_status_swap_params
          params.require(:nomenclature_change_status_swap).permit(
            :event_id, :status,
            primary_output_attributes: [
              :id, :_destroy,
      Severity: Major
      Found in app/controllers/admin/nomenclature_changes/status_swap_controller.rb - About 2 hrs to fix

        Method higher_taxa_headers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def higher_taxa_headers(prev_item, curr_item)
            ranks =
              if prev_item.nil?
                @header_ranks
              else
        Severity: Minor
        Found in app/services/checklist/higher_taxa_injector.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 taxonomic_grouping_per_year has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def taxonomic_grouping_per_year(year)
            conversion = read_taxonomy_conversion
        
            res = {}
            # Get all the non-compliant shipments in a given year
        Severity: Minor
        Found in lib/modules/trade/grouping/compliance.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

        Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Trade::Grouping::Base
          attr_reader :query
        
          TAXONOMIC_GROUPING = 'lib/data/group_conversions.csv'.freeze
        
        
        Severity: Minor
        Found in lib/modules/trade/grouping/base.rb - About 2 hrs to fix

          Class Compliance has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Trade::Grouping::Compliance < Trade::Grouping::Base
          
            # Complete up to current year - 1
            COUNTRIES = {
              2022 => 183,
          Severity: Minor
          Found in lib/modules/trade/grouping/compliance.rb - About 2 hrs to fix

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

              Method run_queries has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def run_queries
                  sql = <<-SQL
                    WITH rows_to_insert AS (
                      #{rows_to_insert_sql}
                    ), rows_to_insert_resolved AS (
              Severity: Major
              Found in lib/tasks/elibrary/documents_importer.rb - About 2 hrs to fix

                Method add_intervals has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def add_intervals
                    (@timelines + [self]).flatten.each do |timeline|
                      timeline.timeline_events.each_with_index do |event, idx|
                        interval =
                          if idx < (timeline.timeline_events.size - 1)
                Severity: Minor
                Found in app/services/checklist/timeline.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 validate_each has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def validate_each(record, attribute, value)
                    raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
                
                    require 'csv'
                    begin
                Severity: Minor
                Found in lib/csv_column_headers_validator.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 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 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

                    Class Constructor has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class NomenclatureChange::Split::Constructor
                      include NomenclatureChange::ConstructorHelpers
                    
                      def initialize(nomenclature_change)
                        @nomenclature_change = nomenclature_change
                    Severity: Minor
                    Found in app/services/nomenclature_change/split/constructor.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 initialize_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def initialize_query
                              @query = MAutoCompleteTaxonConcept.all
                          
                              @query =
                                if @visibility == :trade
                          Severity: Minor
                          Found in app/services/species/taxon_concept_prefix_matcher.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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def run
                              total = Document.count
                              identification_docs.each_with_index do |doc, idx|
                                info_txt = "#{doc.elib_legacy_file_name} (#{idx + 1} of #{total})"
                                target_location = @target_dir + "/documents/#{doc.id}/#{doc.elib_legacy_file_name}"
                          Severity: Minor
                          Found in lib/tasks/elibrary/manual_document_files_importer.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 get_condition_value has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def get_condition_value(key, value)
                              column_name = self.class.filtering_attributes[key.to_sym]
                          
                              # It's not a number (positive number to be precise)
                              if !/\A\d+\z/.match(value)
                          Severity: Minor
                          Found in lib/modules/trade/grouping/base.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 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
                            Severity
                            Category
                            Status
                            Source
                            Language