From efc379427ba5fe27de58efeff2be562d09025733 Mon Sep 17 00:00:00 2001
From: Doug Stull <dstull@gitlab.com>
Date: Wed, 29 Jul 2020 14:42:42 -0400
Subject: [PATCH] Resolve Style/NumericPredicate cop exceptions in haml

- no exceptions...
---
 .rubocop_todo.yml                                      | 2 --
 app/views/admin/labels/destroy.js.haml                 | 2 +-
 app/views/admin/sessions/_signin_box.html.haml         | 2 +-
 app/views/devise/shared/_signin_box.html.haml          | 2 +-
 app/views/devise/shared/_tabs_ldap.html.haml           | 2 +-
 app/views/groups/issues.html.haml                      | 2 +-
 app/views/groups/merge_requests.html.haml              | 2 +-
 app/views/layouts/header/_default.html.haml            | 6 +++---
 app/views/projects/milestones/show.html.haml           | 2 +-
 app/views/projects/runners/_shared_runners.html.haml   | 2 +-
 app/views/shared/_issuable_meta_data.html.haml         | 2 +-
 app/views/shared/issuable/_assignees.html.haml         | 2 +-
 app/views/shared/milestones/_milestone.html.haml       | 2 +-
 app/views/shared/milestones/_sidebar.html.haml         | 2 +-
 app/views/shared/snippets/_snippet.html.haml           | 2 +-
 app/views/users/_deletion_guidance.html.haml           | 2 +-
 ee/app/views/shared/billings/_billing_plan.html.haml   | 2 +-
 ee/app/views/shared/milestones/_weight.html.haml       | 4 ++--
 ee/app/views/trial_registrations/_signin_box.html.haml | 2 +-
 19 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3e0c2838252c3..f18cd6a297ac0 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1026,8 +1026,6 @@ Style/NumericPredicate:
   EnforcedStyle: comparison
   Exclude:
     - 'spec/**/*'
-    - 'app/views/**/*'
-    - 'ee/app/views/**/*'
     - 'app/controllers/concerns/issuable_collections.rb'
     - 'app/controllers/concerns/paginated_collection.rb'
     - 'app/helpers/graph_helper.rb'
diff --git a/app/views/admin/labels/destroy.js.haml b/app/views/admin/labels/destroy.js.haml
index 394d3c11f3154..b9b63829f2544 100644
--- a/app/views/admin/labels/destroy.js.haml
+++ b/app/views/admin/labels/destroy.js.haml
@@ -1,2 +1,2 @@
-- if @labels.size.zero?
+- if @labels.size == 0
   $('.labels').load(document.URL + ' .nothing-here-block').hide().fadeIn(1000)
diff --git a/app/views/admin/sessions/_signin_box.html.haml b/app/views/admin/sessions/_signin_box.html.haml
index cb6c0a76e5641..ab7eb8c79dc2b 100644
--- a/app/views/admin/sessions/_signin_box.html.haml
+++ b/app/views/admin/sessions/_signin_box.html.haml
@@ -7,7 +7,7 @@
   = render_if_exists 'devise/sessions/new_kerberos_tab'
 
   - ldap_servers.each_with_index do |server, i|
-    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i.zero? && form_based_auth_provider_has_active_class?(:ldapmain)) }
+    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i == 0 && form_based_auth_provider_has_active_class?(:ldapmain)) }
       .login-body
         = render 'devise/sessions/new_ldap', server: server, hide_remember_me: true, submit_message: _('Enter Admin Mode')
 
diff --git a/app/views/devise/shared/_signin_box.html.haml b/app/views/devise/shared/_signin_box.html.haml
index c0b005bac7733..d217b47527a8c 100644
--- a/app/views/devise/shared/_signin_box.html.haml
+++ b/app/views/devise/shared/_signin_box.html.haml
@@ -7,7 +7,7 @@
   = render_if_exists 'devise/sessions/new_kerberos_tab'
 
   - ldap_servers.each_with_index do |server, i|
-    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i.zero? && form_based_auth_provider_has_active_class?(:ldapmain)) }
+    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i == 0 && form_based_auth_provider_has_active_class?(:ldapmain)) }
       .login-body
         = render 'devise/sessions/new_ldap', server: server
 
diff --git a/app/views/devise/shared/_tabs_ldap.html.haml b/app/views/devise/shared/_tabs_ldap.html.haml
index eb14ad6006fb0..acd41fb011a3c 100644
--- a/app/views/devise/shared/_tabs_ldap.html.haml
+++ b/app/views/devise/shared/_tabs_ldap.html.haml
@@ -8,7 +8,7 @@
   = render_if_exists "devise/shared/kerberos_tab"
   - ldap_servers.each_with_index do |server, i|
     %li.nav-item
-      = link_to server['label'], "##{server['provider_name']}", class: "nav-link #{active_when(i.zero? && form_based_auth_provider_has_active_class?(:ldapmain))}", data: { toggle: 'tab', qa_selector: 'ldap_tab' }
+      = link_to server['label'], "##{server['provider_name']}", class: "nav-link #{active_when(i == 0 && form_based_auth_provider_has_active_class?(:ldapmain))}", data: { toggle: 'tab', qa_selector: 'ldap_tab' }
 
   = render_if_exists 'devise/shared/tab_smartcard'
 
diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml
index 59432e5f01554..04e0ff30dc908 100644
--- a/app/views/groups/issues.html.haml
+++ b/app/views/groups/issues.html.haml
@@ -4,7 +4,7 @@
 = content_for :meta_tags do
   = auto_discovery_link_tag(:atom, safe_params.merge(rss_url_options).to_h, title: "#{@group.name} issues")
 
-- if group_issues_count(state: 'all').zero?
+- if group_issues_count(state: 'all') == 0
   = render 'shared/empty_states/issues', project_select_button: true
 - else
   .top-area
diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml
index 1828f850d35ff..15e777f5c3645 100644
--- a/app/views/groups/merge_requests.html.haml
+++ b/app/views/groups/merge_requests.html.haml
@@ -2,7 +2,7 @@
 
 - page_title _("Merge Requests")
 
-- if group_merge_requests_count(state: 'all').zero?
+- if group_merge_requests_count(state: 'all') == 0
   = render 'shared/empty_states/merge_requests', project_select_button: true
 - else
   .top-area
diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml
index c65357b76ca84..0d21f224a8acd 100644
--- a/app/views/layouts/header/_default.html.haml
+++ b/app/views/layouts/header/_default.html.haml
@@ -38,20 +38,20 @@
               = link_to assigned_issues_dashboard_path, title: _('Issues'), class: 'dashboard-shortcuts-issues', aria: { label: _('Issues') }, data: { qa_selector: 'issues_shortcut_button', toggle: 'tooltip', placement: 'bottom', container: 'body' } do
                 = sprite_icon('issues', size: 16)
                 - issues_count = assigned_issuables_count(:issues)
-                %span.badge.badge-pill.issues-count.green-badge{ class: ('hidden' if issues_count.zero?) }
+                %span.badge.badge-pill.issues-count.green-badge{ class: ('hidden' if issues_count == 0) }
                   = number_with_delimiter(issues_count)
           - if header_link?(:merge_requests)
             = nav_link(path: 'dashboard#merge_requests', html_options: { class: "user-counter" }) do
               = link_to assigned_mrs_dashboard_path, title: _('Merge requests'), class: 'dashboard-shortcuts-merge_requests', aria: { label: _('Merge requests') }, data: { qa_selector: 'merge_requests_shortcut_button', toggle: 'tooltip', placement: 'bottom', container: 'body' } do
                 = sprite_icon('git-merge', size: 16)
                 - merge_requests_count = assigned_issuables_count(:merge_requests)
-                %span.badge.badge-pill.merge-requests-count{ class: ('hidden' if merge_requests_count.zero?) }
+                %span.badge.badge-pill.merge-requests-count{ class: ('hidden' if merge_requests_count == 0) }
                   = number_with_delimiter(merge_requests_count)
           - if header_link?(:todos)
             = nav_link(controller: 'dashboard/todos', html_options: { class: "user-counter" }) do
               = link_to dashboard_todos_path, title: _('To-Do List'), aria: { label: _('To-Do List') }, class: 'shortcuts-todos', data: { qa_selector: 'todos_shortcut_button', toggle: 'tooltip', placement: 'bottom', container: 'body' } do
                 = sprite_icon('todo-done', size: 16)
-                %span.badge.badge-pill.todos-count{ class: ('hidden' if todos_pending_count.zero?) }
+                %span.badge.badge-pill.todos-count{ class: ('hidden' if todos_pending_count == 0) }
                   = todos_count_format(todos_pending_count)
           %li.nav-item.header-help.dropdown.d-none.d-md-block
             = link_to help_path, class: 'header-help-dropdown-toggle', data: { toggle: "dropdown" } do
diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml
index 5239af82ba650..99e626161c4f8 100644
--- a/app/views/projects/milestones/show.html.haml
+++ b/app/views/projects/milestones/show.html.haml
@@ -8,7 +8,7 @@
 
 = render_if_exists 'shared/milestones/burndown', milestone: @milestone, project: @project
 
-- if can?(current_user, :read_issue, @project) && @milestone.total_issues_count.zero?
+- if can?(current_user, :read_issue, @project) && @milestone.total_issues_count == 0
   .alert.alert-success.gl-mt-3
     %span= _('Assign some issues to this milestone.')
 - elsif @milestone.complete? && @milestone.active?
diff --git a/app/views/projects/runners/_shared_runners.html.haml b/app/views/projects/runners/_shared_runners.html.haml
index 080b2c0b0e929..8a17ca3c6701c 100644
--- a/app/views/projects/runners/_shared_runners.html.haml
+++ b/app/views/projects/runners/_shared_runners.html.haml
@@ -15,7 +15,7 @@
       = _('Enable shared Runners')
   &nbsp; for this project
 
-- if @shared_runners_count.zero?
+- if @shared_runners_count == 0
   = _('This GitLab instance does not provide any shared Runners yet. Instance administrators can register shared Runners in the admin area.')
 - else
   %h4.underlined-title #{_('Available shared Runners:')} #{@shared_runners_count}
diff --git a/app/views/shared/_issuable_meta_data.html.haml b/app/views/shared/_issuable_meta_data.html.haml
index d704eae2090ec..c1749e1f96e1f 100644
--- a/app/views/shared/_issuable_meta_data.html.haml
+++ b/app/views/shared/_issuable_meta_data.html.haml
@@ -20,6 +20,6 @@
     = downvotes
 
 %li.issuable-comments.d-none.d-sm-block
-  = link_to issuable_path, class: ['has-tooltip', ('no-comments' if note_count.zero?)], title: _('Comments') do
+  = link_to issuable_path, class: ['has-tooltip', ('no-comments' if note_count == 0)], title: _('Comments') do
     = sprite_icon('comments', size: 16, css_class: 'gl-vertical-align-text-bottom')
     = note_count
diff --git a/app/views/shared/issuable/_assignees.html.haml b/app/views/shared/issuable/_assignees.html.haml
index 7ef0647d14b54..8e46db6dea2ef 100644
--- a/app/views/shared/issuable/_assignees.html.haml
+++ b/app/views/shared/issuable/_assignees.html.haml
@@ -6,5 +6,5 @@
 - issuable.assignees.take(render_count).each do |assignee| # rubocop: disable CodeReuse/ActiveRecord
   = link_to_member(@project, assignee, name: false, title: "Assigned to :name")
 
-- if more_assignees_count.positive?
+- if more_assignees_count > 0
   %span{ class: 'avatar-counter has-tooltip', data: { container: 'body', placement: 'bottom', 'line-type' => 'old', 'original-title' => "+#{more_assignees_count} more assignees", qa_selector: 'avatar_counter_content' } } +#{more_assignees_count}
diff --git a/app/views/shared/milestones/_milestone.html.haml b/app/views/shared/milestones/_milestone.html.haml
index ae5bf9572bdad..4ef8a9dd84274 100644
--- a/app/views/shared/milestones/_milestone.html.haml
+++ b/app/views/shared/milestones/_milestone.html.haml
@@ -15,7 +15,7 @@
         .text-tertiary.gl-mb-2
           = milestone_date_range(milestone)
       - recent_releases, total_count, more_count = recent_releases_with_counts(milestone)
-      - unless total_count.zero?
+      - unless total_count == 0
         .text-tertiary.gl-mb-2.milestone-release-links
           = sprite_icon("rocket", size: 12)
           = n_('Release', 'Releases', total_count)
diff --git a/app/views/shared/milestones/_sidebar.html.haml b/app/views/shared/milestones/_sidebar.html.haml
index 7fd657ec2ddb9..27cedcae9b660 100644
--- a/app/views/shared/milestones/_sidebar.html.haml
+++ b/app/views/shared/milestones/_sidebar.html.haml
@@ -144,7 +144,7 @@
           %span= total_count
         .title.hide-collapsed= n_('Release', 'Releases', total_count)
         .hide-collapsed
-          - if total_count.zero?
+          - if total_count == 0
             .no-value= s_('MilestoneSidebar|None')
           - else
             .font-weight-bold
diff --git a/app/views/shared/snippets/_snippet.html.haml b/app/views/shared/snippets/_snippet.html.haml
index 5f2c896f68f9c..cf027252524e1 100644
--- a/app/views/shared/snippets/_snippet.html.haml
+++ b/app/views/shared/snippets/_snippet.html.haml
@@ -10,7 +10,7 @@
 
     %ul.controls
       %li
-        = link_to gitlab_snippet_path(snippet, anchor: 'notes'), class: ('no-comments' if notes_count.zero?) do
+        = link_to gitlab_snippet_path(snippet, anchor: 'notes'), class: ('no-comments' if notes_count == 0) do
           = sprite_icon('comments', size: 16, css_class: 'gl-vertical-align-text-bottom')
           = notes_count
       %li
diff --git a/app/views/users/_deletion_guidance.html.haml b/app/views/users/_deletion_guidance.html.haml
index 0024801dbf694..507fe126acbd0 100644
--- a/app/views/users/_deletion_guidance.html.haml
+++ b/app/views/users/_deletion_guidance.html.haml
@@ -6,6 +6,6 @@
       - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path("user/profile/account/delete_account", anchor: "associated-records") }
       = _('Certain user content will be moved to a system-wide "Ghost User" in order to maintain content for posterity. For further information, please refer to the %{link_start}user account deletion documentation.%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
   - personal_projects_count = user.personal_projects.count
-  - unless personal_projects_count.zero?
+  - unless personal_projects_count == 0
     %li
       = n_('%d personal project will be removed and cannot be restored.', '%d personal projects will be removed and cannot be restored.', personal_projects_count) % personal_projects_count
diff --git a/ee/app/views/shared/billings/_billing_plan.html.haml b/ee/app/views/shared/billings/_billing_plan.html.haml
index a6db040822cbc..e67e2cdf59563 100644
--- a/ee/app/views/shared/billings/_billing_plan.html.haml
+++ b/ee/app/views/shared/billings/_billing_plan.html.haml
@@ -17,7 +17,7 @@
         %ul.conditions.p-0.my-auto
           %li= s_("BillingPlans|per user")
           %li= s_("BillingPlans|monthly")
-      .price-per-year.text-left{ class: ("invisible" unless plan.price_per_year.positive?) }
+      .price-per-year.text-left{ class: ("invisible" unless plan.price_per_year > 0) }
         - price_per_year = number_to_plan_currency(plan.price_per_year)
         = s_("BillingPlans|billed annually at %{price_per_year}") % { price_per_year: price_per_year }
 
diff --git a/ee/app/views/shared/milestones/_weight.html.haml b/ee/app/views/shared/milestones/_weight.html.haml
index f33fe81830891..f03b0fbdc6724 100644
--- a/ee/app/views/shared/milestones/_weight.html.haml
+++ b/ee/app/views/shared/milestones/_weight.html.haml
@@ -7,14 +7,14 @@
   .sidebar-collapsed-icon.has-tooltip{ title: milestone_weight_tooltip_text(total_weight), data: { container: 'body', placement: 'left' } }
     = sprite_icon('weight', size: 16)
     %span
-      - unless total_weight.zero?
+      - unless total_weight == 0
         = total_weight
       - else
         None
   .title.hide-collapsed
     Total issue weight
   .value.hide-collapsed{ data: { qa_selector: 'total_issue_weight_value' } }
-    - unless total_weight.zero?
+    - unless total_weight == 0
       %strong.bold= total_weight
     - else
       .no-value None
diff --git a/ee/app/views/trial_registrations/_signin_box.html.haml b/ee/app/views/trial_registrations/_signin_box.html.haml
index 2db891dfc9a59..f3e62a03d0f6b 100644
--- a/ee/app/views/trial_registrations/_signin_box.html.haml
+++ b/ee/app/views/trial_registrations/_signin_box.html.haml
@@ -7,7 +7,7 @@
   = render_if_exists 'devise/sessions/new_kerberos_tab'
 
   - ldap_servers.each_with_index do |server, i|
-    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i.zero? && form_based_auth_provider_has_active_class?(:ldapmain)) }
+    .login-box.tab-pane{ id: "#{server['provider_name']}", role: 'tabpanel', class: active_when(i == 0 && form_based_auth_provider_has_active_class?(:ldapmain)) }
       .login-body
         = render 'devise/sessions/new_ldap', server: server
 
-- 
GitLab