Showing 1,155 of 1,155 total issues
Method write_parts
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def write_parts(zip)
p = parts
p.each do |part|
unless part[:doc].nil?
zip.put_next_entry(part[:entry])
- 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 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import
num = {:manifestation_imported => 0, :item_imported => 0, :manifestation_found => 0, :item_found => 0, :failed => 0}
row_num = 2
rows = open_import_file
field = rows.first
Class ManifestationsController
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class ManifestationsController < ApplicationController
authorize_function
add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path', :only => [:index] #, :unless => proc{params}
# add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path(params)', :only => [:index], :if => proc{params}
add_breadcrumb "I18n.t('page.showing', :model => I18n.t('activerecord.models.manifestation'))", 'manifestation_path(params[:id])', :only => [:show]
Method make_catalog_pdf
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def self.make_catalog_pdf(pdf_file, manifestations, list_title = nil)
report = EnjuTrunk.new_report("#{list_title}.tlf")
#report page
report.events.on :page_create do |e|
e.page.item(:page).value(e.page.no)
- 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 33 (exceeds 5 allowed). Consider refactoring. Open
def update
if params[:manifestation][:identifiers_attributes]
params[:manifestation][:identifiers_attributes].each do |key, identifier_attributes|
if identifier_attributes[:body].blank?
params[:manifestation][:identifiers_attributes]["#{key}"][:_destroy] = 1
- 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 build_select2
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def build_select2(selector_id, selector_name, collection, selected_id, options)
include_blank = options[:include_blank] || false
alt_display = options.has_key?(:alt_display) ? options[:alt_display] : true
width = options[:width] || 300
select_attribute = options[:select_attribute] || :v
- 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 cellClick
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
Calendar.cellClick = function(el, ev) {
var cal = el.calendar;
var closing = false;
var newdate = false;
var date = null;
File agent_import_file.rb
has 369 lines of code (exceeds 250 allowed). Consider refactoring. Open
class AgentImportFile < ActiveRecord::Base
attr_accessible :agent_import, :edit_mode
include ImportFile
default_scope :order => 'id DESC'
scope :not_imported, where(:state => 'pending', :imported_at => nil)
Similar blocks of code found in 3 locations. Consider refactoring. Open
def self.get_user_checkout_stats_tsv(user_checkout_stat, stats)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
# term
- 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 162.
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
def self.get_user_reserve_stats_tsv(user_reserve_stat, stats)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
# term
- 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 162.
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
def self.get_manifestation_reserve_stats_tsv(manifestation_reserve_stat, stats)
data = String.new
data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
# term
- 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 162.
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
Function drilldown
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
Menu.prototype.drilldown = function(container, options) {
var menu = this;
var topList = container.find('.fg-menu');
var breadcrumb = $('<ul class="fg-menu-breadcrumb ui-widget-header ui-corner-all ui-helper-clearfix"></ul>');
var crumbDefaultHeader = $('<li class="fg-menu-breadcrumb-text">'+options.crumbDefaultText+'</li>');
Method index
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def index
@term = Term.current_term
@terms = Term.find(:all, :order => "start_at")
@results = []
@budget_sum = 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 update_manifestation_agents
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def update_manifestation_agents(sheet, datas, field, manifestation, error_msgs)
create_new = SystemConfiguration.get("add_only_exist_agent") == true
[
["#{field}.creator", :creates=, :creates],
- 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 make_form_boolean
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
def make_form_boolean(string, system_configuration)
['true', 'false'].each do |state|
string << "<input type=radio
name=system_configurations[#{ system_configuration.id }]
value=#{state} "
Function _keyEvent
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
Calendar._keyEvent = function(ev) {
var cal = window._dynarch_popupCalendar;
if (!cal || cal.multiple)
return false;
(Calendar.is_ie) && (ev = window.event);
File approvals_controller.rb
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApprovalsController < ApplicationController
add_breadcrumb "I18n.t('page.listing', model: t('activerecord.models.approval'))", 'approvals_path'
add_breadcrumb "I18n.t('page.new', model: I18n.t('activerecord.models.approval'))", 'new_approval_path', only: [:new, :create]
add_breadcrumb "I18n.t('page.editing', :model => I18n.t('activerecord.models.approval'))", 'edit_approval_path(params[:id])', only: [:edit, :update]
add_breadcrumb "I18n.t('activerecord.models.approval')", 'approval_path([:id])', only: [:show]
Method hiduke2yyyymmdd_sub
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def self.hiduke2yyyymmdd_sub(datestr)
yyyymmdd_from = nil
yyyymmdd_to = nil
dfrom = nil
dto = 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 index
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def index
begin
if !current_user.has_role?('Librarian')
if @question
raise unless @question.shared?
- 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 identify_manifestation
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def identify_manifestation(datas, sheet)
Rails.logger.debug "identify_manifestation"
scope = Manifestation.scoped
scope = scope.readonly(false)
- 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"