Module has too many lines. [194/100] Open
module ViewHelper
def fae_date_format(datetime, timezone = @option.time_zone)
datetime.in_time_zone(timezone).strftime('%m/%d/%y') if is_date_or_time?(datetime)
end
- Read upRead up
- Exclude checks
This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [21/10] Open
def fae_filter_form(options = {}, &block)
options = prepare_options_for_filter_form options
return if options[:collection].blank?
form_tag(options[:action], prepare_form_filter_hash(options)) do
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for fae_filter_select is too high. [25.67/15] Open
def fae_filter_select(attribute, opts = {})
options = prepare_options_for_filter_select(attribute, opts)
# grouped_by takes priority over grouped_options
if options[:grouped_by].present?
select_options = filter_generate_select_group(options[:collection], options[:grouped_by], options[:label_method])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for fae_filter_form is too high. [22.41/15] Open
def fae_filter_form(options = {}, &block)
options = prepare_options_for_filter_form options
return if options[:collection].blank?
form_tag(options[:action], prepare_form_filter_hash(options)) do
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [13/10] Open
def fae_filter_select(attribute, opts = {})
options = prepare_options_for_filter_select(attribute, opts)
# grouped_by takes priority over grouped_options
if options[:grouped_by].present?
select_options = filter_generate_select_group(options[:collection], options[:grouped_by], options[:label_method])
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [11/10] Open
def fae_toggle(item, column)
active = item.send(column)
link_class = active ? 'slider-yes-selected' : ''
model_name = item.class.to_s.gsub('::','__').underscore.pluralize
url = fae.toggle_path(model_name, item.id.to_s, column)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Avoid parameter lists longer than 5 parameters. [13/5] Open
def fae_image_form(f, image_name, label: nil, alt_label: nil, caption_label: nil, show_alt: nil, show_caption: nil, required: nil, helper_text: nil, alt_helper_text: nil, caption_helper_text: nil, attached_as: nil, show_form_manager: true)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Avoid parameter lists longer than 5 parameters. [9/5] Open
def fae_content_form(f, attribute, label: nil, hint: nil, helper_text: nil, markdown: nil, markdown_supported: nil, input_options: nil, show_form_manager: true)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Method fae_filter_form
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fae_filter_form(options = {}, &block)
options = prepare_options_for_filter_form options
return if options[:collection].blank?
form_tag(options[:action], prepare_form_filter_hash(options)) do
- 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 parameter lists longer than 5 parameters. [6/5] Open
def fae_file_form(f, file_name, label: nil, helper_text: nil, required: nil, show_form_manager: true)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Line is too long. [88/80] Open
datetime.in_time_zone(timezone).strftime('%m/%d/%y') if is_date_or_time?(datetime)
- Exclude checks
Line is too long. [105/80] Open
def fae_file_form(f, file_name, label: nil, helper_text: nil, required: nil, show_form_manager: true)
- Exclude checks
Line is too long. [164/80] Open
def fae_content_form(f, attribute, label: nil, hint: nil, helper_text: nil, markdown: nil, markdown_supported: nil, input_options: nil, show_form_manager: true)
- Exclude checks
Line is too long. [88/80] Open
link_to url, class: "slider-wrapper #{link_class}", method: :post, remote: true do
- Exclude checks
Extra empty line detected at module body beginning. Open
def fae_date_format(datetime, timezone = @option.time_zone)
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Line is too long. [83/80] Open
<div class="slider-option slider-option-yes" aria-live="polite">Yes</div>
- Exclude checks
Space missing after comma. Open
model_name = item.class.to_s.gsub('::','__').underscore.pluralize
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Operator ||=
should be surrounded by a single space. Open
options[:label] ||= attribute.to_s.titleize
- Read upRead up
- Exclude checks
Checks that operators have space around them, except for ** which should not have surrounding space.
Example:
# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b
# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b
Surrounding space missing in default value assignment. Open
def fae_filter_datepicker(attribute, options={})
- Read upRead up
- Exclude checks
Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.
Example:
# bad
def some_method(arg1=:default, arg2=nil, arg3=[])
# do something...
end
# good
def some_method(arg1 = :default, arg2 = nil, arg3 = [])
# do something...
end
Line is too long. [370/80] Open
render 'fae/images/image_uploader', f: f, image_name: image_name, label: label, alt_label: alt_label, caption_label: caption_label, show_alt: show_alt, show_caption: show_caption, required: required, helper_text: helper_text, alt_helper_text: alt_helper_text, caption_helper_text: caption_helper_text, attached_as: attached_as, show_form_manager: show_form_manager
- Exclude checks
Line is too long. [170/80] Open
render 'fae/application/file_uploader', f: f, file_name: file_name, label: label, required: required, helper_text: helper_text, show_form_manager: show_form_manager
- Exclude checks
Line is too long. [251/80] Open
render 'fae/application/content_form', f: f, attribute: attribute, label: label, hint: hint, helper_text: helper_text, markdown: markdown, markdown_supported: markdown_supported, input_options: input_options, show_form_manager: show_form_manager
- Exclude checks
Line is too long. [92/80] Open
select_options = options_for_select(options[:options]) if options[:options].present?
- Exclude checks
Line is too long. [94/80] Open
values = collection.select { |c| c.send(grouped_by).try(:fae_display_field) == label }
- Exclude checks
Line is too long. [121/80] Open
select_options = filter_generate_select_group(options[:collection], options[:grouped_by], options[:label_method])
- Exclude checks
Line is too long. [94/80] Open
content_tag :nav, class: 'pagination', data: { filter_path: "#{@index_path}/filter" } do
- Exclude checks
Prefer Object#is_a?
over Object#kind_of?
. Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Read upRead up
- Exclude checks
This cop enforces consistent use of Object#is_a?
or Object#kind_of?
.
Example: EnforcedStyle: is_a? (default)
# bad
var.kind_of?(Date)
var.kind_of?(Integer)
# good
var.is_a?(Date)
var.is_a?(Integer)
Example: EnforcedStyle: kind_of?
# bad
var.is_a?(Time)
var.is_a?(String)
# good
var.kind_of?(Time)
var.kind_of?(String)
Space inside parentheses detected. Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Line is too long. [110/80] Open
# I know this `unless !` looks like it should be an `if` but it's definitely supposed to be `unless !`
- Exclude checks
Space missing after comma. Open
klass = item.class.name.underscore.gsub('/','__')
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Line is too long. [243/80] Open
def fae_image_form(f, image_name, label: nil, alt_label: nil, caption_label: nil, show_alt: nil, show_caption: nil, required: nil, helper_text: nil, alt_helper_text: nil, caption_helper_text: nil, attached_as: nil, show_form_manager: true)
- Exclude checks
Line is too long. [133/80] Open
attrs = { method: :delete, title: 'Delete', class: 'js-tooltip table-action', data: { confirm: t('fae.delete_confirmation') } }
- Exclude checks
Line is too long. [93/80] Open
concat text_field_tag "filter[#{attribute}]", nil, placeholder: options[:placeholder]
- Exclude checks
Line is too long. [101/80] Open
datetime.in_time_zone(timezone).strftime("%b %-d, %Y %l:%M%P %Z") if is_date_or_time?(datetime)
- Exclude checks
Line is too long. [95/80] Open
concat select_tag "filter[#{attribute}]", select_options, prompt: options[:placeholder]
- Exclude checks
Favor if
over unless
for negative conditions. Open
unless !options[:search]
concat submit_tag t('fae.apply_filters'), class: 'hidden'
end
- Read upRead up
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Space inside parentheses detected. Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Line is too long. [90/80] Open
form_hash['data-cookie-key'] = options[:cookie_key] if options[:cookie_key].present?
- Exclude checks
Prefer Object#is_a?
over Object#kind_of?
. Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Read upRead up
- Exclude checks
This cop enforces consistent use of Object#is_a?
or Object#kind_of?
.
Example: EnforcedStyle: is_a? (default)
# bad
var.kind_of?(Date)
var.kind_of?(Integer)
# good
var.is_a?(Date)
var.is_a?(Integer)
Example: EnforcedStyle: kind_of?
# bad
var.is_a?(Time)
var.is_a?(String)
# good
var.kind_of?(Time)
var.kind_of?(String)
Missing top-level module documentation comment. Open
module ViewHelper
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Line is too long. [171/80] Open
link_to "#{@index_path}?from_existing=#{item.id}", method: :post, title: 'Clone', class: 'js-tooltip table-action', data: { confirm: t('fae.clone_confirmation') } do
- Exclude checks
Prefer Object#is_a?
over Object#kind_of?
. Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Read upRead up
- Exclude checks
This cop enforces consistent use of Object#is_a?
or Object#kind_of?
.
Example: EnforcedStyle: is_a? (default)
# bad
var.kind_of?(Date)
var.kind_of?(Integer)
# good
var.is_a?(Date)
var.is_a?(Integer)
Example: EnforcedStyle: kind_of?
# bad
var.is_a?(Time)
var.is_a?(String)
# good
var.kind_of?(Time)
var.kind_of?(String)
Line is too long. [90/80] Open
filter_group_wrapper = content_tag(:div, class: 'table-filter-group-wrapper') do
- Exclude checks
Line is too long. [81/80] Open
<div class="slider-option slider-option-no" aria-live="polite">No</div>
- Exclude checks
Line is too long. [131/80] Open
datetime.present? && ( datetime.kind_of?(Date) || datetime.kind_of?(Time) || datetime.kind_of?(ActiveSupport::TimeWithZone) )
- Exclude checks
Line is too long. [111/80] Open
select_options = options_from_collection_for_select(options[:collection], 'id', options[:label_method])
- Exclude checks
Rename is_date_or_time?
to date_or_time?
. Open
def is_date_or_time?(datetime)
- Read upRead up
- Exclude checks
This cop makes sure that predicates are named properly.
Example:
# bad
def is_even?(value)
end
# good
def even?(value)
end
# bad
def has_value?
end
# good
def value?
end
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
datetime.in_time_zone(timezone).strftime("%b %-d, %Y %l:%M%P %Z") if is_date_or_time?(datetime)
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Line is too long. [85/80] Open
labels = collection.map { |c| c.send(grouped_by).try(:fae_display_field) }.uniq
- Exclude checks