unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method initialize_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize_query
    @taxon_concepts_rel = MTaxonConcept.all.
      by_cites_eu_taxonomy

    if @cites_regions.empty? && @countries.empty? && !@cites_appendices.empty?
Severity: Minor
Found in app/services/checklist/checklist.rb - About 55 mins 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 access_denied_error has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def access_denied_error(exception)
    rescue_path = if request.referrer && request.referrer != request.url
                    request.referer
                  elsif current_user.is_manager_or_contributor_or_secretariat?
                    admin_root_path
Severity: Minor
Found in app/controllers/application_controller.rb - About 55 mins 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 download has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def download
    set_csv_separator

    @filters = filter_params.merge({
      :csv_separator => cookies['speciesplus.csv_separator'].try(:to_sym)
Severity: Minor
Found in app/controllers/species/exports_controller.rb - About 55 mins 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 add_conditions_for_document has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def add_conditions_for_document
    @query = @query.search_by_title(@title_query) if @title_query.present?

    if @document_type.present?
      @query = @query.where('document_type IN (?)', @document_type.split(','))
Severity: Minor
Found in app/services/document_search.rb - About 55 mins 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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def save
    return false unless valid?
    success = true
    Document.transaction do
      @documents.each do |d|
Severity: Minor
Found in app/services/document_batch.rb - About 55 mins 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 process_unreassigned_taxon_concept_citations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def process_unreassigned_taxon_concept_citations
    citations = @input.document_citation_reassignments.map { |c|
      c.reassignable if _is_input_reassignment(c)
    }.compact

Severity: Minor
Found in app/services/nomenclature_change/delete_unreassigned_processor.rb - About 55 mins 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 listing_change_before_save_callback has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 apply_taxon_concept_options_to_rel has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 sanitized_shipments_scope has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitized_shipments_scope
    res = {}
    sanitized_sandbox_scope.each do |scope_column, scope_def|
      case scope_column
      when 'taxon_name', 'rank'
Severity: Minor
Found in app/models/trade/validation_rule.rb - About 45 mins 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 common_names_with_lng_initials has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def common_names_with_lng_initials(taxon_concept)
    res = ''
    unless !@english_common_names || taxon_concept.english_names.empty?
      res += " (E) #{LatexToPdf.escape_latex(taxon_concept.english_names.join(', '))} "
    end
Severity: Minor
Found in app/services/checklist/pdf/helpers.rb - About 45 mins 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 taxon_concept_internal_note_label has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def taxon_concept_internal_note_label(comment)
    content_tag(:label) do
      content_tag(:p, class: 'internal-notes-type') do
        comment.comment_type + ' note'
      end +
Severity: Minor
Found in app/helpers/taxon_concept_helper.rb - About 45 mins 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 count_matching has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.count_matching(params)
    Quota.where(
      [
        "EXTRACT(year from start_date)::INTEGER = :year
        AND ((:excluded_geo_entities) IS NULL OR geo_entity_id NOT IN (:excluded_geo_entities))
Severity: Minor
Found in app/models/trade_restrictions/quota.rb - About 45 mins 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 split_outputs_blurb has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def split_outputs_blurb
    return '' if @nomenclature_change.outputs.empty? ||
      @nomenclature_change.outputs.map(&:display_full_name).compact.empty?
    html = ' into '
    total = @nomenclature_change.outputs.size
Severity: Minor
Found in app/helpers/admin/nomenclature_changes_helper.rb - About 45 mins 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 prepare_chain has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def prepare_chain
    chain = []
    chain << NomenclatureChange::OutputTaxonConceptProcessor.new(@primary_output)
    chain << NomenclatureChange::OutputTaxonConceptProcessor.new(@secondary_output)

Severity: Minor
Found in app/services/nomenclature_change/status_swap/processor.rb - About 45 mins 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 default_separator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def default_separator(ip)
      invalid_addresses = ['127.0.0.1', nil, 'localhost', 'nil', '', 'unknown']

      if invalid_addresses.include?(ip)
        :comma
Severity: Minor
Found in lib/modules/sapi_module/geo_i_p.rb - About 45 mins 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_positive_integer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def sanitise_positive_integer(i, default = nil)
    new_i =
      if i.is_a?(String)
        tmp = i.to_i
        tmp.to_s == i ? tmp : nil
Severity: Minor
Found in lib/modules/search_param_sanitiser.rb - About 45 mins 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

Consider simplifying this complex logical expression.
Open

            if (event.is_addition? || event.is_amendment? || event.is_deletion?) &&
              @current || event.is_reservation? && event.is_current
              @continues_in_present = true
              Checklist::TimelineInterval.new(
                :taxon_concept_id => @taxon_concept_id,
Severity: Major
Found in app/services/checklist/timeline.rb - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if prev_event && (
              prev_event.is_addition? ||
                prev_event.change_type_name == 'AMENDMENT'
              ) &&
              event.is_addition? &&
    Severity: Major
    Found in app/services/checklist/timeline.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

            if reassignment.is_a?(NomenclatureChange::Reassignment) && (
              reassignable.is_a?(ListingChange) ||
              reassignable.is_a?(CitesSuspension) || reassignable.is_a?(Quota) ||
              reassignable.is_a?(EuSuspension) || reassignable.is_a?(EuOpinion)
              )
      Severity: Major
      Found in app/services/nomenclature_change/reassignment_copy_processor.rb - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if reassignment.is_a?(NomenclatureChange::Reassignment) && (
                reassignable.is_a?(ListingChange) ||
                reassignable.is_a?(CitesSuspension) || reassignable.is_a?(Quota) ||
                reassignable.is_a?(EuSuspension) || reassignable.is_a?(EuOpinion)
                )
        Severity: Major
        Found in app/services/nomenclature_change/reassignment_transfer_processor.rb - About 40 mins to fix
          Severity
          Category
          Status
          Source
          Language