Add AvoidConditionalStatements Rubocop rule
What does this MR do and why?
Describe in detail what your merge request does and why.
Related #385304 (closed) and #385304 (comment 1345437109)
Forbid usage of conditionals in spec/features
it is possible to create flaky tests when used combined with Capybara methods that are automatically waiting.
Offenses
30703 files inspected, 141 offenses detected
Click to expand
Offenses:
ee/spec/features/admin/admin_settings_spec.rb:416:156: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
it "#{button_effect} if 'require admin approval for new sign-ups' is #{require_admin_approval_action} and the user cap is #{user_cap_action} and #{add_pending_user ? "has" : "doesn't have"} pending user count" do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/admin/admin_settings_spec.rb:422:11: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
unless [:changed_from_unlimited_to_limited, :unchanged_unlimited].include?(user_cap_action) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/admin/admin_settings_spec.rb:426:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if add_pending_user ...
^^^^^^^^^^^^^^^^^^^
ee/spec/features/analytics/code_analytics_spec.rb:46:29: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
it "shows empty state #{expect_button ? 'with' : 'without'} \"New merge request\" button" do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/analytics/code_analytics_spec.rb:51:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if expect_button ...
^^^^^^^^^^^^^^^^
ee/spec/features/billings/billing_plans_spec.rb:35:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Plan::PAID_HOSTED_PLANS.include?(plan.name) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/billings/billing_plans_spec.rb:520:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
break cell.find('[data-testid="property-value"]').text if label&.text == 'Seats currently in use'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/scoped_issue_board_spec.rb:629:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if filter == 'current_iteration' ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/scoped_issue_board_spec.rb:631:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if value ...
^^^^^^^^
ee/spec/features/boards/scoped_issue_board_spec.rb:640:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if value.is_a?(Array) ...
^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/scoped_issue_board_spec.rb:642:9: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif filter == 'weight' ...
^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/user_visits_board_spec.rb:39:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board_path.include?('group_by') ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/user_visits_board_spec.rb:104:27: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
let_it_be(:board) { workspace == "project" ? create(:board, project: project) : create(:board, group: group) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/boards/user_visits_board_spec.rb:130:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
return project_boards_path(project, params) if workspace == "project"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/ci_shared_runner_warnings_spec.rb:193:5: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
visible ? expect_quota_exceeded_alert(message) : expect_no_quota_exceeded_alert
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/epic_boards/epic_boards_spec.rb:429:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if value.is_a?(Array) ...
^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/epics/epic_show_spec.rb:37:19: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
button_name = type == 'issue' ? 'Add an existing issue' : 'Add an existing epic'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/epics/epic_show_spec.rb:38:23: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
input_character = type == 'issue' ? '#' : '&'
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/epics/gfm_autocomplete_spec.rb:217:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if shown ...
^^^^^^^^
ee/spec/features/epics/gfm_autocomplete_spec.rb:222:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if not_shown ...
^^^^^^^^^^^^
ee/spec/features/epics/gfm_autocomplete_spec.rb:223:9: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
expect(page).not_to have_selector('.atwho-view li') unless shown
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/group_protected_branches_spec.rb:165:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if real_time_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/group_protected_branches_spec.rb:170:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if real_time_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/group_protected_branches_spec.rb:173:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if real_time_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/group_protected_branches_spec.rb:177:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if real_time_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/groups/analytics/cycle_analytics/filters_and_data_spec.rb:57:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
page.driver.browser.action.move_by(-10000, -10000).perform if rehover
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/groups/analytics/cycle_analytics/multiple_value_streams_spec.rb:48:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
return unless with_aggregation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/groups/iterations/user_views_iteration_spec.rb:62:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if shows_actions ...
^^^^^^^^^^^^^^^^
ee/spec/features/incidents/incident_details_spec.rb:278:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if href ...
^^^^^^^
ee/spec/features/issues/user_sees_empty_state_spec.rb:10:29: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
it "shows empty state #{expect_button ? 'with' : 'without'} \"New issue\" button" do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/labels_hierarchy_spec.rb:31:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
labels.push(project_label_1) if project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/profiles/usage_quotas_spec.rb:58:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if shared_runners_enabled ...
^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/projects/analytics/visualization_designer_spec.rb:102:15: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if visualization[:content].nil? ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/projects/licenses/maintainer_views_policies_spec.rb:118:5: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
version ? "#{name} (#{version})" : name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/projects/merge_requests/user_approves_merge_request_spec.rb:71:21: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
button_text = additional_approver ? 'Add approval' : 'Approve'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/projects/settings/issues_settings_spec.rb:121:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if toggle_disabled ...
^^^^^^^^^^^^^^^^^^
ee/spec/features/projects/settings/issues_settings_spec.rb:127:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if toggle_checked ...
^^^^^^^^^^^^^^^^^
ee/spec/features/projects_spec.rb:60:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if params[:shows_adjourned_delete] ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:31:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
expect_required_approval_and_sign_in if require_admin_approval_after_user_signup
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:33:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
unless Gitlab::CurrentSettings.email_confirmation_setting_off? ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:34:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Gitlab::CurrentSettings.email_confirmation_setting_soft? ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:38:9: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif require_admin_approval_after_user_signup ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:43:9: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif identity_verification ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:130:24: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
number_of_emails = email_confirmation_setting == 'off' ? 1 : 2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:146:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if from_banner ...
^^^^^^^^^^^^^^
ee/spec/features/registrations/email_confirmation_spec.rb:148:5: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif custom ...
^^^^^^^^^^^^
ee/spec/features/registrations/identity_verification_spec.rb:44:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
verify_email unless skip_email_validation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/registrations/identity_verification_spec.rb:62:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
verify_email unless skip_email_validation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/search/elastic/snippet_search_spec.rb:29:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
sign_in(current_user) if current_user
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/subscriptions/expiring_subscription_message_spec.rb:18:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if expires_at.present? ...
^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/subscriptions/expiring_subscription_message_spec.rb:75:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if expires_at.present? ...
^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/users/identity_verification_spec.rb:181:5: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
(different_code = rand.to_s[2..7]) == code ? random_code(code) : different_code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/admin/dashboard_spec.rb:45:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Gitlab.ee? ...
^^^^^^^^^^^^^
spec/features/calendar_spec.rb:21:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if contributions > 0 && contributions < 10 ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/calendar_spec.rb:23:7: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif contributions >= 10 && contributions < 20 ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/calendar_spec.rb:25:7: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif contributions >= 20 && contributions < 30 ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/calendar_spec.rb:27:7: C: RSpec/AvoidConditionalStatements: Don't use elsif conditional statments in specs, it might create flakiness
elsif contributions >= 30 ...
^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/calendar_spec.rb:38:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if contributions == 0 ...
^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/dependency_proxy_for_containers_spec.rb:37:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if env['REQUEST_PATH'] == '/token' ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/empty_states_spec.rb:15:24: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
project_relation = issuable == :issue ? :project : :source_project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/empty_states_spec.rb:45:35: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/empty_states_spec.rb:64:35: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/group_settings_spec.rb:172:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
expect(page).to have_content(target_group.name) if target_group
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/group_settings_spec.rb:176:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if target_group ...
^^^^^^^^^^^^^^^
spec/features/groups/members/sort_members_spec.rb:22:57: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
expect(page).to have_button("Sorting Direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/navbar_spec.rb:17:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
insert_after_nav_item(_('Analytics'), new_nav_item: settings_for_maintainer_nav_item) if Gitlab.ee?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/groups/navbar_spec.rb:50:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Gitlab.ee? ...
^^^^^^^^^^^^^
spec/features/issuables/issuable_list_spec.rb:67:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if issuable_type == :issue ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/issuable_list_spec.rb:75:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if issuable_type == :issue ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/issuable_list_spec.rb:85:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if issuable_type == :issue ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/issuable_list_spec.rb:100:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if issuable_type == :issue ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/markdown_references/jira_spec.rb:56:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if referenced_issues.include?(issue_actual_project) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/markdown_references/jira_spec.rb:64:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if referenced_issues.include?(issue_other_project) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/markdown_references/jira_spec.rb:176:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if referenced_issues.include?(issue) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issuables/markdown_references/jira_spec.rb:183:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if jira_referenced ...
^^^^^^^^^^^^^^^^^^
spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb:14:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if title.empty? ...
^^^^^^^^^^^^^^^
spec/features/issues/user_bulk_edits_issues_labels_spec.rb:432:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if unmark ...
^^^^^^^^^
spec/features/issues/user_bulk_edits_issues_labels_spec.rb:446:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if uncheck ...
^^^^^^^^^^
spec/features/issues/user_creates_branch_and_merge_request_spec.rb:226:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if branch_name ...
^^^^^^^^^^^^^^
spec/features/issues/user_edits_issue_spec.rb:219:17: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
toggle.click if toggle.visible?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/issues/user_interacts_with_awards_spec.rb:364:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if !status ...
^^^^^^^^^^
spec/features/labels_hierarchy_spec.rb:54:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board ...
^^^^^^^^
spec/features/labels_hierarchy_spec.rb:76:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board ...
^^^^^^^^
spec/features/labels_hierarchy_spec.rb:101:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board ...
^^^^^^^^
spec/features/labels_hierarchy_spec.rb:129:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board ...
^^^^^^^^
spec/features/labels_hierarchy_spec.rb:148:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if board ...
^^^^^^^^
spec/features/markdown/keyboard_shortcuts_spec.rb:10:24: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
let(:modifier_key) { is_mac ? :command : :control }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/markdown/keyboard_shortcuts_spec.rb:11:30: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
let(:other_modifier_key) { is_mac ? :control : :command }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/merge_request/batch_comments_spec.rb:287:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if resolve ...
^^^^^^^^^^
spec/features/merge_request/batch_comments_spec.rb:291:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if unresolve ...
^^^^^^^^^^^^
spec/features/merge_request/user_posts_diff_notes_spec.rb:274:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
assert_form_is_reset if asset_form_reset
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/merge_request/user_reverts_merge_request_spec.rb:58:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
uncheck('create_merge_request') unless create_merge_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb:202:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
line = line.find(:xpath, 'preceding-sibling::*[1][self::td]/preceding-sibling::*[1][self::td]') if line.tag_name == 'td'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/merge_request/user_squashes_merge_request_spec.rb:44:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
uncheck 'Delete source branch' unless protected_source_branch
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/merge_request/user_suggests_changes_on_diff_spec.rb:163:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if index < 1 ...
^^^^^^^^^^^^
spec/features/monitor_sidebar_link_spec.rb:12:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
project.add_role(user, role) if role
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/monitor_sidebar_link_spec.rb:33:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if render ...
^^^^^^^^^
spec/features/oauth_login_spec.rb:27:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
enter_code(user.current_otp) if enter_two_factor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/oauth_login_spec.rb:37:7: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
provider == :salesforce ? let(:additional_info) { { extra: { email_verified: true } } } : let(:additional_info) { {} }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/participants_autocomplete_spec.rb:19:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if resource_name == 'commit' ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/profiles/user_edit_profile_spec.rb:17:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if respond_to?(:wait_for_requests)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/profiles/user_edit_profile_spec.rb:28:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
wait_for_requests if respond_to?(:wait_for_requests)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/blobs/edit_spec.rb:30:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if is_diff ...
^^^^^^^^^^
spec/features/projects/blobs/edit_spec.rb:39:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if commit_changes ...
^^^^^^^^^^^^^^^^^
spec/features/projects/branches_spec.rb:347:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
branches = branches.select { |b| state == 'active' ? b.active? : b.stale? } if state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/branches_spec.rb:347:38: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
branches = branches.select { |b| state == 'active' ? b.active? : b.stale? } if state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/commit/cherry_pick_spec.rb:125:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
uncheck('create_merge_request') unless create_merge_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/commit/user_reverts_commit_spec.rb:78:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
uncheck('create_merge_request') unless create_merge_request
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/compare_spec.rb:177:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if commit ...
^^^^^^^^^
spec/features/projects/deploy_keys_spec.rb:23:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Gitlab::FIPS.enabled? ...
^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/environments/environment_spec.rb:369:44: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
allow_next_instance_of(Gitlab.ee? ? EE::Environment : Environment) do |instance|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/files/template_selector_menu_spec.rb:60:11: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
count = is_visible ? 1 : 0
^^^^^^^^^^^^^^^^^^
spec/features/projects/integrations/user_activates_issue_tracker_spec.rb:11:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
click_active_checkbox if disable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/integrations/user_activates_issue_tracker_spec.rb:16:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
fill_in 'service_new_issue_url', with: url unless skip_new_issue_url
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/integrations/user_activates_issue_tracker_spec.rb:28:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if skip_test ...
^^^^^^^^^^^^
spec/features/projects/integrations/user_activates_issue_tracker_spec.rb:54:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if skip_test ...
^^^^^^^^^^^^
spec/features/projects/integrations/user_activates_jira_spec.rb:26:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
unless Gitlab.ee? ...
^^^^^^^^^^^^^^^^^
spec/features/projects/labels/user_removes_labels_spec.rb:47:9: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
break unless li
^^^^^^^^^^^^^^^
spec/features/projects/members/sorting_spec.rb:152:57: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
expect(page).to have_button("Sorting Direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/milestones/milestone_spec.rb:73:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
expect(page).to have_text(panel_content) if panel_content
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/releases/user_views_releases_spec.rb:83:11: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
find('.sorting-direction-button').click if direction == :ascending
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/settings/project_settings_spec.rb:91:36: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
expect(button).to have_content(is_collapsed ? 'Expand' : 'Collapse')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/settings/project_settings_spec.rb:92:32: C: RSpec/AvoidConditionalStatements: Don't use conditional statments in specs, it might create flakiness
expect(panel[:class]).send(is_collapsed ? 'not_to' : 'to', include('expanded'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/settings/repository_settings_spec.rb:251:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if direction_select.disabled? ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/settings/user_transfers_a_project_spec.rb:30:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
return unless confirm
^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/show/user_sees_git_instructions_spec.rb:43:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
expect(page).to have_field('http_project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/show/user_sees_git_instructions_spec.rb:55:7: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
expect(page).to have_field('http_project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/tree/create_directory_spec.rb:56:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if page.has_css?('[data-testid="begin-commit-button"]') ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects/tree/create_file_spec.rb:45:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if page.has_css?('[data-testid="begin-commit-button"]') ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/projects_spec.rb:26:9: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
find(".project-template #{sub_template_tab}").click if sub_template_tab
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_uses_header_search_field_spec.rb:266:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
href.concat("&project_id=#{project_id}") if project_id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_uses_header_search_field_spec.rb:267:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
href.concat("&group_id=#{group_id}") if group_id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_uses_header_search_field_spec.rb:268:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
href.concat("&search_code=true") if search_code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_uses_header_search_field_spec.rb:269:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
href.concat("&repository_ref=#{repository_ref}") if repository_ref
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/snippets/explore_spec.rb:12:5: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
sign_in(user) if user
^^^^^^^^^^^^^^^^^^^^^
spec/features/tags/developer_creates_tag_spec.rb:73:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
fill_in 'message', with: message unless message.nil?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/tags/developer_creates_tag_spec.rb:74:5: C: RSpec/AvoidConditionalStatements: Don't use unless conditional statments in specs, it might create flakiness
fill_in 'release_description', with: desc unless desc.nil?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/usage_stats_consent_spec.rb:11:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
if Gitlab.ee? ...
^^^^^^^^^^^^^
spec/features/users/login_spec.rb:212:7: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
click_on("Sign in via 2FA code") if only_two_factor_webauthn_enabled
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/users/overview_spec.rb:206:13: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
break if i == 20
^^^^^^^^^^^^^^^^
spec/features/users/overview_spec.rb:269:13: C: RSpec/AvoidConditionalStatements: Don't use if conditional statments in specs, it might create flakiness
break if i == 20
^^^^^^^^^^^^^^^^
30703 files inspected, 141 offenses detected
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen