Showing 48 of 101 total issues
Method initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
- 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_menu_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def build_menu_items(menu)
returns = ""
menu[:items].each do |item|
rails_model = item.to_s.titlecase.gsub(' ','').singularize.to_sym
- 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 _updateDateTime
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_updateDateTime: function(dp_inst) {
dp_inst = this.inst || dp_inst;
var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
formatCfg = $.datepicker._getFormatConfig(dp_inst),
Function load_feed
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function load_feed(etext) {
counter = 0;
if (options.json_url && maxItems()) {
if (options.cache && json_cache_object.get(etext)) {
addMembers(etext);
Function _doKeyPress
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.datepicker._doKeyPress = function(event) {
var inst = $.datepicker._getInst(event.target),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
Function addItem
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addItem(title, value, preadded, locked, focusme) {
if (!maxItems()) {
return false
}
var liclass = "bit-box" + (locked ? " locked": "");
Avoid deeply nested control flow statements. Open
if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
Avoid deeply nested control flow statements. Open
if (h == 0) tmph = 12 +'a';
else if (h < 12) tmph += 'a';
else tmph += 'p';
Avoid deeply nested control flow statements. Open
if(this.millisec < this._defaults.millisecMin)
this.millisec = this._defaults.millisecMin;
Avoid deeply nested control flow statements. Open
} else if (aph == 12) h = 12;
else h = aph + 12;
Method search_by_params
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.search_by_params(results=nil, query)
results = self.send(:relation) if results.nil?
where = {}
- 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 migrate!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def migrate!
raise "schema_from needs" if @schema_from.nil?
raise "schema_to needs" if @schema_to.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
Avoid deeply nested control flow statements. Open
if (aph == 12) h = 0;
else h = aph;
Consider simplifying this complex logical expression. Open
unless (!record.complete? && ((value == "") || (value == '0'*14) || (Cnpj.new(value).valido?))) ||
(Cnpj.new(value).valido?)
record.errors[attribute] << (options[:message] || ("%s %s" % [I18n.t("customer_pjs.doc"), I18n.t('errors.messages.invalid')]) )
end
Consider simplifying this complex logical expression. Open
if ((_key.exclamation <= charcode && charcode <= _key.slash) || (_key.colon <= charcode && charcode <= _key.at) || (_key.squarebricket_left <= charcode && charcode <= _key.apostrof)) {
string = string.replace(string[i], escape(string[i]))
}
Function addItem
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function addItem(title, value, preadded, locked, focusme) {
Method validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
if (record.person_type==CustomerPj.to_s)
#cnpj
- 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 load_form
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_form
#remove conficts
feedback_params = params[:task][:feedbacks]
params[:task].delete :feedbacks
- 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 due_critical_level
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def due_critical_level
return 0 if done? || due_time.nil?
if (due_time>Time.now)
- 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
Avoid too many return
statements within this method. Open
return