unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method update_or_create_error_record has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def update_or_create_error_record(annual_report_upload, existing_record, error_count, error_message, matching_criteria)
Severity: Minor
Found in app/models/trade/validation_rule.rb - About 35 mins to fix

    Method higher_taxa_from_parent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def higher_taxa_from_parent
        field_names = higher_taxa_field_names
        data =
          if @taxon_concept.parent && @taxon_concept.parent.data
            @taxon_concept.parent.data
    Severity: Minor
    Found in app/services/taxon_concept_data.rb - About 35 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 ancestors_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def ancestors_path(taxon_concept)
        Rank.where(
          ["taxonomic_position < ?", taxon_concept.rank.taxonomic_position]
          ).order(:taxonomic_position).map do |r|
          return nil unless taxon_concept.data
    Severity: Minor
    Found in app/helpers/admin_helper.rb - About 35 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 error_message_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def error_message_for(field)
        return "" if resource.errors[field].empty? && field != :password_confirmation
        message =
          if field == :password_confirmation
            field = :password
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 35 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        @nomenclature_change.assign_attributes(
          (nomenclature_change_status_to_accepted_params || {}).merge({
            :status => (step == steps.last ? NomenclatureChange::SUBMITTED : step.to_s)
          })

    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 scoped_records_arel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def scoped_records_arel(s)
        not_null_nodes = required_column_names.map do |c|
          s[c].not_eq(nil)
        end
        not_null_conds = not_null_nodes.shift
    Severity: Minor
    Found in app/models/trade/inclusion_validation_rule.rb - About 35 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        @nomenclature_change.assign_attributes(
          (nomenclature_change_split_params || {}).merge({
            :status => (step == steps.last ? NomenclatureChange::SUBMITTED : step.to_s)
          })
    Severity: Minor
    Found in app/controllers/admin/nomenclature_changes/split_controller.rb - About 35 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 partial_db_query has a Cognitive Complexity of 7 (exceeds 5 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: Minor
    Found in app/services/trade/shipment_report_queries.rb - About 35 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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        @document = Document.find(params[:id])
        path_to_file = @document.filename.path unless @document.is_link?
        if access_denied? && !@document.is_public
          render_403
    Severity: Minor
    Found in app/controllers/api/v1/documents_controller.rb - About 35 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 change_consecutive_additions_to_amendments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def change_consecutive_additions_to_amendments
        (@timelines + [self]).flatten.each do |timeline|
          prev_event = nil
          timeline.timeline_events.each_with_index do |event, idx|
            if prev_event && (
    Severity: Minor
    Found in app/services/checklist/timeline.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def download
        filters = (filter_params || {}).merge({
          :csv_separator =>
            if filter_params && filter_params[:csv_separator] &&
              filter_params[:csv_separator].downcase.strip.to_sym == :semicolon
    Severity: Minor
    Found in app/controllers/admin/exports_controller.rb - About 35 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 main_entry has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def main_entry(tc)
        res = listed_taxon_name(tc)
        res += " #{LatexToPdf.escape_latex(tc.author_year)}" if @authors
        res += current_listing_with_annotations(tc)
        if ['SPECIES', 'SUBSPECIES', 'GENUS', 'FAMILY', 'SUBFAMILY'].include? tc.rank_name
    Severity: Minor
    Found in app/services/checklist/pdf/index_content.rb - About 35 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 validation_errors_for_shipment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def validation_errors_for_shipment(shipment)
        return nil unless shipment_in_scope?(shipment)
        # if it is, check if validated columns are not equal
        distinct_values = true
        shipments_columns.each do |c1|
    Severity: Minor
    Found in app/models/trade/distinct_values_validation_rule.rb - About 35 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 expected_full_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def expected_full_name(parent)
        if self.rank &&
          Rank.in_range(Rank::VARIETY, Rank::SPECIES).include?(self.rank.name)
          parent.full_name +
            if self.rank.name == Rank::VARIETY
    Severity: Minor
    Found in app/models/taxon_concept.rb - About 35 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 set_pagination_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_pagination_headers(data, params)
        data = instance_variable_get("@#{data}").presence
        # Make sure the count works for both TradeView and ComplianceTool
        _count = data ? (data.first.is_a?(Array) ? data.count : data.first['total_count']) : 0
        params = send(params)
    Severity: Minor
    Found in app/controllers/api/v1/shipments_controller.rb - About 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 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: Minor
    Found in app/services/checklist/pdf/index_query.rb - About 35 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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        @document = Document.find(params[:id])
        path_to_file = @document.filename.path unless @document.is_link?
        if access_denied? && !@document.is_public
          render_403
    Severity: Minor
    Found in app/controllers/checklist/documents_controller.rb - About 35 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 new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.new(filters = {})
        @designation =
          if filters[:designation_id]
            Designation.find(filters[:designation_id])
          elsif filters[:designation]
    Severity: Minor
    Found in app/services/species/listings_export_factory.rb - About 35 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 resolve has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def resolve(node)
        @expected_full_name = node.expected_full_name(node.parent)
        return node if name_compatible_with_parent?(node)
        Rails.logger.debug("Resolving node name: #{node.full_name} (expected: #{@expected_full_name})")
    
    
    Severity: Minor
    Found in app/services/nomenclature_change/taxonomic_tree_name_resolver.rb - About 35 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 build_listing_change_associations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_listing_change_associations(reassignable, copied_object)
        # for listing changes this needs to copy listing distributions and exceptions
        reassignable.listing_distributions.each do |listing_distr|
          !copied_object.new_record? && listing_distr.duplicates({
            listing_change_id: copied_object.id
    Severity: Minor
    Found in app/services/nomenclature_change/reassignment_copy_processor.rb - About 35 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

    Severity
    Category
    Status
    Source
    Language