unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method kingdom has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def kingdom(tex, fetcher, kingdom_name)
    kingdom = fetcher.next
    return if kingdom.empty?
    @skip_ancestor_ids = nil

Severity: Minor
Found in app/services/checklist/pdf/history_content.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 before_validate_full_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def before_validate_full_name
    self.full_name =
      if rank && parent && ['A', 'N'].include?(name_status)
        rank_name = rank.name
        parent_full_name = parent.full_name
Severity: Minor
Found in app/models/taxon_concept.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 sanitise_condition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitise_condition
    filtering_attributes = self.class.filtering_attributes
    condition_attributes = @opts.keep_if do |k, v|
      filtering_attributes.key?(k.to_sym) && v.present?
    end
Severity: Minor
Found in lib/modules/trade/grouping/base.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 sanitise_column_names has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitise_column_names
    return '' if @attributes.blank?
    @attributes.map do |attribute|
      next if attribute == 'year' || attribute.nil?
      name = attribute.include?('id') ? 'id' : attribute.include?('iso') ? 'iso2' : attribute.include?('code') ? 'code' : 'name'
Severity: Minor
Found in lib/modules/trade/grouping/trade_plus_static.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 columns_with_type has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def columns_with_type
    [
      ['EventTypeID', 'TEXT'],
      ['EventTypeName', 'TEXT'],
      ['splus_event_type', 'TEXT'],
Severity: Minor
Found in lib/tasks/elibrary/citations_importer.rb - About 1 hr to fix

    Method get_condition_value has 35 lines of code (exceeds 25 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 1 hr to fix

      Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(params)
          sanitized_params = {
            taxon_concepts_ids: sanitise_integer_array(params[:taxon_concepts_ids]),
            reported_taxon_concepts_ids: sanitise_integer_array(params[:reported_taxon_concepts_ids]),
            appendices: sanitise_string_array(params[:appendices]),
      Severity: Minor
      Found in app/services/trade/search_params.rb - About 1 hr to fix

        Method summary has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def summary
            [
              output_children_summary,
              output_names_summary,
              output_distribution_summary,
        Severity: Minor
        Found in app/services/nomenclature_change/reassignment_summarizer.rb - About 1 hr to fix

          Method zip_file_generator has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def zip_file_generator
              missing_files = []
              pdf_file_paths = []
              tmp_dir_path = [Rails.root, "/tmp/", SecureRandom.hex(8)].join
              FileUtils.mkdir tmp_dir_path
          Severity: Minor
          Found in app/workers/manual_download_worker.rb - About 1 hr to fix

            Method tmp_taxon_concept has 33 lines of code (exceeds 25 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

              Method kingdom has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def kingdom(tex, fetcher, kingdom_name)
                  kingdom = fetcher.next
                  return if kingdom.empty?
                  @skip_ancestor_ids = nil
              
              
              Severity: Minor
              Found in app/services/checklist/pdf/history_content.rb - About 1 hr to fix

                Method perform has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def perform(aru_id, submitter_id)
                    submitter = User.find(submitter_id)
                    begin
                      aru = Trade::AnnualReportUpload.find(aru_id)
                    rescue ActiveRecord::RecordNotFound => e
                Severity: Minor
                Found in app/workers/submission_worker.rb - About 1 hr to fix

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

                    def run_queries
                      # insert taxon names
                      sql = <<-SQL
                        WITH rows_to_insert AS (
                          #{rows_to_insert_sql}
                  Severity: Minor
                  Found in lib/tasks/elibrary/non_cites_taxa_importer.rb - About 1 hr to fix

                    Function handleDownloadRequest has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function handleDownloadRequest (ignoreWarning) {
                        var output_type = $( "input[name='outputType']:checked" ).val(),
                          report_type = $( "input[name='report']:checked" ).val(),
                          csv_separator = $( "select[name='csvSeparator']" ).val(),
                          query = location.search.substr(1);
                    Severity: Minor
                    Found in app/assets/javascripts/cites_trade/application.js - About 1 hr to fix

                      Method process has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def process
                          Rails.logger.debug "FULL REASSIGNMENT #{@old_taxon_concept.full_name} to #{@new_taxon_concept.full_name}"
                          update_timestamp = Time.now
                          update_attrs = {
                            taxon_concept_id: @new_taxon_concept.id,
                      Severity: Minor
                      Found in app/services/nomenclature_change/full_reassignment.rb - About 1 hr to fix

                        Method run_summary has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def run_summary
                            @expand_headers = false # use this only for collapsed headers
                            # such as the Checklist or Species+ website
                            res = []
                            current_higher_taxon = nil
                        Severity: Minor
                        Found in app/services/checklist/higher_taxa_injector.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 dashboard_download has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.dashboard_download(params)
                            return taxonomic_download(params) if params[:type] == 'taxonomy'
                            query =
                              if params[:year].present?
                                if params[:type].present?
                        Severity: Minor
                        Found in lib/modules/trade/download_data_retriever.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 filter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def filter(data, params)
                            if params[:filter].present?
                        
                              if params[:group_by].include?('commodity')
                                data = data[params[:year]].delete_if { |d| d['term'].index(/#{params[:filter]}/i).nil? }
                        Severity: Minor
                        Found in lib/modules/trade/grouping/compliance.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 import has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def import(data)
                              # Array of CitesRstProcesses in current import we can use to
                              # destroy records no longer being returned from the RST API.
                              active_ids = []
                              data.map do |item|
                        Severity: Minor
                        Found in lib/modules/import/rst/importer.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 convert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.convert(input_str)
                            doc = Nokogiri::HTML(input_str)
                            output_str = ''
                            doc.at_css("body").traverse do |n|
                              if n.text?
                        Severity: Minor
                        Found in lib/modules/html_to_latex.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

                        Severity
                        Category
                        Status
                        Source
                        Language