unepwcmc/SAPI

View on GitHub

Showing 253 of 368 total issues

Method available_columns has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def available_columns
    {
      :id => { :internal => true },
      :year => {},
      :appendix => {},
Severity: Minor
Found in app/services/trade/shipments_export.rb - About 1 hr to fix

    Function displayResults has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function displayResults (q) {
        var table_view_title, formURL = '/' + locale + '/cites_trade/shipments',
          data_headers, data_rows, table_tmpl,
          comptab_regex = /comptab/,
          gross_net_regex = /(gross_exports|gross_imports|net_exports|net_imports)/;
    Severity: Minor
    Found in app/assets/javascripts/cites_trade/application.js - About 1 hr to fix

      Method kingdom_summary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.kingdom_summary(t, k)
            puts "#############################################################"
            puts "#############################################################"
            puts ">>> #{k.full_name} general stats"
      
      
      Severity: Minor
      Found in lib/modules/sapi_module/summary.rb - About 1 hr to fix

        Method import_species_distributions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.import_species_distributions
            sql = <<-SQL
              WITH doc_taxon_tmp AS (
                  SELECT dc.id doc_cit_id, dctc.taxon_concept_id tc_id
                  FROM document_citation_taxon_concepts dctc
        Severity: Minor
        Found in lib/tasks/elibrary/identification_docs_distributions_importer.rb - About 1 hr to fix

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

            Method batch_update_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def batch_update_params
                update_params = params.permit(
                  :updates => shipment_attributes
                )
                res = update_params && update_params.delete('updates') || {}
            Severity: Minor
            Found in app/controllers/trade/shipments_controller.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 to_csv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.to_csv(file_path, filters)
                limit = 1000
                offset = 0
                csv_separator_char =
                  case filters[:csv_separator]
            Severity: Minor
            Found in app/models/trade_restriction.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 show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def show
                builder = klass::Constructor.new(@nomenclature_change)
                case step
                when :primary_output
                  set_events

            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 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                @nomenclature_change.assign_attributes(
                  (nomenclature_change_status_swap_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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                @nomenclature_change.assign_attributes(
                  (nomenclature_change_status_to_synonym_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 populate_taxon_concept_fields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def populate_taxon_concept_fields
                self.parent_id = taxon_concept.parent_id_changed? ? taxon_concept.parent_id_was : taxon_concept.parent_id
                self.rank_id = taxon_concept.rank_id_changed? ? taxon_concept.rank_id_was : taxon_concept.rank_id
                self.scientific_name = taxon_concept.full_name_changed? ? taxon_concept.full_name_was : taxon_concept.full_name
                self.author_year = taxon_concept.author_year_changed? ? taxon_concept.author_year_was : taxon_concept.author_year
            Severity: Minor
            Found in app/models/nomenclature_change/output.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                @nomenclature_change.assign_attributes(
                  (nomenclature_change_lump_params || {}).merge({
                    :status => (step == steps.last ? NomenclatureChange::SUBMITTED : step.to_s)
                  })
            Severity: Minor
            Found in app/controllers/admin/nomenclature_changes/lump_controller.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 download_zip has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def download_zip
                @documents = Document.find(params[:ids].split(','))
            
                t = Tempfile.new('tmp-zip-' + request.remote_ip)
                missing_files = []
            Severity: Minor
            Found in app/controllers/api/v1/documents_controller.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 zip_file_generator has a Cognitive Complexity of 10 (exceeds 5 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

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

              def generate_mapping_table_rows(rule)
                formatted_input = input_flattening(rule)
                formatted_input.delete_if { |_, v| v.empty? }
                output = rule['output']
                modifier = output['quantity_modifier'] ? "'#{output['quantity_modifier']}'" : 'NULL'
            Severity: Minor
            Found in lib/modules/trade/formatted_codes/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 download_zip has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def download_zip
                @documents = Document.find(params[:ids].split(','))
            
                t = Tempfile.new('tmp-zip-' + request.remote_ip)
                missing_files = []
            Severity: Minor
            Found in app/controllers/api/v1/documents_controller.rb - About 1 hr to fix

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

                def perform(*args)
                  # rake "dashboard_stats:cache:update"
                  DashboardStatsCache.update_dashboard_stats
              
                  # rake "db:common_names:cleanup"
              Severity: Minor
              Found in app/jobs/sunday_cleanup_job.rb - About 1 hr to fix

                Method select_columns has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def select_columns
                    [
                      "taxon_concepts_mview.id AS id",
                      "taxon_concepts_mview.kingdom_name",
                      "taxon_concepts_mview.phylum_name",
                Severity: Minor
                Found in app/services/checklist/csv/history.rb - About 1 hr to fix

                  Method columns_with_type has 27 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/documents_importer.rb - About 1 hr to fix

                    Method update_checklist_downloads has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.update_checklist_downloads
                        puts "Updating CITES Checklist downloads"
                        modules = [
                          Checklist::Pdf,
                          Checklist::Csv,
                    Severity: Minor
                    Found in lib/modules/downloads_cache.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language