diff --git a/.rubocop_todo/lint/ambiguous_operator_precedence.yml b/.rubocop_todo/lint/ambiguous_operator_precedence.yml index e29d5065913e6f1186ce2180eb7f37753219c2e5..46108eb252798fd67acd316bf3b5819b3f07bd48 100644 --- a/.rubocop_todo/lint/ambiguous_operator_precedence.yml +++ b/.rubocop_todo/lint/ambiguous_operator_precedence.yml @@ -33,19 +33,6 @@ Lint/AmbiguousOperatorPrecedence: - 'lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb' - 'lib/gitlab/database/postgres_hll/buckets.rb' - 'lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb' - - 'scripts/packages/automated_cleanup.rb' - - 'scripts/perf/gc/print_gc_stats.rb' - - 'scripts/perf/query_limiting_report.rb' - - 'scripts/review_apps/automated_cleanup.rb' - - 'spec/controllers/projects/issues_controller_spec.rb' - - 'spec/controllers/search_controller_spec.rb' - - 'spec/helpers/time_helper_spec.rb' - - 'spec/lib/api/helpers/pagination_strategies_spec.rb' - - 'spec/lib/banzai/filter/front_matter_filter_spec.rb' - - 'spec/lib/gitlab/ci/ansi2json/line_spec.rb' - - 'spec/lib/gitlab/ci/runner_releases_spec.rb' - - 'spec/lib/gitlab/ci/trace/chunked_io_spec.rb' - - 'spec/lib/gitlab/ci/trace/stream_spec.rb' - 'spec/lib/gitlab/conan_token_spec.rb' - 'spec/lib/gitlab/database/background_migration/batched_job_spec.rb' - 'spec/lib/gitlab/database/batch_count_spec.rb' diff --git a/scripts/packages/automated_cleanup.rb b/scripts/packages/automated_cleanup.rb index 8d9ba1e4a347abe266ddf1ba688757bac3ceefe0..56281b1a99323ba5684d1e2144b14c8199813764 100755 --- a/scripts/packages/automated_cleanup.rb +++ b/scripts/packages/automated_cleanup.rb @@ -62,7 +62,7 @@ def delete_package(package) end def time_ago(days:) - Time.now - days * 24 * 3600 + Time.now - (days * 24 * 3600) end def old_enough(package, days_for_delete) diff --git a/scripts/perf/gc/print_gc_stats.rb b/scripts/perf/gc/print_gc_stats.rb index a72a046051c1cce012f502705cdfea0ea0e195ca..8fb775c75a8a37b49391a6a1dc40b6f9d3259b43 100755 --- a/scripts/perf/gc/print_gc_stats.rb +++ b/scripts/perf/gc/print_gc_stats.rb @@ -62,8 +62,8 @@ class << self values += gc_stat_keys.map { |k| gc_stats[k] } values << ::Gitlab::Metrics::System.memory_usage_rss[:total] values << gc_total_time -values << tms.utime + tms.cutime -values << tms.stime + tms.cstime +values << (tms.utime + tms.cutime) +values << (tms.stime + tms.cstime) values << tms.real puts values.join(',') diff --git a/scripts/perf/query_limiting_report.rb b/scripts/perf/query_limiting_report.rb index 6326b2590ae207acbd9afa4b8a0b53379cb71cb1..27622d212c18702ca7158bb0975149afad87abdf 100755 --- a/scripts/perf/query_limiting_report.rb +++ b/scripts/perf/query_limiting_report.rb @@ -66,17 +66,17 @@ def execute puts "\n\nFound #{total_issues.length} total issues with '#{ISSUES_SEARCH_LABEL}' search label, #{issues.length} are still opened..." puts "\n\nFound #{code_lines.length} total occurrences of '#{CODE_LINES_SEARCH_STRING}' in code..." - puts "\n" + '-' * 80 + puts "\n" + ('-' * 80) puts "\n\nIssues without any '#{CODE_LINES_SEARCH_STRING}' code references (#{issues_without_code_references.length} total):" pp issues_without_code_references - puts "\n" + '-' * 80 + puts "\n" + ('-' * 80) puts "\n\n'#{CODE_LINES_SEARCH_STRING}' calls with references to an issue which doesn't have '#{ISSUES_SEARCH_LABEL}' search label (#{code_lines_with_missing_issues.length} total):" pp code_lines_with_missing_issues - puts "\n" + '-' * 80 + puts "\n" + ('-' * 80) puts "\n\n'#{CODE_LINES_SEARCH_STRING}' calls with no issue iid (#{code_lines_without_issue_iid&.length || 0} total):" pp code_lines_without_issue_iid diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb index 1e4fbf85f9ba1196ac1b3abf76d38cbf1946df08..02ae8062139f981826c02ee06692e090b355a507 100755 --- a/scripts/review_apps/automated_cleanup.rb +++ b/scripts/review_apps/automated_cleanup.rb @@ -272,7 +272,7 @@ def threshold_time(days:) raise "days should be an integer between 1 and 365 inclusive! Got #{days_integer}" unless days_integer.between?(1, 365) - Time.now - days_integer * 24 * 3600 + Time.now - (days_integer * 24 * 3600) end def ignore_exception?(exception_message, exceptions_ignored) diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index bdefa8920073e47aad505006c506132a2ccc61ef..0fc0b0bcc2e04fee27e3d6e225b0c17c3a60bde9 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -167,8 +167,8 @@ term_limit = Gitlab::Search::Params::SEARCH_TERM_LIMIT term_char_limit = Gitlab::Search::AbuseDetection::ABUSIVE_TERM_SIZE { - chars_under_limit: (('a' * (term_char_limit - 1) + ' ') * (term_limit - 1))[0, char_limit], - chars_over_limit: (('a' * (term_char_limit - 1) + ' ') * (term_limit - 1))[0, char_limit + 1], + chars_under_limit: ((('a' * (term_char_limit - 1)) + ' ') * (term_limit - 1))[0, char_limit], + chars_over_limit: ((('a' * (term_char_limit - 1)) + ' ') * (term_limit - 1))[0, char_limit + 1], terms_under_limit: ('abc ' * (term_limit - 1)), terms_over_limit: ('abc ' * (term_limit + 1)), term_length_over_limit: ('a' * (term_char_limit + 1)), diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb index 02e28b2ba055eec7a34f7e412184135b0c3dff1f..add36ec705fb51b4e3db4e6e5c159b22f8678b90 100644 --- a/spec/helpers/time_helper_spec.rb +++ b/spec/helpers/time_helper_spec.rb @@ -28,9 +28,9 @@ 0 | "00:00" 1.second | "00:01" 42.seconds | "00:42" - 2.minutes + 1.second | "02:01" - 3.hours + 2.minutes + 1.second | "03:02:01" - 30.hours | "30:00:00" + (2.minutes + 1.second) | "02:01" + (3.hours + 2.minutes + 1.second) | "03:02:01" + 30.hours | "30:00:00" end with_them do diff --git a/spec/lib/api/helpers/pagination_strategies_spec.rb b/spec/lib/api/helpers/pagination_strategies_spec.rb index f6e8e3cc75627e3cee58145abf16c7714460e66b..7ba185e13feee8ce1e74f1d98210456dc07fe71f 100644 --- a/spec/lib/api/helpers/pagination_strategies_spec.rb +++ b/spec/lib/api/helpers/pagination_strategies_spec.rb @@ -70,7 +70,7 @@ end context 'when a request scope is given' do - let(:params) { { per_page: 100, page: offset_limit / 100 + 1 } } + let(:params) { { per_page: 100, page: (offset_limit / 100) + 1 } } let(:request_scope) { double("scope", actual_limits: plan_limits) } context 'when the scope limit is exceeded' do @@ -106,7 +106,7 @@ context 'when a request scope is not given' do context 'when the default limits are exceeded' do - let(:params) { { per_page: 100, page: offset_limit / 100 + 1 } } + let(:params) { { per_page: 100, page: (offset_limit / 100) + 1 } } it 'renders a 405 error' do expect(subject).to receive(:error!).with(/maximum allowed offset/, 405) @@ -128,7 +128,7 @@ end context 'when keyset pagination is not available for the relation' do - let(:params) { { per_page: 100, page: offset_limit / 100 + 1 } } + let(:params) { { per_page: 100, page: (offset_limit / 100) + 1 } } before do allow(Gitlab::Pagination::Keyset).to receive(:available_for_type?).and_return(false) diff --git a/spec/lib/banzai/filter/front_matter_filter_spec.rb b/spec/lib/banzai/filter/front_matter_filter_spec.rb index 9d25dafb727f22570f23df9dd8f6401ceaab2e63..6dc6903a66267e118555e63385c453d43f5b57a6 100644 --- a/spec/lib/banzai/filter/front_matter_filter_spec.rb +++ b/spec/lib/banzai/filter/front_matter_filter_spec.rb @@ -191,7 +191,7 @@ describe 'protects against malicious backtracking' do it 'fails fast for strings with many spaces' do - content = "coding:" + " " * 50_000 + ";" + content = "coding:" + (" " * 50_000) + ";" expect do Timeout.timeout(3.seconds) { filter(content) } @@ -199,7 +199,7 @@ end it 'fails fast for strings with many newlines' do - content = "coding:\n" + ";;;" + "\n" * 10_000 + "x" + content = "coding:\n" + ";;;" + ("\n" * 10_000) + "x" expect do Timeout.timeout(3.seconds) { filter(content) } @@ -207,7 +207,7 @@ end it 'fails fast for strings with many `coding:`' do - content = "coding:" * 120_000 + "\n" * 80_000 + ";" + content = ("coding:" * 120_000) + ("\n" * 80_000) + ";" expect do Timeout.timeout(3.seconds) { filter(content) } diff --git a/spec/lib/gitlab/ci/ansi2json/line_spec.rb b/spec/lib/gitlab/ci/ansi2json/line_spec.rb index 475a54b275dc2a2b800954f61816b7cb921224b0..7c06b10a701db2bfdc8494ab005d16dfcf08545f 100644 --- a/spec/lib/gitlab/ci/ansi2json/line_spec.rb +++ b/spec/lib/gitlab/ci/ansi2json/line_spec.rb @@ -92,11 +92,11 @@ 0.seconds | '00:00' 7.seconds | '00:07' 75 | '01:15' - 1.minute + 15.seconds | '01:15' - 13.hours + 14.minutes + 15.seconds | '13:14:15' - 1.day + 13.hours + 14.minutes + 15.seconds | '37:14:15' - Float::MAX | '8765:00:00' - 10**10000 | '8765:00:00' + (1.minute + 15.seconds) | '01:15' + (13.hours + 14.minutes + 15.seconds) | '13:14:15' + (1.day + 13.hours + 14.minutes + 15.seconds) | '37:14:15' + Float::MAX | '8765:00:00' + (10**10000) | '8765:00:00' end with_them do diff --git a/spec/lib/gitlab/ci/runner_releases_spec.rb b/spec/lib/gitlab/ci/runner_releases_spec.rb index 126a5b854710999a083ec4896cedfd616829bde3..d63410dcbf786451e5066db98eb11a7001fd2864 100644 --- a/spec/lib/gitlab/ci/runner_releases_spec.rb +++ b/spec/lib/gitlab/ci/runner_releases_spec.rb @@ -75,7 +75,7 @@ def releases_by_minor http_call_timestamp_offsets = [] allow(Gitlab::HTTP).to receive(:get).with(runner_releases_url, anything) do - http_call_timestamp_offsets << Time.now.utc - start_time + http_call_timestamp_offsets << (Time.now.utc - start_time) err_class = opts&.dig(:raise_error) raise err_class if err_class diff --git a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb index 7a926a06f16f04627887e818ef5c7e4f8f40e200..fbed648905345d0e7086913711f831e47e35559a 100644 --- a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb +++ b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb @@ -326,9 +326,9 @@ end it 'has known length' do - expect(sample_trace_raw_utf8.bytesize).to eq(4 * 4 + 3 * 1) - expect(sample_trace_raw.bytesize).to eq(4 * 4 + 3 * 1) - expect(chunked_io.size).to eq(4 * 4 + 3 * 1) + expect(sample_trace_raw_utf8.bytesize).to eq((4 * 4) + (3 * 1)) + expect(sample_trace_raw.bytesize).to eq((4 * 4) + (3 * 1)) + expect(chunked_io.size).to eq((4 * 4) + (3 * 1)) end it_behaves_like 'all line matching' diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index 9439d29aa114a4b1bd184d216631fa6c48f86051..b8ceb012787374f2bc67124c09f14a00060c801c 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -450,14 +450,14 @@ end context 'long line' do - let(:data) { 'a' * 80000 + '100%' + 'a' * 80000 } + let(:data) { ('a' * 80000) + '100%' + ('a' * 80000) } let(:regex) { '\d+\%' } it { is_expected.to eq('100') } end context 'many lines' do - let(:data) { "foo\n" * 80000 + "100%\n" + "foo\n" * 80000 } + let(:data) { ("foo\n" * 80000) + "100%\n" + ("foo\n" * 80000) } let(:regex) { '\d+\%' } it { is_expected.to eq('100') }