Showing 234 of 234 total issues
File opac.rb
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Opac < Service
attr_reader :record_attributes, :display_name
# The Opac class has a few assumptions
# * You have some sort of bib client to get MARC records from your OPAC
Method find_by_title
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_by_title
connection = sfx4_db_connection
query_match_clause = case search_type_param
when "contains"
terms = title_query_param.split(" ")
Similar blocks of code found in 2 locations. Consider refactoring. Open
items = $(items).map(function (i, item) {
i = $(that.options.item).attr('data-value', item)
i.find('a').html(that.highlighter(item))
return i[0]
})
- Read upRead up
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 88.
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. Open
items = $(items).map(function (i, item) {
i = $(that.options.item).data('value', item);
i.find('a').html(that.highlighter(item));
return i[0];
});
- Read upRead up
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 88.
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 referent.rb
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'i18n'
require 'truncate_to_db_limit'
# Note: There are a few actual attributes stored as Columns in referent --
# these were originally used for identifying a Referent identifying the
Method handle
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle(request, session_id)
return if (@services.nil? || @services.empty?)
bundle_start = Time.now
Rails.logger.info(TermColor.color("Umlaut: Launching service wave #{@priority_level} #{'(non-threaded)' unless config.lookup!("threaded_service_wave", true) }", :yellow) + ", request #{request.id}") if @log_timing
Method gen_lamr_request
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gen_lamr_request(request)
output = ""
builder = Builder::XmlMarkup.new(:target => output, :indent => 2)
builder.instruct!(:xml, :encoding => "UTF-8")
Method add_asin_service_responses
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def add_asin_service_responses(request, asin, item_url)
# we want to highlight Amazon to link to 'search in this book', etc.
if asin
# Search or Look inside the book offered? We only know by trying and
# then screen-scraping.
- Read upRead up
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 handle
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def handle(request)
ids_processed = []
holdings_added = 0
if (@identifier_search && url = blacklight_precise_search_url(request) )
- Read upRead up
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 google_book_search.rb
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
class GoogleBookSearch < Service
require 'multi_json'
# Identifiers used in API response to indicate viewability level
Method normalize_params
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def normalize_params
# citation search params
# sfx.title_search and umlaut.title_search_type are synonyms
params["sfx.title_search"] = params["umlaut.title_search_type"] if params["sfx.title_search"].blank?
Method handle
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle(request)
scopus_query = scopus_query(request)
# we can't make a good query, nevermind.
return request.dispatched(self, true) if scopus_query.blank?
Method create_partial_volume_responses
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create_partial_volume_responses(request, ht_json)
items = ht_json.values.first["items"]
full_ids = items.collect do |i|
i["fromRecord"] if (is_serial_part?(i) && full_view?(i))
end.compact.uniq
- Read upRead up
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 do_query
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_query(request)
# get the search terms for use in both fulltext search and highlighted_link
# IA does index apostrophes, although not generally other puncutation. Need to keep em.
search_terms = {:title => get_search_title(request.referent ,:keep_apostrophes=>true),
:creator => get_search_creator(request.referent)}
Class SectionRenderer
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class SectionRenderer
include ActionView::Helpers::TagHelper
# First argument is the current umlaut Request object.
# Second argument is a session description hash. See class overview
Method to_citation
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_citation
citation = {}
# call self.metadata once and use the array for efficiency, don't
# keep calling it. profiling shows it DOES make a difference.
my_metadata = self.metadata
Method enhance_referent
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def enhance_referent(body, request)
doc = Nokogiri::XML(body)
return unless cite = doc.at("PubmedArticleSet/PubmedArticle/MedlineCitation") # Nothing of interest here
return unless article = cite.at("Article") # No more useful metadata
Method preempted_by
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def preempted_by(uml_request, for_type_generated=nil)
preempted_by = @preempted_by
return false if preempted_by.nil?
preempted_by = [preempted_by] unless preempted_by.kind_of?(Array)
preemption = nil
- Read upRead up
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 freshen_dispatches!
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def freshen_dispatches!
umlaut_request.dispatched_services.each do | ds |
# go through dispatched_services and set still in progress but too long to failed temporary
if ( (ds.status == DispatchedService::InProgress ||
ds.status == DispatchedService::Queued ) &&
- Read upRead up
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 searchPath
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def searchPath(args = {})
args[:xml] = true if args[:xml].nil?
path = self.hip_base_url.path() + '?' "menu=search&aspect=power&npp=30&ipp=20&spp=20&profile=general&ri=2"
- Read upRead up
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"