Commit a379ab20 authored by Alex Kalderimis's avatar Alex Kalderimis

Fix outstanding rubocop violations in BaseField

These were discovered using REVEAL_RUBOCOP_TODO
parent 3b96d441
......@@ -54,8 +54,10 @@ module Types
end
def check_feature_flag(args)
args[:description] = feature_documentation_message(args[:feature_flag], args[:description]) if args[:feature_flag].present?
args.delete(:feature_flag)
ff = args.delete(:feature_flag)
return args unless ff.present?
args[:description] = feature_documentation_message(ff, args[:description])
args
end
......@@ -78,7 +80,9 @@ module Types
# items which can be loaded.
proc do |ctx, args, child_complexity|
# Resolvers may add extra complexity depending on used arguments
complexity = child_complexity + self.resolver&.try(:resolver_complexity, args, child_complexity: child_complexity).to_i
complexity = child_complexity + resolver&.try(
:resolver_complexity, args, child_complexity: child_complexity
).to_i
complexity += 1 if calls_gitaly?
complexity += complexity * connection_complexity_multiplier(ctx, args)
......@@ -93,7 +97,7 @@ module Types
page_size = field_defn.connection_max_page_size || ctx.schema.default_max_page_size
limit_value = [args[:first], args[:last], page_size].compact.min
multiplier = self.resolver&.try(:complexity_multiplier, args).to_f
multiplier = resolver&.try(:complexity_multiplier, args).to_f
limit_value * multiplier
end
end
......
......@@ -47,7 +47,7 @@ RSpec.describe GitlabSchema do
end
describe '.execute' do
context 'for different types of users' do
context 'with different types of users' do
context 'when no context' do
it 'returns DEFAULT_MAX_COMPLEXITY' do
expect(GraphQL::Schema)
......@@ -78,13 +78,15 @@ RSpec.describe GitlabSchema do
context 'when a logged in user' do
it 'returns AUTHENTICATED_COMPLEXITY' do
expect(GraphQL::Schema).to receive(:execute).with('query', hash_including(max_complexity: GitlabSchema::AUTHENTICATED_COMPLEXITY))
expect(GraphQL::Schema).to receive(:execute)
.with('query', hash_including(max_complexity: GitlabSchema::AUTHENTICATED_COMPLEXITY))
described_class.execute('query', context: { current_user: user })
end
it 'returns AUTHENTICATED_MAX_DEPTH' do
expect(GraphQL::Schema).to receive(:execute).with('query', hash_including(max_depth: GitlabSchema::AUTHENTICATED_MAX_DEPTH))
expect(GraphQL::Schema).to receive(:execute)
.with('query', hash_including(max_depth: GitlabSchema::AUTHENTICATED_MAX_DEPTH))
described_class.execute('query', context: { current_user: user })
end
......@@ -94,7 +96,8 @@ RSpec.describe GitlabSchema do
it 'returns ADMIN_COMPLEXITY' do
user = build :user, :admin
expect(GraphQL::Schema).to receive(:execute).with('query', hash_including(max_complexity: GitlabSchema::ADMIN_COMPLEXITY))
expect(GraphQL::Schema).to receive(:execute)
.with('query', hash_including(max_complexity: GitlabSchema::ADMIN_COMPLEXITY))
described_class.execute('query', context: { current_user: user })
end
......@@ -130,7 +133,7 @@ RSpec.describe GitlabSchema do
end
describe '.object_from_id' do
context 'for subclasses of `ApplicationRecord`' do
context 'with subclasses of `ApplicationRecord`' do
let_it_be(:user) { create(:user) }
it 'returns the correct record' do
......@@ -162,7 +165,7 @@ RSpec.describe GitlabSchema do
end
end
context 'for classes that are not ActiveRecord subclasses and have implemented .lazy_find' do
context 'with classes that are not ActiveRecord subclasses and have implemented .lazy_find' do
it 'returns the correct record' do
note = create(:discussion_note_on_merge_request)
......@@ -182,7 +185,7 @@ RSpec.describe GitlabSchema do
end
end
context 'for other classes' do
context 'with other classes' do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`
before do
......
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