LafayetteCollegeLibraries/spot

View on GitHub

Showing 25 of 25 total issues

Method validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(record)
      Array.wrap(options[:fields]).each do |field|
        next unless record.respond_to?(field)

        slugs = record.send(field).select { |id| id.start_with? 'slug:' }
Severity: Minor
Found in app/validators/spot/slug_validator.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 add_assertions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def add_assertions(*)
      object.controlled_properties.each do |property|
        object[property].each do |value|
          resource = value.respond_to?(:resource) ? value.resource : value
          next unless resource.is_a?(ActiveTriples::Resource)
Severity: Minor
Found in app/services/spot/deep_indexing_service.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 transform_language_tagged_fields! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def transform_language_tagged_fields!(params)
      return unless respond_to?(:language_tagged_fields)

      language_tagged_fields.flatten.each do |field|
        value_key = "#{field}_value"
Severity: Minor
Found in app/forms/concerns/language_tagged_form_fields.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(record)
      fields.each do |field|
        next unless record.respond_to?(field)

        values = record.send(field)
Severity: Minor
Found in app/validators/spot/only_urls_validator.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 model_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def model_attributes(form_params)
      super.tap do |params|
        terms.each do |key|
          if params[key].is_a? Array
            params[key] = params[key].map { |v| v.respond_to?(:strip) ? v.strip : v }.reject(&:blank?)
Severity: Minor
Found in app/forms/concerns/strips_whitespace.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 default_terms has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def default_terms
      %i[
        id
        title
        title_alternative
Severity: Minor
Found in app/services/spot/work_csv_service.rb - About 1 hr to fix

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

        def find_renderer_class(name)
          renderer = nil
          ['Renderer', 'AttributeRenderer'].each do |suffix|
            const_name = "#{name.to_s.camelize}#{suffix}".to_sym
            renderer =
    Severity: Minor
    Found in app/presenters/concerns/spot/presents_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 generate_solr_document has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Confirmed

      def generate_solr_document
        super.tap do |doc|
          # bibliographic_citation is a part of Spot::CoreMetadata, which is included on all works,
          # but this should safeguard in the event that's not the case in the future
          next doc unless object.respond_to?(:bibliographic_citation) && object.bibliographic_citation.present?
    Severity: Minor
    Found in app/indexers/concerns/indexes_citation_metadata.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 clear_expired_embargoes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def clear_expired_embargoes(regenerate_thumbnails: false)
            ::Hyrax::EmbargoService.assets_with_expired_embargoes.each do |presenter|
              item = ActiveFedora::Base.find(presenter.id)
    
              next if item.under_embargo?
    Severity: Minor
    Found in app/services/spot/embargo_lease_service.rb - About 45 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 manifest_metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def manifest_metadata
          metadata_fields.map do |field|
            raw_values = send(field.to_sym)
            next if raw_values.blank?
    
    
    Severity: Minor
    Found in app/presenters/spot/iiif_manifest_presenter.rb - About 45 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 content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def content
          ::CSV.generate do |csv|
            csv << terms.map do |term|
              values = work.respond_to?(term) ? work.send(term) : ''
              values = values.respond_to?(:to_a) ? values.to_a : [values]
    Severity: Minor
    Found in app/services/spot/work_csv_service.rb - About 45 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 clear_expired_leases has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def clear_expired_leases(regenerate_thumbnails: false)
            ::Hyrax::LeaseService.assets_with_expired_leases.each do |presenter|
              item = ActiveFedora::Base.find(presenter.id)
    
              next if item.active_lease?
    Severity: Minor
    Found in app/services/spot/embargo_lease_service.rb - About 45 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 append_to_solr_doc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def append_to_solr_doc(solr_doc, solr_field_key, field_info, value)
          return super unless object.controlled_properties.include?(solr_field_key.to_sym)
    
          value_uri, value_label_hash = value.respond_to?(:solrize) ? value.solrize : [value, { label: value }]
    
    
    Severity: Minor
    Found in app/services/spot/deep_indexing_service.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 add_english_language_dates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_english_language_dates(solr_doc)
        solr_doc[english_language_date_field] = dates.map do |date|
          begin
            parsed = Date.parse(date)
          rescue ArgumentError
    Severity: Minor
    Found in app/indexers/concerns/indexes_english_language_dates.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 store_years_encompassed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def store_years_encompassed(doc)
        raw_values = [:date, :date_associated].map { |s| object.send(s) }.map(&:to_a).flatten
        years = raw_values.reduce([]) do |dates, date|
          parsed = Date.edtf(date)
          next (dates + [parsed.year]) if parsed.is_a? Date
    Severity: Minor
    Found in app/indexers/image_indexer.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(record)
          authority_name = options[:authority]
          field = options[:field]
          authority = authority_for(authority_name)
    
    
    Severity: Minor
    Found in app/validators/spot/required_local_authority_validator.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 load_and_authorize_resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_and_authorize_resource
          search_params = params
          search_params.delete :page
          search_params.delete :type
    
    
    Severity: Minor
    Found in app/controllers/spot/export_controller.rb - About 25 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 add_rights_statement_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_rights_statement_label(doc)
        doc[value_key] ||= []
        doc[label_key] ||= []
        doc[shortcode_key] ||= []
    
    
    Severity: Minor
    Found in app/indexers/concerns/indexes_rights_statements.rb - About 25 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_field_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_field_options(value, _index)
        return super if defined?(super)
    
        dom_id = input_dom_id if respond_to?(:input_dom_id)
        dom_id ||= "#{object_name}_#{attribute_name}"
    Severity: Minor
    Found in app/inputs/concerns/language_tagging.rb - About 25 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 add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def add(env, id)
            collection = ::Collection.find(id)
    
            return unless env.current_ability.can?(:deposit, collection)
    
    
    Severity: Minor
    Found in app/actors/spot/actors/collections_membership_actor.rb - About 25 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