Showing 9 of 227 total issues
Method pull_data
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pull_data(answers)
answers.pull(
:id,
:reply_id,
:survey_id,
Method method_missing
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method_name, *args)
if method_name.name.end_with?('=')
raise ArgumentError, "wrong number of arguments expected 1, got #{args.length}" unless args.length == 1
@stash[method_name.name.chop.to_sym] = args.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 fmt_hour
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def fmt_hour(value)
hour = value.is_a?(Integer) ? value : value.hour
ampm = hour >= 12 && hour != 24 ? 'PM' : 'AM'
hr = hour > 12 ? hour % 12 : hour
hr = hr.zero? ? 12 : hr
- 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 define_advising_method
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def define_advising_method(method_name, klass, args = EMPTY_ARRAY, calling: nil, memoize: true)
define_method(method_name) do |*method_args, **kwargs|
obj = advising_object_memos.fetch(method_name) do
klass.new(self, *args).tap do |obj|
advising_object_memos[method_name] = obj if memoize
- 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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call(user:, visit:, tracker:, wants_preview:)
fail! error: format(SUBMITTED_ERROR, survey.name.inspect) if already_submitted?(visit, wants_preview)
fail! error: PERMISSION_ERROR unless user.can_create_reply?(survey)
if user.can_preview_survey?(survey, wants_preview: wants_preview)
- 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 button_to
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def button_to(name = nil, options = nil, html_options = EMPTY_HASH, &block)
htmx_attr_keys = options.is_a?(Hash) ? HTMX_ONLY_ATTRS & options.keys : EMPTY_ARRAY
return orig_button_to(name, options, html_options, &block) if htmx_attr_keys.empty?
html_options, options = options, name if block_given?
- 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 survey_open_indicator
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def survey_open_indicator(survey)
htmx = {
'hx-post' => survey.open? ? survey_close_path(survey) : survey_open_path(survey),
'hx-vals' => { authenticity_token: authenticity_token }.to_json,
'hx-target' => "#survey-card-#{survey.id}",
- 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 nav_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def nav_link(content, path = nil, active:, **html_options)
classes = %w[nav-link]
unless path
path = content
- 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 data_grid_display
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def data_grid_display(answers, question, alt: '-')
return alt if answers.blank?
tag.div(class: 'text-nowrap text-end') do
answers.map do |answer|
- 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"