psu-libraries/psulib_blacklight

View on GitHub

Showing 24 of 39 total issues

Function SpecialRequestLink has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

const SpecialRequestLink = ({ holding, locationText }) => {
  const [hasData, setHasData] = useState(false);
  const [showSpinner, setShowSpinner] = useState(true);
  const [url, setUrl] = useState('#');
  const { catkey } = holding;
Severity: Minor
Found in app/javascript/availability/components/special_request_link.jsx - 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

File index.js has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @file
 * Real Time Availability
 */

Severity: Minor
Found in app/javascript/availability/index.js - About 6 hrs to fix

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

class CatalogController < ApplicationController
  include BlacklightAdvancedSearch::Controller
  include BlacklightRangeLimit::ControllerOverride
  include Blacklight::Catalog
  include Blacklight::Configurable
Severity: Minor
Found in app/controllers/catalog_controller.rb - About 4 hrs to fix

Function loadAvailability has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  loadAvailability() {
    const titleIDs = [];
    const summaryHoldings = {};

    // Get the catkeys
Severity: Major
Found in app/javascript/availability/index.js - About 2 hrs to fix

Function processBoundParents has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  processBoundParents(boundHoldings, allHoldings, summaryHoldings) {
    const catkeys = Object.keys(boundHoldings);

    let itemIDs = [];
    $.each(catkeys, (i, catkey) => {
Severity: Major
Found in app/javascript/availability/index.js - About 2 hrs to fix

Function blCheckboxSubmit has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.blCheckboxSubmit = function (argOpts) {
    this.each(function () {
      const options = $.extend({}, $.fn.blCheckboxSubmit.defaults, argOpts);

      const form = $(this);
Severity: Major
Found in app/javascript/blacklight_overrides/javascripts/checkbox_submit.js - About 2 hrs to fix

Class SolrManager has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class SolrManager
    ALLOWED_TIME_TO_RESPOND = 30

    attr_reader :config

Severity: Minor
Found in lib/psulib_blacklight/solr_manager.rb - About 2 hrs to fix

Function availabilityDisplay has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  availabilityDisplay(allHoldings, summaryHoldings) {
    $('.availability').each(function () {
      const availabilityHTML = $(this);
      const catkey = availabilityHTML.data('keys');
      const isOnlineOnOrderOnly = availabilityHTML.data('isOnlineOnOrderOnly');
Severity: Major
Found in app/javascript/availability/index.js - About 2 hrs to fix

Function setGooglePreview has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export default function setGooglePreview() {
  const element = document.getElementById('google-preview');
  const urlComponents = {
    googlePreviewUrl: '/links/google-preview-data',
    searchItem: element?.dataset?.searchItem,

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 getBoundHoldings has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getBoundHoldings(boundHoldings, titleInfo) {
    boundHoldings[titleInfo.catkey] = [];

    titleInfo.jQueryObj.children('BoundwithLinkInfo').each(function () {
      const linkedAsParent = $(this).children('linkedAsParent').text();
Severity: Minor
Found in app/javascript/availability/index.js - About 1 hr to fix

Function clicked has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async clicked() {
    for (let i = 0; i < this.forms.length; i += 1) {
      if (!this.checked(i)) {
        this.forms[i].querySelector('span').innerHTML =
          this.forms[i].getAttribute('data-inprogress');
Severity: Minor
Found in app/javascript/psulib_blacklight/javascripts/checkbox_submit_all.js - About 1 hr to fix

Function setGooglePreview has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function setGooglePreview() {
  const element = document.getElementById('google-preview');
  const urlComponents = {
    googlePreviewUrl: '/links/google-preview-data',
    searchItem: element?.dataset?.searchItem,

Method get_item_location_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get_item_location_data(holding)
      item_location_data = []
      if holding['ItemInfo'].is_a?(Array)
        holding['ItemInfo'].each do |item|
          if item_location_data.size >= 3
Severity: Minor
Found in app/services/holdings_request_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 index has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    cache_key = nil
    # No other params presents indicates we are on the homepage
    if params.keys.eql? %w[controller action]
      cache_key = "#{params['controller']}/#{params['action']}facet_query"
Severity: Minor
Found in app/controllers/catalog_controller.rb - About 1 hr to fix

Function availabilityDataStructurer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  availabilityDataStructurer(holdingMetadata) {
    const availabilityStructuredData = [];
    let holdingData = [];
    let pluralize = '';
    let library = '';
Severity: Minor
Found in app/javascript/availability/index.js - About 1 hr to fix

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

      def url
        url_opts = @url_opts.merge(({ id: @document } if @document) || {})
        if @action.path
          helpers.public_send(@action.path, url_opts)
        elsif url_opts[:id].class.respond_to?(:model_name)
Severity: Minor
Found in app/components/blacklight/document/action_component.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 follow_redirects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def follow_redirects(url)
      host = URI.parse(url).host

      # Skip any further redirect business if we already know that we're going to get a
      # response with good CORS headers.
Severity: Minor
Found in app/models/solr_document.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 get_data_from_call_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_data_from_call_info(call_info)
      availability = []
      call_info.each do |holding|
        if availability.size >= 30
          @view_more = true
Severity: Minor
Found in app/services/holdings_request_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

Function clicked has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async clicked() {
    for (let i = 0; i < this.forms.length; i += 1) {
      if (!this.checked(i)) {
        this.forms[i].querySelector('span').innerHTML =
          this.forms[i].getAttribute('data-inprogress');
Severity: Minor
Found in app/javascript/psulib_blacklight/javascripts/checkbox_submit_all.js - 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 login has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def login
    session[:groups] = request.env.fetch(Settings.groups_header, '').split(',')
    redirect_location = params['fullpath'] || stored_location_for(User) || '/'
    if current_user
      flash[:success] = I18n.t('blackcat.successful_login')
Severity: Minor
Found in app/controllers/application_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

Severity
Category
Status
Source
Language