app/helpers/notifications_helper.rb
File notifications_helper.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module NotificationsHelper
REASON_LABELS = {
'comment' => 'primary',
'author' => 'success',
'state_change' => 'info',
Method sidebar_filter_link
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def sidebar_filter_link(active:, param:, value:, count: nil, except: nil, link_class: nil, path_params: nil, title: nil)
css_class = 'nav-item'
css_class += ' active' if active
css_class += " #{param}-#{value}"
- 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 function_button
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def function_button(title, octicon, css_class, tooltip, hidden=true)
Method notification_icon
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def notification_icon(notification)
subject_type = notification.subject_type
state = notification.user.try(:github_app_authorized?) ? notification.state : nil
return 'issue-closed' if subject_type == 'Issue' && state == 'closed'
return 'git-pull-request-draft' if subject_type == 'PullRequest' && notification.draft?
- 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"