unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

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

    Method search_params has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def search_params
        (params[:filters] || params).permit(
          :reporter_type,
          :time_range_start,
          :time_range_end,
    Severity: Minor
    Found in app/controllers/trade_controller.rb - About 1 hr to fix

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

        def initialize(user)
          # Define abilities for the passed in user here. For example:
          #
          #   user ||= User.new # guest user (not logged in)
          #   if user.admin?
      Severity: Minor
      Found in app/models/ability.rb - About 1 hr to fix

        Method sql_columns has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def sql_columns
            general_subtype_column = <<-SQL
              case
                when general_subtype is TRUE
                  then 'Whole animals/plants'
        Severity: Minor
        Found in app/services/species/id_manual_documents_export.rb - About 1 hr to fix

          Method data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def data
              Ahoy::Event.from(<<-SQL
                (
                  WITH weeks_as_timestamps AS (
                    SELECT * FROM generate_series(
          Severity: Minor
          Found in app/services/events_by_type_stats.rb - About 1 hr to fix

            Method event_types_with_names has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.event_types_with_names
                [
                  {
                    id: 'CitesCop',
                    name: 'CITES CoP'
            Severity: Minor
            Found in app/models/event.rb - About 1 hr to fix

              Method download has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def download
                  respond_to do |format|
                    format.html {
                      search = Trade::ShipmentsExportFactory.new(search_params.merge({
                        :per_page => Trade::ShipmentsExport::PUBLIC_CSV_LIMIT
              Severity: Minor
              Found in app/controllers/cites_trade/exports_controller.rb - About 1 hr to fix

                Method matching_records_arel has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def matching_records_arel(table_name)
                    s = Arel::Table.new("#{table_name}_view")
                    tc = Arel::Table.new('taxon_concepts')
                    t = Arel::Table.new('taxonomies')
                
                
                Severity: Minor
                Found in app/models/trade/taxon_concept_source_validation_rule.rb - About 1 hr to fix

                  Function parseTaxonCascadeData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function parseTaxonCascadeData(data, term, showSpp) {
                      var d = data.auto_complete_taxon_concepts;
                      var data_by_rank = [];
                      var currentRank = d[0].rank_name;
                      data_by_rank.push({
                  Severity: Minor
                  Found in app/assets/javascripts/cites_trade/application.js - About 1 hr to fix

                    Method _build_document_reassignment has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def _build_document_reassignment(document_citation, input, outputs)
                        reassignment = input.document_citation_reassignment_class.new(
                          reassignable_type: 'DocumentCitation',
                          reassignable_id: document_citation.id
                        )
                    Severity: Minor
                    Found in app/models/nomenclature_change/constructor_helpers.rb - About 1 hr to fix

                      Method generate_timelines has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def generate_timelines
                          @raw_timelines = {}
                          ['I', 'II', 'III'].each do |species_listing_name|
                            @raw_timelines[species_listing_name] = Checklist::Timeline.new(
                              :taxon_concept_id => @taxon_concept_id,
                      Severity: Minor
                      Found in app/services/checklist/timelines_for_taxon_concept.rb - About 1 hr to fix

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

                          Consider simplifying this complex logical expression.
                          Open

                              if annotation &&
                                 annotation.short_note_en.blank? &&
                                 annotation.short_note_fr.blank? &&
                                 annotation.short_note_es.blank? &&
                                 annotation.full_note_en.blank? &&
                          Severity: Major
                          Found in app/models/listing_change.rb - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                return nil unless shipment.source && (
                                  shipment.taxon_concept &&
                                  shipment.taxon_concept.data['kingdom_name'] == 'Animalia' &&
                                  INVALID_KINGDOM_SOURCE['ANIMALIA'].include?(shipment.source.code) ||
                                  shipment.taxon_concept &&
                            Severity: Major
                            Found in app/models/trade/taxon_concept_source_validation_rule.rb - About 1 hr to fix

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

                                def changeable_after_save_callback_on_commit
                                  changeable_clear_cache
                              
                                  # For models that are not directly related to taxon concepts
                                  # but for which is anyway preferable for the changes to be reflacted
                              Severity: Minor
                              Found in app/models/concerns/changeable.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 admin_new_modal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def admin_new_modal(options = {})
                                  resource = options[:resource] || controller_name.singularize
                                  id = options[:id] || "new-#{resource}"
                                  title = options[:title] || "Add new #{resource.titleize}"
                                  content_tag(
                              Severity: Minor
                              Found in app/helpers/admin_helper.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 apply_rank_options_to_rel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def apply_rank_options_to_rel
                                  @rank_id = @rank_options && @rank_options[:id]
                                  if @rank_id
                                    @rank_scope = @rank_options[:scope] || ''
                                    rank = Rank.find(@rank_id) if @rank_scope
                              Severity: Minor
                              Found in app/services/taxon_concept_prefix_matcher.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 comparison_conditions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def comparison_conditions(comparison_attributes = nil)
                                  comparison_attributes ||= self.comparison_attributes
                                  a = self.class.all
                                  arel_nodes = []
                                  comparison_attributes.each do |attr_name, attr_val|
                              Severity: Minor
                              Found in app/models/concerns/comparison_attributes.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 changeable_after_save_callback has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def changeable_after_save_callback
                                  unless respond_to?(:taxon_concept)
                                    return
                                  end
                              
                              
                              Severity: Minor
                              Found in app/models/concerns/changeable.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 show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def show
                                  builder = NomenclatureChange::Split::Constructor.new(@nomenclature_change)
                                  case step
                                  when :inputs
                                    set_events
                              Severity: Minor
                              Found in app/controllers/admin/nomenclature_changes/split_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

                              Severity
                              Category
                              Status
                              Source
                              Language