Commit f5f0f099 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '239356-fix-Style/RedundantFetchBlock' into 'master'

Fix Style/RedundantFetchBlock rubocop offence

See merge request gitlab-org/gitlab!82093
parents de24e6e9 1f56d105
......@@ -657,18 +657,6 @@ Style/NumericLiteralPrefix:
Style/PercentLiteralDelimiters:
Enabled: false
# Offense count: 26
# Cop supports --auto-correct.
# Configuration parameters: SafeForConstants.
Style/RedundantFetchBlock:
Exclude:
- 'app/finders/admin/projects_finder.rb'
- 'lib/gitlab/diff/file.rb'
- 'spec/lib/gitlab/json_cache_spec.rb'
- 'spec/lib/gitlab/metrics/dashboard/cache_spec.rb'
- 'spec/lib/gitlab/null_request_store_spec.rb'
- 'spec/lib/gitlab/safe_request_store_spec.rb'
# Offense count: 206
# Cop supports --auto-correct.
Style/RedundantInterpolation:
......
......@@ -69,7 +69,7 @@ class Admin::ProjectsFinder
end
def sort(items)
sort = params.fetch(:sort) { 'latest_activity_desc' }
sort = params.fetch(:sort, 'latest_activity_desc')
items.sort_by_attribute(sort)
end
end
......@@ -383,7 +383,7 @@ module Gitlab
private
def diffable_by_attribute?
repository.attributes(file_path).fetch('diff') { true }
repository.attributes(file_path).fetch('diff', true)
end
# NOTE: Files with unsupported encodings (e.g. UTF-16) are treated as binary by git, but they are recognized as text files during encoding detection. These files have `Binary files a/filename and b/filename differ' as their raw diff content which cannot be used. We need to handle this special case and avoid displaying incorrect diff.
......
# frozen_string_literal: true
# rubocop:disable Style/RedundantFetchBlock
require 'spec_helper'
......@@ -547,3 +548,4 @@ RSpec.describe Gitlab::JsonCache do
end
end
end
# rubocop:enable Style/RedundantFetchBlock
# frozen_string_literal: true
# rubocop:disable Style/RedundantFetchBlock
require 'spec_helper'
......@@ -84,3 +85,4 @@ RSpec.describe Gitlab::Metrics::Dashboard::Cache, :use_clean_rails_memory_store_
end
end
end
# rubocop:enable Style/RedundantFetchBlock
......@@ -49,7 +49,7 @@ RSpec.describe Gitlab::NullRequestStore do
describe '#fetch' do
it 'returns the block result' do
expect(null_store.fetch('key') { 'block result' }).to eq('block result')
expect(null_store.fetch('key') { 'block result' }).to eq('block result') # rubocop:disable Style/RedundantFetchBlock
end
end
......
......@@ -183,7 +183,7 @@ RSpec.describe Gitlab::SafeRequestStore do
context 'when RequestStore is active', :request_store do
it 'uses RequestStore' do
expect do
described_class.fetch('foo') { 'block result' }
described_class.fetch('foo') { 'block result' } # rubocop:disable Style/RedundantFetchBlock
end.to change { described_class.read('foo') }.from(nil).to('block result')
end
end
......@@ -193,7 +193,7 @@ RSpec.describe Gitlab::SafeRequestStore do
RequestStore.clear! # Ensure clean
expect do
described_class.fetch('foo') { 'block result' }
described_class.fetch('foo') { 'block result' } # rubocop:disable Style/RedundantFetchBlock
end.not_to change { described_class.read('foo') }.from(nil)
RequestStore.clear! # Clean up
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment