sul-dlss/exhibits

View on GitHub

Showing 26 of 26 total issues

File catalog_controller.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class CatalogController < ApplicationController
  include BlacklightAdvancedSearch::Controller
  helper Openseadragon::OpenseadragonHelper

  include Blacklight::Catalog
Severity: Minor
Found in app/controllers/catalog_controller.rb - About 3 hrs to fix

    File dor_config.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'macros/general'
    require_relative 'macros/dor'
    
    require 'active_support/core_ext/object/blank'
    extend Traject::Macros::General
    Severity: Minor
    Found in lib/traject/dor_config.rb - About 2 hrs to fix

      Method page_entries_info has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def page_entries_info(collection, entry_name: nil)
          entry_name = if entry_name
                         entry_name.pluralize(collection.size, I18n.locale)
                       else
                         collection.entry_name(count: collection.size).to_s.downcase
      Severity: Minor
      Found in app/controllers/concerns/search_across_blacklight_overrides.rb - About 1 hr to fix

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

          def page_entries_info(collection, entry_name: nil)
            entry_name = if entry_name
                           entry_name.pluralize(collection.size, I18n.locale)
                         else
                           collection.entry_name(count: collection.size).to_s.downcase
        Severity: Minor
        Found in app/controllers/concerns/search_across_blacklight_overrides.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_thumbnail_url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_thumbnail_url
                return unless thumbnail_field
        
                # if a thumbnail service is available
                image = manifest['thumbnail'] if iiif_thumbnail_service?(manifest['thumbnail'])
        Severity: Minor
        Found in app/models/spotlight/resources/iiif_manifest.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 extract_annotations_from_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def extract_annotations_from_list(accumulator, url)
                annotation_list = JSON.parse(Faraday.get(url).body)
                return unless annotation_list['@type'] == 'sc:AnnotationList' && annotation_list['resources']
        
                annotation_list['resources'].each do |resource|
        Severity: Minor
        Found in lib/traject/macros/canvas.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 extract_geonames_ids has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def extract_geonames_ids(sdb)
          sdb.smods_rec.subject.map do |z|
            next unless z.geographic.any?
        
            uri = z.geographic.attr('valueURI')
        Severity: Minor
        Found in lib/traject/dor_config.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

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

            init: function (el) {
              var _this = this;
              var $el = $(el);
              var data = $el.data();
              $.getJSON(data.path, {
        Severity: Minor
        Found in app/assets/javascripts/bibliography.js - About 1 hr to fix

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

          Blacklight.onLoad(function () {
            'use strict';
          
            $('[data-behavior="exhibit-search-typeahead"]').each(function (i, element) {
              ExhibitSearchTypeahead.init($(element)); // eslint-disable-line no-undef
          Severity: Major
          Found in app/assets/javascripts/exhibit_search_typeahead.js and 2 other locations - About 55 mins to fix
          app/assets/javascripts/index_status_typeahead.js on lines 111..117
          app/assets/javascripts/site_search_type_toggle.js on lines 41..47

          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 54.

          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 3 locations. Consider refactoring.
          Open

          Blacklight.onLoad(function () {
            'use strict';
          
            $('[data-behavior="site-search-type-toggle"]').each(function (i, element) {
              SiteSearchTypeToggle.init($(element)); // eslint-disable-line no-undef
          Severity: Major
          Found in app/assets/javascripts/site_search_type_toggle.js and 2 other locations - About 55 mins to fix
          app/assets/javascripts/exhibit_search_typeahead.js on lines 99..105
          app/assets/javascripts/index_status_typeahead.js on lines 111..117

          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 54.

          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 3 locations. Consider refactoring.
          Open

          Blacklight.onLoad(function () {
            'use strict';
          
            $('[data-behavior="index-status-typeahead"]').each(function (i, element) {
              IndexStatusTypeahead.init($(element)); // eslint-disable-line no-undef
          Severity: Major
          Found in app/assets/javascripts/index_status_typeahead.js and 2 other locations - About 55 mins to fix
          app/assets/javascripts/exhibit_search_typeahead.js on lines 99..105
          app/assets/javascripts/site_search_type_toggle.js on lines 41..47

          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 54.

          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

          Method flatten_top_level has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def flatten_top_level(attributes)
                flatten = %w(
                  id modsxml druid last_updated url_fulltext display_type collection_type
                  author_1xx_search
                  title_245_search title_245a_display title_245a_search title_display title_sort
          Severity: Minor
          Found in lib/traject/adjust_cardinality.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

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

          Blacklight.onLoad(function () {
            'use strict';
          
            $('[data-behavior="bibliography-contents"]').each(function (i, element) {
              Bibliography.init(element); // eslint-disable-line no-undef
          Severity: Minor
          Found in app/assets/javascripts/bibliography.js and 1 other location - About 45 mins to fix
          app/assets/javascripts/cited_documents.js on lines 34..40

          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 50.

          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

          Method resource_images_iiif_urls has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def resource_images_iiif_urls
                  lambda do |resource, accumulator, _context|
                    content_metadata = resource.public_xml.at_xpath('/publicObject/contentMetadata')
                    next if content_metadata.nil?
          
          
          Severity: Minor
          Found in lib/traject/macros/dor.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

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

          Blacklight.onLoad(function () {
            'use strict';
          
            $('[data-behavior="cited-documents-contents"]').each(function (i, element) {
              CitedDocuments.init(element); // eslint-disable-line no-undef
          Severity: Minor
          Found in app/assets/javascripts/cited_documents.js and 1 other location - About 45 mins to fix
          app/assets/javascripts/bibliography.js on lines 93..99

          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 50.

          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

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def initialize(id, iiif_id, label, annotation_lists, annotations)
          Severity: Minor
          Found in app/models/canvas.rb - About 35 mins to fix

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

            to_field 'author_no_collector_ssim' do |resource, accumulator|
              non_collector_authors = resource.smods_rec.personal_name.select { |n| n.role.any? }.reject { |n| n.role.all? { |r| includes_marc_relator_role?(r, value: 'Collector', value_uri: 'http://id.loc.gov/vocabulary/relators/col') } }
            
              accumulator.concat(non_collector_authors.map(&:display_value_w_date))
            Severity: Minor
            Found in lib/traject/dor_config.rb and 1 other location - About 35 mins to fix
            lib/traject/dor_config.rb on lines 156..159

            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 36.

            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

            to_field 'collector_ssim' do |resource, accumulator|
              collectors = resource.smods_rec.personal_name.select { |n| n.role.any? }.reject { |n| n.role.any? { |r| includes_marc_relator_role?(r, value: 'Collector', value_uri: 'http://id.loc.gov/vocabulary/relators/col') } }
            
              accumulator.concat(collectors.map(&:display_value_w_date))
            Severity: Minor
            Found in lib/traject/dor_config.rb and 1 other location - About 35 mins to fix
            lib/traject/dor_config.rb on lines 144..147

            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 36.

            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

            Method extract_canvas_annotations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def extract_canvas_annotations
                    lambda do |record, accumulator, _context|
                      return if record['otherContent'].blank?
            
                      record['otherContent'].each do |link|
            Severity: Minor
            Found in lib/traject/macros/canvas.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 extract_canvas_annotation_list_urls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def extract_canvas_annotation_list_urls
                    lambda do |record, accumulator, _context|
                      return if record['otherContent'].blank?
            
                      record['otherContent'].each do |link|
            Severity: Minor
            Found in lib/traject/macros/canvas.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

            Severity
            Category
            Status
            Source
            Language