Showing 1,155 of 1,155 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
items.each do |item|
report.page.list(:list).add_row do |row|
row.item(:library).value(item.shelf.library.display_name.localize) if item.shelf && item.shelf.library
row.item(:acquired_at).value(item.acquired_at_string) if item.acquired_at_string
row.item(:bookstore).value(item.bookstore.name) if item.bookstore
- 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 93.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
items.each do |item|
report.page.list(:list).add_row do |row|
row.item(:library).value(item.shelf.library.display_name.localize) if item.shelf && item.shelf.library
row.item(:acquired_at).value(item.acquired_at_string) if item.acquired_at_string
row.item(:bookstore).value(item.bookstore.name) if item.bookstore
- 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 93.
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 reminder_list.rb
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ReminderList < ActiveRecord::Base
attr_accessible :item_identifier, :status, :mail_sent_at
default_scope :order => 'reminder_lists.id DESC'
Class NacsisCatSearch
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class NacsisCatSearch
# sunspot_solrのSearchオブジェクトとの互換層
include FormInputUtils
Method create_manifestation_from_nacsis_cat
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_manifestation_from_nacsis_cat(nacsis_cat, book_types, manifestation = nil)
return nil if nacsis_cat.blank?
ActiveRecord::Base.transaction do
child_manifestation = nil
Method set_user_value
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_user_value(user, row)
#日本語化
username = I18n.t('activerecord.attributes.user.username')
user_number = I18n.t('activerecord.attributes.user.user_number')
library = I18n.t('activerecord.attributes.user.library')
Method read_wrong_sheet
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.read_wrong_sheet(extraparams, options = { sheet: nil, default_style: nil, data: nil })
oo = Excelx.new(eval(extraparams)['filename'])
sheet_name = eval(extraparams)['sheet'] rescue nil
oo.default_sheet = sheet_name
begin
- 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 check_price
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def check_price
record = Expense.where(:item_id => self.id).order("id DESC").first
begin
unless record.nil?
record.acquired_at_ym = select_acquired_at
- 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 is_original?
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def is_original?
if self.rank == 0
manifestation = nil
if self.manifestation
manifestation = self.manifestation
- 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 generate_non_arrival_list
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_non_arrival_list(start_at, end_at)
# generate order list
logger.debug "self.generate_non_arrival_list start_at=#{start_at} end_at=#{end_at}"
order_lists = OrderList.where(:ordered_at => start_at.beginning_of_day..end_at.end_of_day)
- 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_exinfos
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.add_exinfos(exinfos, item_id)
return [] if exinfos.blank?
list = []
exinfos.each do |key, value|
name = key.split('_').first
- 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 hold_query
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def hold_query(command, db_type)
return unless @item
return @item.nacsis_identifier if command == 'delete'
query_field = command == 'update' ? ["ID=#{@item.nacsis_identifier}"] : []
- 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
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.get(keyname)
value = typename = nil
s = Rails.cache.read("#{Prefix_Key}#{keyname}")
if s
- 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_exinfos
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.add_exinfos(exinfos, manifestation_id)
return [] if exinfos.blank?
list = []
exinfos.each do |key, value|
name = key.split('_').first
- 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 18 (exceeds 5 allowed). Consider refactoring. Open
def get_list_size
unless request.xhr? && params[:list_type].present?
render :nothing => true, :status => :not_found
return
end
- 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
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create
# check checked
@selected_list_type = params[:export_item_list][:list_type]
@selected_library = params[:library].map(&:to_i) if params[:library]
@selected_carrier_type = params[:carrier_type].map(&:to_i) if params[:carrier_type]
- 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_all
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def update_all
respond_to do |format|
begin
@current_basket.checked_manifestations.map(&:manifestation).each do |m|
if m.series_statement
- 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 import
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def import(resource_import_textfile)
I18n.locale = :ja
adapter = EnjuTrunk::ResourceAdapter::Base.find_by_classname(resource_import_textfile.adapter_name)
adapter.logger = logger
- 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 prepare_options
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def prepare_options
@libraries = Library.real
@libraries.delete_if {|l| l.shelves.empty?}
if @item.new_record?
@library = Library.real.first(:order => :position, :include => :shelves)
- 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_list
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def set_list(obj, status)
unless obj.blank?
obj.each do |i|
@same_items = LossItem.where(:item_id => i.id) if obj == @items and status.blank?
@same_items = LossItem.where(:item_id => i.id, :status => status) if obj == @items and !status.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"