Showing 1,155 of 1,155 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
second_row[:detail].each do |detail|
books_row << detail[:jpn_not_donate][book_sym]
books_row << detail[:jpn_not_donate][price_sym] if conditions.money_aggregation.present?
books_row << detail[:foreign_not_donate][book_sym]
books_row << detail[:foreign_not_donate][price_sym] if conditions.money_aggregation.present?
- 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 81.
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
second_row[:detail].each do |detail|
books_row << detail[:jpn_donate][book_sym]
books_row << detail[:jpn_donate][price_sym] if conditions.money_aggregation.present?
books_row << detail[:foreign_donate][book_sym]
books_row << detail[:foreign_donate][price_sym] if conditions.money_aggregation.present?
- 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 81.
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
Method make_audio_list_pdf
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.make_audio_list_pdf(pdf_file, items)
filename = I18n.t('item_register.audio_list')
report = EnjuTrunk.new_item_list('item_list')
report.events.on :page_create do |e|
- 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 add_extexts
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.add_extexts(extexts, item_id)
return [] if extexts.blank?
list = []
extexts.each do |key, value|
next if value['value'].blank?
- 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 validate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def validate
unless item
errors[:base] << I18n.t("activerecord.errors.messages.binding_item.not_exist")
else
unless item.bookbinder_id.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 set_query
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.set_query(query = nil, birth = nil, add = nil)
date_of_birth = nil
# query
query = query.to_s
query = query.gsub("-", "") if query
- 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 can_use_purchase_request?
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def can_use_purchase_request?
role_can_use_purchase_request = SystemConfiguration.get("purchase_request.can_use")
if role_can_use_purchase_request == ''
return true
else
- 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 get_agent_import_results_tsv
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.get_agent_import_results_tsv(agent_import_results)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
columns = [
[:agent, 'activerecord.models.agent'],
- 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 update
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def update
respond_to do |format|
if @series_statement_merge_list.update_attributes(params[:series_statement_merge_list])
if params[:mode] == 'merge'
selected_series_statement = SeriesStatement.find(params[:selected_series_statement_id]) rescue 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 get_list_size
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_list_size
if !request.xhr? || params[:list_type].blank?
render :nothing => true, :status => :not_found
return
- 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 update
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def update
respond_to do |format|
if @agent_merge_list.update_attributes(params[:agent_merge_list])
if params[:mode] == 'merge'
selected_agent = Agent.find(params[:selected_agent_id]) rescue 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 parse_list_params
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def parse_list_params(library_ids, carrier_type_ids, bookstore_ids, ndcs, acquired_at, deny_blank_bookstore_ids = true)
error = []
# check required params
error << t('item_list.no_list_condition') if library_ids.blank? || carrier_type_ids.blank? || (deny_blank_bookstore_ids && bookstore_ids.blank?)
- 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 create_subject_values
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create_subject_values(add_subjects)
subjects = []
(add_subjects || []).each do |add_subject|
next if add_subject[:subject_id].blank?
if add_subject[:subject_id].to_i != 0
- 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
Function print
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Date.prototype.print = function (str) {
var m = this.getMonth();
var d = this.getDate();
var y = this.getFullYear();
var wn = this.getWeekNumber();
Method upload_info_to_nacsis
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload_info_to_nacsis(id, db_type, command)
return {} unless check_upload_params(id, db_type, command)
req_query = {}
Method daily_report
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def daily_report
@library_reports = LibraryReport.where(:id => params[:id]) rescue nil
yyyymmdd = @library_reports[0].yyyymmdd.to_s unless @library_reports.empty?
yyyymmdd = params[:library_report][:yyyymmdd].to_s if params[:library_report] && params[:library_report][:yyyymmdd]
library_ids = params[:library]
Method create
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
unless @basket
access_denied; return
end
@accept.basket = @basket
Method update
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
unless @user == current_user or current_user.has_role?('Librarian')
access_denied; return
end
unless @user.agent
File order_list.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
class OrderList < ActiveRecord::Base
include ItemsHelper
scope :not_ordered, where(:state => 'pending')
Similar blocks of code found in 2 locations. Consider refactoring. Open
grand_totals.each do |grand_total|
books_row << grand_total[:jpn_donate][book_sym]
books_row << grand_total[:jpn_donate][price_sym] if conditions.money_aggregation.present?
books_row << grand_total[:foreign_donate][book_sym]
books_row << grand_total[:foreign_donate][price_sym] if conditions.money_aggregation.present?
- 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 79.
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