diff --git a/.rubocop_todo/rspec/be_nil.yml b/.rubocop_todo/rspec/be_nil.yml index 384c2c9db4c32813d9351785ac4a01a1e4b87669..95b06276941ad631ad9372e35c32e132dcd14753 100644 --- a/.rubocop_todo/rspec/be_nil.yml +++ b/.rubocop_todo/rspec/be_nil.yml @@ -38,23 +38,3 @@ RSpec/BeNil: - 'spec/lib/gitlab/metrics/subscribers/external_http_spec.rb' - 'spec/lib/gitlab/middleware/rack_multipart_tempfile_factory_spec.rb' - 'spec/lib/gitlab/project_template_spec.rb' - - 'spec/lib/gitlab/sample_data_template_spec.rb' - - 'spec/lib/gitlab/search_context/builder_spec.rb' - - 'spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb' - - 'spec/lib/gitlab/suggestions/suggestion_set_spec.rb' - - 'spec/lib/gitlab/template/gitignore_template_spec.rb' - - 'spec/lib/gitlab/timeless_spec.rb' - - 'spec/lib/gitlab/url_blockers/domain_allowlist_entry_spec.rb' - - 'spec/lib/gitlab/url_blockers/ip_allowlist_entry_spec.rb' - - 'spec/lib/mattermost/session_spec.rb' - - 'spec/lib/web_ide/config/entry/global_spec.rb' - - 'spec/migrations/20240212172655_self_hosted_sent_notifications_cleanup_spec.rb' - - 'spec/models/activity_pub/releases_subscription_spec.rb' - - 'spec/models/ci/secure_file_spec.rb' - - 'spec/models/diff_note_spec.rb' - - 'spec/models/grafana_integration_spec.rb' - - 'spec/models/group_spec.rb' - - 'spec/models/ml/experiment_spec.rb' - - 'spec/models/ml/model_spec.rb' - - 'spec/models/ml/model_version_spec.rb' - - 'spec/models/project_spec.rb' diff --git a/spec/lib/gitlab/sample_data_template_spec.rb b/spec/lib/gitlab/sample_data_template_spec.rb index 09ca41fcfc2aee70b16a510abf9beffe6de73db0..9a8bd1dfdfdb2a19ff14a39f7386dc65c80188d8 100644 --- a/spec/lib/gitlab/sample_data_template_spec.rb +++ b/spec/lib/gitlab/sample_data_template_spec.rb @@ -26,7 +26,7 @@ context 'when there is no match' do let(:query) { 'no-match' } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end end diff --git a/spec/lib/gitlab/search_context/builder_spec.rb b/spec/lib/gitlab/search_context/builder_spec.rb index 19724cdcfa86a617696a024ca9b37bdac6c239ef..450ea0e5887d7b14b6cf676567e06ea54a951525 100644 --- a/spec/lib/gitlab/search_context/builder_spec.rb +++ b/spec/lib/gitlab/search_context/builder_spec.rb @@ -136,7 +136,7 @@ def be_search_context(project: nil, group: nil, snippets: [], ref: nil) end it 'returns nil without groups controller action' do - expect(subject.scope).to be(nil) + expect(subject.scope).to be_nil end context 'when on issues scope' do diff --git a/spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb b/spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb index 479ef29bbf91922bd64082e3a55964874f68cce0..91c884a9c831718b380f850e53dc748e1821b52c 100644 --- a/spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb +++ b/spec/lib/gitlab/sidekiq_daemon/monitor_spec.rb @@ -296,13 +296,13 @@ subject { monitor.send(:notification_channel_enabled?) } it 'return nil when SIDEKIQ_MONITOR_WORKER is not set' do - expect(subject).to be nil + expect(subject).to be_nil end it 'return nil when SIDEKIQ_MONITOR_WORKER set to 0' do allow(ENV).to receive(:fetch).with('SIDEKIQ_MONITOR_WORKER', 0).and_return("0") - expect(subject).to be nil + expect(subject).to be_nil end it 'return 1 when SIDEKIQ_MONITOR_WORKER set to 1' do diff --git a/spec/lib/gitlab/suggestions/suggestion_set_spec.rb b/spec/lib/gitlab/suggestions/suggestion_set_spec.rb index 4b8327ddfab94b4daf456535a1540c0005c8d83e..4a822717c78863bec71024e9ad3d1d437386b679 100644 --- a/spec/lib/gitlab/suggestions/suggestion_set_spec.rb +++ b/spec/lib/gitlab/suggestions/suggestion_set_spec.rb @@ -94,7 +94,7 @@ def create_suggestion(file_path, new_line, to_content) end it 'returns nil if no errors are found' do - expect(suggestion_set.error_message).to be(nil) + expect(suggestion_set.error_message).to be_nil end end diff --git a/spec/lib/gitlab/template/gitignore_template_spec.rb b/spec/lib/gitlab/template/gitignore_template_spec.rb index 365b579d08e4a1dd7403ec9401b2a5a8512535f0..80c5a144093aa2549211f77197d4ea28c97665ea 100644 --- a/spec/lib/gitlab/template/gitignore_template_spec.rb +++ b/spec/lib/gitlab/template/gitignore_template_spec.rb @@ -20,7 +20,7 @@ describe '.find' do it 'returns nil if the file does not exist' do - expect(subject.find('mepmep-yadida')).to be nil + expect(subject.find('mepmep-yadida')).to be_nil end it 'returns the Gitignore object of a valid file' do diff --git a/spec/lib/gitlab/timeless_spec.rb b/spec/lib/gitlab/timeless_spec.rb index d806349d3261ac128f077a2a6feedabb2178ff0a..6da8b69bfdf0616b75233789dfde48432f273a26 100644 --- a/spec/lib/gitlab/timeless_spec.rb +++ b/spec/lib/gitlab/timeless_spec.rb @@ -21,7 +21,7 @@ model.save!(username: "#{model.username}-a") end - expect(model.created_at).to be(nil) + expect(model.created_at).to be_nil end it 'does not record updated_at' do diff --git a/spec/lib/gitlab/url_blockers/domain_allowlist_entry_spec.rb b/spec/lib/gitlab/url_blockers/domain_allowlist_entry_spec.rb index 2405b6769b7df4f4224eaadead72c9dea58714be..2534fcc5ee626c087bbec8e9539d09e66415c792 100644 --- a/spec/lib/gitlab/url_blockers/domain_allowlist_entry_spec.rb +++ b/spec/lib/gitlab/url_blockers/domain_allowlist_entry_spec.rb @@ -10,7 +10,7 @@ domain_allowlist_entry = described_class.new(domain) expect(domain_allowlist_entry.domain).to eq(domain) - expect(domain_allowlist_entry.port).to be(nil) + expect(domain_allowlist_entry.port).to be_nil end it 'initializes with port' do diff --git a/spec/lib/gitlab/url_blockers/ip_allowlist_entry_spec.rb b/spec/lib/gitlab/url_blockers/ip_allowlist_entry_spec.rb index 3c1c30fc052b317a88f18b5bf453fca8ec10dfa4..8c673aba18c38b0a377391306b18495e90d8fe2b 100644 --- a/spec/lib/gitlab/url_blockers/ip_allowlist_entry_spec.rb +++ b/spec/lib/gitlab/url_blockers/ip_allowlist_entry_spec.rb @@ -10,7 +10,7 @@ ip_allowlist_entry = described_class.new(ipv4) expect(ip_allowlist_entry.ip).to eq(ipv4) - expect(ip_allowlist_entry.port).to be(nil) + expect(ip_allowlist_entry.port).to be_nil end it 'initializes with port' do diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index 0abb132eece24eeb970e742a468bbd03f00486e5..1582efe17a68b491ca47b3e936a978348a40051c 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -41,7 +41,7 @@ it 'returns nill on calling a non exisitng method on request' do return_value = subject.request.method_missing("non_existing_method", "something") do end - expect(return_value).to be(nil) + expect(return_value).to be_nil end end diff --git a/spec/lib/web_ide/config/entry/global_spec.rb b/spec/lib/web_ide/config/entry/global_spec.rb index 24b7ef340b4f0e093d7b0544765d07c9a71a8aa0..a9ea4b6f7a6fc99dd04575e2db8f74bc82026a33 100644 --- a/spec/lib/web_ide/config/entry/global_spec.rb +++ b/spec/lib/web_ide/config/entry/global_spec.rb @@ -56,7 +56,7 @@ context 'when not composed' do describe '#terminal_value' do it 'returns nil' do - expect(global.terminal_value).to be nil + expect(global.terminal_value).to be_nil end end diff --git a/spec/migrations/20240212172655_self_hosted_sent_notifications_cleanup_spec.rb b/spec/migrations/20240212172655_self_hosted_sent_notifications_cleanup_spec.rb index 2594e9481b835720cc209ca40f504fe2c519fb87..486010cce4c743a41db1ccf0aac4d09f24aea973 100644 --- a/spec/migrations/20240212172655_self_hosted_sent_notifications_cleanup_spec.rb +++ b/spec/migrations/20240212172655_self_hosted_sent_notifications_cleanup_spec.rb @@ -28,13 +28,13 @@ migration.before -> { sent_notifications.reset_column_information - expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be nil + expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be_nil } migration.after -> { sent_notifications.reset_column_information - expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be nil + expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be_nil } end end @@ -59,7 +59,7 @@ end expect(sent_notifications.columns.find { |c| c.name == 'id' }.sql_type).to eq('bigint') - expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be nil + expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be_nil end end @@ -88,7 +88,7 @@ sent_notifications.reset_column_information expect(sent_notifications.columns.find { |c| c.name == 'id' }.sql_type).to eq('bigint') - expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be nil + expect(sent_notifications.columns.find { |c| c.name == 'id_convert_to_bigint' }).to be_nil end end end diff --git a/spec/models/activity_pub/releases_subscription_spec.rb b/spec/models/activity_pub/releases_subscription_spec.rb index 0633f293971b674a663c662e9700b91a22426877..8f03be95b1513e4398172966821fd3ff57029f6d 100644 --- a/spec/models/activity_pub/releases_subscription_spec.rb +++ b/spec/models/activity_pub/releases_subscription_spec.rb @@ -75,19 +75,19 @@ it 'returns nil if project and url do not match' do result = described_class.find_by_project_and_subscriber(0, 'I really should not exist') - expect(result).to be(nil) + expect(result).to be_nil end it 'returns nil if project does not match' do result = described_class.find_by_project_and_subscriber(0, subscription.subscriber_url) - expect(result).to be(nil) + expect(result).to be_nil end it 'returns nil if url does not match' do result = described_class.find_by_project_and_subscriber(subscription.project_id, 'I really should not exist') - expect(result).to be(nil) + expect(result).to be_nil end end end diff --git a/spec/models/ci/secure_file_spec.rb b/spec/models/ci/secure_file_spec.rb index 40c04dce93c2f6cff58c1a83d8bd83c366190089..451e24bf4e9825f752cf26916eb972816dfca83a 100644 --- a/spec/models/ci/secure_file_spec.rb +++ b/spec/models/ci/secure_file_spec.rb @@ -104,7 +104,7 @@ it 'returns nil if there is no file extension' do file = build(:ci_secure_file, name: 'file1') - expect(file.file_extension).to be nil + expect(file.file_extension).to be_nil end end @@ -144,7 +144,7 @@ it 'returns nil when the file type is not supported by any parsers' do file = build(:ci_secure_file, name: 'file1.foo') - expect(file.metadata_parser).to be nil + expect(file.metadata_parser).to be_nil end end diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb index 992c6003b27060e1a0b33e1facdc11cda16cc1ae..235553cbfb84bcafe97d53b61922e31610eeeec8 100644 --- a/spec/models/diff_note_spec.rb +++ b/spec/models/diff_note_spec.rb @@ -583,7 +583,7 @@ it "does not validate diff line" do diff_line = subject.diff_line - expect(diff_line).to be nil + expect(diff_line).to be_nil expect(subject).to be_valid end diff --git a/spec/models/grafana_integration_spec.rb b/spec/models/grafana_integration_spec.rb index 83a0b89d8b2de63fec48256577e837a53e9e9b7a..0c7edab699860b666e234ab51d9b0151442c8290 100644 --- a/spec/models/grafana_integration_spec.rb +++ b/spec/models/grafana_integration_spec.rb @@ -62,7 +62,7 @@ it 'returns nil' do grafana_integration.update!(enabled: false) - expect(grafana_integration.client).to be(nil) + expect(grafana_integration.client).to be_nil end end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 8613b308514d73ee333cd4552cef228bd9ec4f54..ff39a0922b1b3b8e396f49eb82f3165deac8eda1 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -3562,7 +3562,7 @@ def define_cache_expectations(cache_key) let(:import_export_upload) { create(:import_export_upload, group: group) } it 'returns nil' do - expect(group.import_export_upload_by_user(user)).to be nil + expect(group.import_export_upload_by_user(user)).to be_nil end end end @@ -4208,7 +4208,7 @@ def define_cache_expectations(cache_key) it 'returns nil if no readme project is present' do create(:project, :repository, namespace: group) - expect(group.group_readme).to be(nil) + expect(group.group_readme).to be_nil end end diff --git a/spec/models/ml/experiment_spec.rb b/spec/models/ml/experiment_spec.rb index 9a688b3da07ff7767b26ea7f1e58098767a82315..ee1a9ed4140e858ba3a4ca1d7acc6bd3ef0bf4bf 100644 --- a/spec/models/ml/experiment_spec.rb +++ b/spec/models/ml/experiment_spec.rb @@ -86,7 +86,7 @@ context 'if does not exist' do let(:iid) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end end diff --git a/spec/models/ml/model_spec.rb b/spec/models/ml/model_spec.rb index 4d3b2371d7bd7bd1a28c539e9c075ff0fe199045..7fb5242b1b0049aa4a871a8066ec416ada9178e6 100644 --- a/spec/models/ml/model_spec.rb +++ b/spec/models/ml/model_spec.rb @@ -150,13 +150,13 @@ context 'if id has no match' do let(:id) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end context 'if project id does not match' do let(:project_id) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end end diff --git a/spec/models/ml/model_version_spec.rb b/spec/models/ml/model_version_spec.rb index bf8c44fbbb791494a75205ec3cc7e717c044fe05..febfb8edabea37936411ebc88df40b35f2cb255b 100644 --- a/spec/models/ml/model_version_spec.rb +++ b/spec/models/ml/model_version_spec.rb @@ -180,13 +180,13 @@ context 'if id has no match' do let(:id) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end context 'if project id does not match' do let(:project_id) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end end @@ -205,19 +205,19 @@ context 'if id has no match' do let(:version) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end context 'if project id does not match' do let(:project_id) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end context 'if model name does not match' do let(:model_name) { non_existing_record_id } - it { is_expected.to be(nil) } + it { is_expected.to be_nil } end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 43c8e06bb060df518b0c656f1590587bb5b956dd..c892da72ba1ecf514171a763fa8390f90b88fbef 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -8204,7 +8204,7 @@ def has_external_wiki let(:import_export_upload) { create(:import_export_upload, project: project) } it 'returns nil' do - expect(project.import_export_upload_by_user(user)).to be nil + expect(project.import_export_upload_by_user(user)).to be_nil end end end @@ -8238,7 +8238,7 @@ def has_external_wiki context 'when no jira imports' do it 'returns nil' do - expect(project.latest_jira_import).to be nil + expect(project.latest_jira_import).to be_nil end end