Showing 30 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;
- Read upRead up
- Create a ticketCreate a ticket
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
*/
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Confirmed
{locationData.supplement.length > 0 && (
<li>
<div className="h6 mt-2">
<span className="sr-only">{locationName}</span>
Supplements
- Read upRead up
- Create a ticketCreate a ticket
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 138.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Confirmed
{locationData.index.length > 0 && (
<li>
<div className="h6 mt-2">
<span className="sr-only">{locationName}</span>
Indexes
- Read upRead up
- Create a ticketCreate a ticket
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 138.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Create a ticketCreate a ticket
Function loadAvailability
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
loadAvailability() {
const titleIDs = [];
const summaryHoldings = {};
// Get the catkeys
- Create a ticketCreate a ticket
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) => {
- Create a ticketCreate a ticket
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);
- Create a ticketCreate a ticket
Class SolrManager
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class SolrManager
ALLOWED_TIME_TO_RESPOND = 30
attr_reader :config
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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,
- Read upRead up
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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,
- Create a ticketCreate a ticket
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
- Read upRead up
- Create a ticketCreate a ticket
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 availabilityDataStructurer
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
availabilityDataStructurer(holdingMetadata) {
const availabilityStructuredData = [];
let holdingData = [];
let pluralize = '';
let library = '';
- Create a ticketCreate a ticket
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"
- Create a ticketCreate a ticket
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.
- Read upRead up
- Create a ticketCreate a ticket
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 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)
- Read upRead up
- Create a ticketCreate a ticket
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
class GooglePreviewLinkComponent < HathiGoogleLinksComponent
def search_item
return nil if free_to_read?
return "LCCN:#{lccn}" if lccn.present?
- Read upRead up
- Create a ticketCreate a ticket
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 39.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76