archivesspace/archivesspace

View on GitHub

Showing 1,505 of 2,469 total issues

Method returns has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

    def returns(*returns, &block)
      raise "No .permissions declaration for endpoint #{@methods.map {|m| m.to_s.upcase}.join('|')} #{@uri}" if !@has_permissions

      @returns = returns.map { |r| r[1] = @@return_types[r[1]] || r[1]; r }

Severity: Minor
Found in backend/app/lib/rest.rb - About 1 day 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

File archival_objects.crud.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//= require agents.crud
//= require subjects.crud
//= require dates.crud
//= require notes.crud
//= require instances.crud
Severity: Major
Found in frontend/app/assets/javascripts/archival_objects.crud.js - About 1 day to fix

    Method preview_sort_name has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

      def preview_sort_name(target)
        result = ""
    
        case target['jsonmodel_type']
        when 'name_person'
    Severity: Minor
    Found in backend/app/lib/merge_helpers.rb - About 1 day 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 serialize_digital_object has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

      def serialize_digital_object(digital_object, xml, fragments)
        return if digital_object["publish"] === false && !@include_unpublished
        return if digital_object["suppressed"] === true
    
        # ANW-285: Only serialize file versions that are published, unless include_unpublished flag is set
    Severity: Minor
    Found in backend/app/exporters/serializers/ead.rb - About 7 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 apply_nested_records has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_nested_records(json, new_record = false)
          self.remove_nested_records if !new_record
    
          self.class.nested_records.each do |nested_record|
            # Read the subrecords from our JSON blob and fetch or create
    Severity: Minor
    Found in backend/app/model/ASModel_crud.rb - About 7 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 dataset_iterator has 197 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def dataset_iterator(&block)
        DB.open do |db|
          @ao_ids.each_slice(BATCH_SIZE) do |batch|
            base_fields = [:id, :lock_version] + FIELDS_OF_INTEREST.fetch(:archival_object).map {|field| field.column}
            base = ArchivalObject
    Severity: Major
    Found in backend/app/model/spreadsheet_builder.rb - About 7 hrs to fix

      Method set_up_base_permissions has 196 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.set_up_base_permissions
          if not Repository[:repo_code => Repository.GLOBAL]
            Repository.create(:repo_code => Repository.GLOBAL,
                              :name => "Global repository",
                              :json_schema_version => JSONModel(:repository).schema_version,
      Severity: Major
      Found in backend/app/lib/bootstrap_access_control.rb - About 7 hrs to fix

        File bootstrap-accessibility.js has 491 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* ========================================================================
        * Extends Bootstrap v3.1.1
        
        * Copyright (c) <2015> PayPal
        
        

          File trollop.rb has 490 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'date'
          
          module Trollop
          
          VERSION = "2.0"
          Severity: Minor
          Found in launcher/backup/lib/trollop.rb - About 7 hrs to fix

            Method archdesc_dates has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
            Open

                def archdesc_dates
                  unless @archdesc_dates
                    results = []
                    dates = self.dates || []
                    dates.each do |date|
            Severity: Minor
            Found in backend/app/exporters/lib/export_helpers.rb - About 7 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

            Function initImportJobForm has 188 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var initImportJobForm = function () {
                var supportsHTML5MultipleFileInput = function () {
                  var input = document.createElement('input');
                  input.setAttribute('multiple', 'true');
                  return input.multiple === true;
            Severity: Major
            Found in frontend/app/assets/javascripts/jobs.crud.js - About 7 hrs to fix

              Method process_row has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
              Open

                def process_row(row_hash = nil)
                  #This allows the processing of a single row
                  if (!row_hash.nil?)
                    @row_hash = row_hash
                  end
              Severity: Minor
              Found in backend/app/lib/bulk_import/top_container_linker_validator.rb - About 7 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

              Function ClipboardAction has 185 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          var ClipboardAction = (function () {
                            /**
                             * @param {Object} options
                             */
                            function ClipboardAction(options) {
              Severity: Major
              Found in frontend/app/assets/javascripts/clipboard.js - About 7 hrs to fix

                Method defaults has 182 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.defaults
                    {
                      'show_suppressed' => false,
                      'publish' => false,
                      'rde_sort_alpha' => true,
                Severity: Major
                Found in common/config/preference_defaults.rb - About 7 hrs to fix

                  File rest.rb has 465 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module RESTHelpers
                  
                    include JSONModel
                  
                  
                  
                  Severity: Minor
                  Found in backend/app/lib/rest.rb - About 7 hrs to fix

                    Method serialize_subnotes has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def serialize_subnotes(subnotes, xml, fragments, include_p = true)
                        subnotes.each do |sn|
                          next if sn["publish"] === false && !@include_unpublished
                    
                          audatt = sn["publish"] === false ? {:audience => 'internal'} : {}
                    Severity: Minor
                    Found in backend/app/exporters/serializers/ead.rb - About 7 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 serialize_subnotes has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def serialize_subnotes(subnotes, xml, fragments, include_p = true)
                        subnotes.each do |sn|
                          next if sn["publish"] === false && !@include_unpublished
                    
                          audatt = sn["publish"] === false ? {:audience => 'internal'} : {}
                    Severity: Minor
                    Found in backend/app/exporters/serializers/ead3.rb - About 7 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 migrate_langmaterial_notes has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def migrate_langmaterial_notes
                      # Find all langmaterial notes
                      self[:note].each do |note_id|
                        if note_id[:notes].lit.include?('langmaterial')
                    
                    
                    Severity: Minor
                    Found in common/db/migrations/123_create_lang_materials_schema.rb - About 7 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 IndexerCommon has 50 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class IndexerCommon
                    
                      include JSONModel
                    
                      @@record_types = IndexerCommonConfig.record_types
                    Severity: Minor
                    Found in indexer/app/lib/indexer_common.rb - About 7 hrs to fix

                      Class ApplicationController has 50 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ApplicationController < ActionController::Base
                        include ActionView::Helpers::TranslationHelper
                        protect_from_forgery with: :exception
                      
                        helper :all
                      Severity: Minor
                      Found in frontend/app/controllers/application_controller.rb - About 7 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language