Showing 1,155 of 1,155 total issues
Method update_manifestation_classifications
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_manifestation_classifications(sheet, datas, field, manifestation, error_msgs)
return unless field == 'book'
classification_field = "#{field}.classification"
classification_type_field = "#{field}.classification_type"
Method index
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@selected_circulation_ids = params[:circulation_status].map{|s| s.to_i} if params[:circulation_status]
if params[:pdf] || params[:tsv]
@displist = []
if params[:circulation_status].blank?
Method find_same_item
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_same_item(attrs, manifestation_type)
conditions = ["((manifestations).manifestation_type_id = \'#{manifestation_type.id}\')"] # FIXME!
attrs.each do |key, value|
case key
when 'creators', 'subjects'
Method fixup_config_application
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fixup_config_application
target = 'config/application.rb'
gsub_file target, /^(\s*)(class Application < Rails::Application)\n/, <<-'E'
\1\2
Similar blocks of code found in 3 locations. Consider refactoring. Open
detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 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 62.
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 3 locations. Consider refactoring. Open
sum_detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 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 62.
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 3 locations. Consider refactoring. Open
grand_total = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
:not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 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 62.
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 get
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get(keyname)
value = typename = nil
s = Rails.cache.read("#{Prefix_Key}#{keyname}")
if s
Method get_purchase_requests_tsv
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_purchase_requests_tsv(purchase_requests)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
columns = [
[:original_title, 'activerecord.attributes.manifestation.original_title'],
Method get_result_list
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_result_list(list_type, ranks, checkouts)
user_file = UserFile.new(current_user)
excel_filepath, excel_fileinfo = user_file.create(list_type, Setting.bestreader_excelx.filename)
begin
Method new_search_internal
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_search_internal(manifestation_type = :all)
search = Sunspot.new_search(Manifestation)
Manifestation.build_search_for_manifestations_list(search, @query, @with_filter, @without_filter)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def create
@item_has_use_restriction = ItemHasUseRestriction.new(params[:item_has_use_restriction])
respond_to do |format|
if @item_has_use_restriction.save
- 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 61.
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
def create
@library_report = LibraryReport.new(params[:library_report])
respond_to do |format|
if @library_report.save
- 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 61.
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 get_resource_import_textresults_excelx
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_resource_import_textresults_excelx(resource_import_textresults)
# initialize
out_dir = "#{Rails.root}/private/system/manifestations_list_excelx"
excel_filepath = "#{out_dir}/list#{Time.now.strftime('%s')}#{rand(10)}.xlsx"
FileUtils.mkdir_p(out_dir) unless FileTest.exist?(out_dir)
Method send_message
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_message(status, reason = nil)
system_user = User.find(1) # TODO: システムからのメッセージの発信者
PurchaseRequest.transaction do
case status
when 'accepted'
Method new_work_has_titles_from_nacsis_cat
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_work_has_titles_from_nacsis_cat(nacsis_cat)
return [] if nacsis_cat.blank?
nacsis_info = nacsis_cat.detail
wht_ary = []
nacsis_info[:other_titles].each do |other_title|
Method make_export_item_list_tsv
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.make_export_item_list_tsv(items)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
columns = [
[:library, 'activerecord.models.library'],
Method create_with_params
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_with_params(params, has_role_id)
logger.debug "create_with_params start."
user = User.new
user.assign_attributes(params, :as => :admin)
Method val_keyword
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def val_keyword
# 先頭に数字が混ざる可能性があるため、検証する開始文字位置を定める
string_location = 0
keyword.split("").each do |spelling|
if string_location == 0 then
- 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 excel_worksheet_value
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def excel_worksheet_value(ws_type, ws_col, sep_flg, ccount)
helper = Object.new
helper.extend(ItemsHelper)
helper.instance_eval { def t(*a) I18n.t(*a) end } # NOTE: ItemsHelper#i18n_rankの中でtを呼び出しているが、ヘルパーを直接利用しようとするとRedCloth由来のtが見えてしまうため、その回避策
val = 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"