From f8cc668f200a666273c1db5f88ae3d40a5f5fb38 Mon Sep 17 00:00:00 2001 From: Archish Thakkar <archishthakkar@gmail.com> Date: Fri, 10 May 2024 22:48:32 +0000 Subject: [PATCH] Fix Lint/AmbiguousOperatorPrecedence 17 offenses Changelog: other --- .rubocop_todo/lint/ambiguous_operator_precedence.yml | 10 ---------- spec/requests/api/pypi_packages_spec.rb | 2 +- spec/requests/lfs_http_spec.rb | 2 +- .../calculate_next_run_service_spec.rb | 2 +- .../relative_position_rebalancing_service_spec.rb | 2 +- spec/services/web_hook_service_spec.rb | 4 ++-- spec/support/helpers/dependency_proxy_helpers.rb | 2 +- .../features/sidebar_shared_examples.rb | 2 +- .../models/relative_positioning_shared_examples.rb | 12 ++++++------ spec/tooling/lib/tooling/kubernetes_client_spec.rb | 6 +++--- 10 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.rubocop_todo/lint/ambiguous_operator_precedence.yml b/.rubocop_todo/lint/ambiguous_operator_precedence.yml index 63f21322716e9..8b1c0e30c4d54 100644 --- a/.rubocop_todo/lint/ambiguous_operator_precedence.yml +++ b/.rubocop_todo/lint/ambiguous_operator_precedence.yml @@ -116,13 +116,3 @@ Lint/AmbiguousOperatorPrecedence: - 'spec/models/merge_request_diff_spec.rb' - 'spec/models/packages/package_file_spec.rb' - 'spec/models/prometheus_alert_spec.rb' - - 'spec/requests/api/pypi_packages_spec.rb' - - 'spec/requests/lfs_http_spec.rb' - - 'spec/services/ci/pipeline_schedules/calculate_next_run_service_spec.rb' - - 'spec/services/issues/relative_position_rebalancing_service_spec.rb' - - 'spec/services/web_hook_service_spec.rb' - - 'spec/support/helpers/dependency_proxy_helpers.rb' - - 'spec/support/shared_examples/features/sidebar_shared_examples.rb' - - 'spec/support/shared_examples/models/relative_positioning_shared_examples.rb' - - 'spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb' - - 'spec/tooling/lib/tooling/kubernetes_client_spec.rb' diff --git a/spec/requests/api/pypi_packages_spec.rb b/spec/requests/api/pypi_packages_spec.rb index 60061124f25c1..34d4410f9ac11 100644 --- a/spec/requests/api/pypi_packages_spec.rb +++ b/spec/requests/api/pypi_packages_spec.rb @@ -388,7 +388,7 @@ def snowplow_context(user_role: :developer) include_context 'setup auth headers' before do - params[:sha256_digest] = 'a' * 63 + '%' + params[:sha256_digest] = ('a' * 63) + '%' project.add_developer(user) end diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index c33981dcc6f48..8c6507e53e675 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -882,7 +882,7 @@ def authorization_in_action(action) where(:size, :sha256, :status) do nil | nil | :ok # Test setup sanity check 0 | nil | :bad_request - nil | 'a' * 64 | :bad_request + nil | ('a' * 64) | :bad_request end with_them do diff --git a/spec/services/ci/pipeline_schedules/calculate_next_run_service_spec.rb b/spec/services/ci/pipeline_schedules/calculate_next_run_service_spec.rb index b3bdfdee95622..8039139f46897 100644 --- a/spec/services/ci/pipeline_schedules/calculate_next_run_service_spec.rb +++ b/spec/services/ci/pipeline_schedules/calculate_next_run_service_spec.rb @@ -29,7 +29,7 @@ '*/5 * * * *' | '0 * * * *' | nil | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5) # 1.day / 2.hours => 12 times a day and it is invalid because there is a minimum for plan limits. # See: https://docs.gitlab.com/ee/administration/instance_limits.html#limit-the-number-of-pipelines-created-by-a-pipeline-schedule-per-day - '*/5 * * * *' | '0 * * * *' | 1.day / 2.hours | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5) + '*/5 * * * *' | '0 * * * *' | (1.day / 2.hours) | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5) '*/5 * * * *' | '0 * * * *' | 2000 | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5) '*/5 * * * *' | '0 * * * *' | -24 | Time.zone.local(2021, 5, 27, 11, 0) | Time.zone.local(2021, 5, 27, 12, 5) end diff --git a/spec/services/issues/relative_position_rebalancing_service_spec.rb b/spec/services/issues/relative_position_rebalancing_service_spec.rb index 512990b5b3d7a..1525b37df2b79 100644 --- a/spec/services/issues/relative_position_rebalancing_service_spec.rb +++ b/spec/services/issues/relative_position_rebalancing_service_spec.rb @@ -146,7 +146,7 @@ def issues_in_position_order service.send(:preload_issue_ids) expect(service.send(:caching).get_cached_issue_ids(0, 300)).not_to be_empty # simulate we already rebalanced half the issues - index = clump_size * 3 / 2 + 1 + index = (clump_size * 3 / 2) + 1 service.send(:caching).cache_current_index(index) end diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index 8e6bf22282347..30a0165aaaab3 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -609,7 +609,7 @@ context 'with oversize response body' do let(:oversize_body) { 'a' * (described_class::RESPONSE_BODY_SIZE_LIMIT + 1) } - let(:stripped_body) { 'a' * (described_class::RESPONSE_BODY_SIZE_LIMIT - ellipsis.bytesize) + ellipsis } + let(:stripped_body) { ('a' * (described_class::RESPONSE_BODY_SIZE_LIMIT - ellipsis.bytesize)) + ellipsis } before do stub_full_request(project_hook.url, method: :post).to_return(status: 200, body: oversize_body) @@ -663,7 +663,7 @@ context 'with oversize header' do let(:oversize_header) { 'a' * (described_class::RESPONSE_HEADERS_SIZE_LIMIT + 1) } - let(:stripped_header) { 'a' * (described_class::RESPONSE_HEADERS_SIZE_LIMIT - ellipsis.bytesize) + ellipsis } + let(:stripped_header) { ('a' * (described_class::RESPONSE_HEADERS_SIZE_LIMIT - ellipsis.bytesize)) + ellipsis } let(:response_headers) { { 'oversized-header' => oversize_header } } let(:expected_response_headers) { { 'Oversized-Header' => stripped_header } } diff --git a/spec/support/helpers/dependency_proxy_helpers.rb b/spec/support/helpers/dependency_proxy_helpers.rb index ae54c64a4d972..b4971aa8b3121 100644 --- a/spec/support/helpers/dependency_proxy_helpers.rb +++ b/spec/support/helpers/dependency_proxy_helpers.rb @@ -40,7 +40,7 @@ def build_jwt(user_or_token = nil, expire_time: nil) jwt['user_id'] = user_or_token.id if user_or_token.is_a?(User) jwt['personal_access_token'] = user_or_token.token if user_or_token.is_a?(PersonalAccessToken) jwt['deploy_token'] = user_or_token.token if user_or_token.is_a?(DeployToken) - jwt.expire_time = expire_time || jwt.issued_at + 1.minute + jwt.expire_time = expire_time || (jwt.issued_at + 1.minute) end end end diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb index 69f1156179222..7054d939a3f8e 100644 --- a/spec/support/shared_examples/features/sidebar_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb @@ -184,7 +184,7 @@ context 'when limitedToHours instance option is turned on' do before do # 3600+3600*24 = 1d 1h or 25h - issue.timelogs.create!(time_spent: 3600 + 3600 * 24, user: user) + issue.timelogs.create!(time_spent: 3600 + (3600 * 24), user: user) stub_application_setting(time_tracking_limit_to_hours: true) refresh_and_click_first_card diff --git a/spec/support/shared_examples/models/relative_positioning_shared_examples.rb b/spec/support/shared_examples/models/relative_positioning_shared_examples.rb index 692320d45d5e7..d5daf6b29abe4 100644 --- a/spec/support/shared_examples/models/relative_positioning_shared_examples.rb +++ b/spec/support/shared_examples/models/relative_positioning_shared_examples.rb @@ -330,9 +330,9 @@ def as_items(items) let(:start) { RelativePositioning::START_POSITION } before do - item1.update!(relative_position: start - RelativePositioning::IDEAL_DISTANCE * 0) - item2.update!(relative_position: start - RelativePositioning::IDEAL_DISTANCE * 1) - item3.update!(relative_position: start - RelativePositioning::IDEAL_DISTANCE * 2) + item1.update!(relative_position: start - (RelativePositioning::IDEAL_DISTANCE * 0)) + item2.update!(relative_position: start - (RelativePositioning::IDEAL_DISTANCE * 1)) + item3.update!(relative_position: start - (RelativePositioning::IDEAL_DISTANCE * 2)) end def leap_frog @@ -414,9 +414,9 @@ def leap_frog context 'leap-frogging' do before do start = RelativePositioning::START_POSITION - item1.update!(relative_position: start + RelativePositioning::IDEAL_DISTANCE * 0) - item2.update!(relative_position: start + RelativePositioning::IDEAL_DISTANCE * 1) - item3.update!(relative_position: start + RelativePositioning::IDEAL_DISTANCE * 2) + item1.update!(relative_position: start + (RelativePositioning::IDEAL_DISTANCE * 0)) + item2.update!(relative_position: start + (RelativePositioning::IDEAL_DISTANCE * 1)) + item3.update!(relative_position: start + (RelativePositioning::IDEAL_DISTANCE * 2)) end let(:item3) { create(factory, default_params) } diff --git a/spec/tooling/lib/tooling/kubernetes_client_spec.rb b/spec/tooling/lib/tooling/kubernetes_client_spec.rb index 86427c3f55abd..df36f3d091733 100644 --- a/spec/tooling/lib/tooling/kubernetes_client_spec.rb +++ b/spec/tooling/lib/tooling/kubernetes_client_spec.rb @@ -5,9 +5,9 @@ RSpec.describe Tooling::KubernetesClient do let(:instance) { described_class.new } - let(:one_day_ago) { Time.now - 3600 * 24 * 1 } - let(:two_days_ago) { Time.now - 3600 * 24 * 2 } - let(:three_days_ago) { Time.now - 3600 * 24 * 3 } + let(:one_day_ago) { Time.now - (3600 * 24 * 1) } + let(:two_days_ago) { Time.now - (3600 * 24 * 2) } + let(:three_days_ago) { Time.now - (3600 * 24 * 3) } before do # Global mock to ensure that no kubectl commands are run by accident in a test. -- GitLab