unepwcmc/SAPI

View on GitHub

Showing 368 of 368 total issues

Method summary has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def summary
    res = []
    rank_name = @output.new_rank.try(:name) || @output.taxon_concept.try(:rank).try(:name)
    full_name = @output.display_full_name
    name_status = @output.new_name_status || @output.taxon_concept.try(:name_status)
Severity: Minor
Found in app/services/nomenclature_change/output_taxon_concept_processor.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 gross_net_query has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def gross_net_query(options)
    "SELECT
      year,
      appendix,
      taxon_concept_id,
Severity: Major
Found in app/services/trade/shipment_report_queries.rb - About 2 hrs to fix

    Class MTaxonConcept has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MTaxonConcept < ApplicationRecord
      extend Mobility
      self.table_name = :taxon_concepts_mview
      self.primary_key = :id
    
    
    Severity: Minor
    Found in app/models/m_taxon_concept.rb - About 2 hrs to fix

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

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

          def nomenclature_change_status_to_synonym_params
            params.require(:nomenclature_change_status_to_synonym).permit(
              :event_id, :status,
              primary_output_attributes: [
                :id, :_destroy,

          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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              function goToResults (q) {
                                var $link = $('#view_genie'),
                                  href = '/' + locale + '/cites_trade/download/view_results?' + q;
                                $link.attr('href', href).click();
                                window.location.href = $link.attr("href");
                            Severity: Major
                            Found in app/assets/javascripts/cites_trade/application.js and 1 other location - About 2 hrs to fix
                            app/assets/javascripts/cites_trade/application.js on lines 758..763

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 79.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              function downloadResults (q) {
                                var $link = $('#download_genie'),
                                  href = '/' + locale + '/cites_trade/exports/download?' + q;
                                $link.attr('href', href).click();
                                window.location.href = $link.attr("href");
                            Severity: Major
                            Found in app/assets/javascripts/cites_trade/application.js and 1 other location - About 2 hrs to fix
                            app/assets/javascripts/cites_trade/application.js on lines 751..756

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 79.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Severity
                            Category
                            Status
                            Source
                            Language