app/models/dispatcher.rb
Class Dispatcher
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Dispatcher
def initialize(proposal)
@proposal = proposal
end
Assignment Branch Condition size for step_complete is too high. [20.4/15] Open
Open
def step_complete(step)
if next_step.present?
StepMailer.proposal_notification(next_step).deliver_later
end
- 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. [14/10] Open
Open
def deliver_cancelation_emails(canceler, reason = nil)
cancelation_notification_recipients = [proposal.requester] + active_step_users + only_observers - [canceler]
cancelation_notification_recipients.each do |recipient|
CancelationMailer.cancelation_notification(
- 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 notify_observers
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def notify_observers(needs_review, comment)
only_observers.each do |observer|
unless user_is_modifier?(observer, comment.user)
if observer.role_on(proposal).observer_only?
if needs_review == true
- 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
Re-enable Metrics/MethodLength cop with # rubocop:enable
after disabling it. Open
Open
# rubocop:disable Metrics/MethodLength
- Exclude checks
Re-enable Style/Next cop with # rubocop:enable
after disabling it. Open
Open
# rubocop:disable Style/Next
- Exclude checks
Re-enable Metrics/AbcSize cop with # rubocop:enable
after disabling it. Open
Open
# rubocop:disable Metrics/AbcSize
- Exclude checks