app/services/message_sender.rb
Method run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def run
slack_user_id = EmployeeFinder.new(employee.slack_username).slack_user_id
if employee.slack_user_id.nil? && slack_user_id.present?
employee.slack_user_id = slack_user_id
Method run
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def run
slack_user_id = EmployeeFinder.new(employee.slack_username).slack_user_id
if employee.slack_user_id.nil? && slack_user_id.present?
employee.slack_user_id = slack_user_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
Line is too long. [161/80] Open
Open
error: StandardError.new("Was unable to find a slack channel for user with name #{employee.slack_username} and slack user id #{employee.slack_user_id}"),
- Exclude checks
Extra empty line detected at method body end. Open
Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the bodies of methods.
Example:
# good
def foo
# ...
end
# bad
def bar
# ...
end