Skip to content

Commit 1301568

Browse files
committed
re: RuboCop - get rid of redundant curly braces around a hash parameter
1 parent 024b2d5 commit 1301568

12 files changed

+32
-53
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,6 @@ Style/AlignHash:
1919
Exclude:
2020
- 'test/action_controller/json_api/pagination_test.rb'
2121

22-
# Offense count: 27
23-
# Cop supports --auto-correct.
24-
# Configuration parameters: EnforcedStyle, SupportedStyles.
25-
# SupportedStyles: braces, no_braces, context_dependent
26-
Style/BracesAroundHashParameters:
27-
Exclude:
28-
- 'test/action_controller/adapter_selector_test.rb'
29-
- 'test/action_controller/json_api/pagination_test.rb'
30-
- 'test/adapter/json_api/linked_test.rb'
31-
- 'test/adapter/json_api/pagination_links_test.rb'
32-
- 'test/adapter/null_test.rb'
33-
- 'test/adapter_test.rb'
34-
- 'test/collection_serializer_test.rb'
35-
- 'test/serializable_resource_test.rb'
36-
- 'test/serializers/associations_test.rb'
37-
- 'test/serializers/attributes_test.rb'
38-
- 'test/serializers/root_test.rb'
3922

4023
# Offense count: 271
4124
# Configuration parameters: EnforcedStyle, SupportedStyles.

test/action_controller/adapter_selector_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ module Serialization
55
class AdapterSelectorTest < ActionController::TestCase
66
class AdapterSelectorTestController < ActionController::Base
77
def render_using_default_adapter
8-
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
8+
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
99
render json: @profile
1010
end
1111

1212
def render_using_adapter_override
13-
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
13+
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
1414
render json: @profile, adapter: :json_api
1515
end
1616

1717
def render_skipping_adapter
18-
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
18+
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
1919
render json: @profile, adapter: false
2020
end
2121
end

test/action_controller/json_api/pagination_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class PaginationTest < ActionController::TestCase
1414
class PaginationTestController < ActionController::Base
1515
def setup
1616
@array = [
17-
Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
18-
Profile.new({ name: 'Name 2', description: 'Description 2', comments: 'Comments 2' }),
19-
Profile.new({ name: 'Name 3', description: 'Description 3', comments: 'Comments 3' })
17+
Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1'),
18+
Profile.new(name: 'Name 2', description: 'Description 2', comments: 'Comments 2'),
19+
Profile.new(name: 'Name 3', description: 'Description 3', comments: 'Comments 3')
2020
]
2121
end
2222

test/adapter/json_api/linked_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def setup
1717
@first_post = Post.new(id: 10, title: 'Hello!!', body: 'Hello, world!!')
1818
@second_post = Post.new(id: 20, title: 'New Post', body: 'Body')
1919
@third_post = Post.new(id: 30, title: 'Yet Another Post', body: 'Body')
20-
@blog = Blog.new({ name: 'AMS Blog' })
20+
@blog = Blog.new(name: 'AMS Blog')
2121
@first_comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
2222
@second_comment = Comment.new(id: 2, body: 'ZOMG ANOTHER COMMENT')
2323
@first_post.blog = @blog

test/adapter/json_api/pagination_links_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class PaginationLinksTest < ActiveSupport::TestCase
1313
def setup
1414
ActionController::Base.cache_store.clear
1515
@array = [
16-
Profile.new({ id: 1, name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }),
17-
Profile.new({ id: 2, name: 'Name 2', description: 'Description 2', comments: 'Comments 2' }),
18-
Profile.new({ id: 3, name: 'Name 3', description: 'Description 3', comments: 'Comments 3' }),
19-
Profile.new({ id: 4, name: 'Name 4', description: 'Description 4', comments: 'Comments 4' }),
20-
Profile.new({ id: 5, name: 'Name 5', description: 'Description 5', comments: 'Comments 5' })
16+
Profile.new(id: 1, name: 'Name 1', description: 'Description 1', comments: 'Comments 1'),
17+
Profile.new(id: 2, name: 'Name 2', description: 'Description 2', comments: 'Comments 2'),
18+
Profile.new(id: 3, name: 'Name 3', description: 'Description 3', comments: 'Comments 3'),
19+
Profile.new(id: 4, name: 'Name 4', description: 'Description 4', comments: 'Comments 4'),
20+
Profile.new(id: 5, name: 'Name 5', description: 'Description 5', comments: 'Comments 5')
2121
]
2222
end
2323

@@ -122,7 +122,7 @@ def test_pagination_links_using_will_paginate
122122
end
123123

124124
def test_pagination_links_with_additional_params
125-
adapter = load_adapter(using_will_paginate, mock_request({ test: 'test' }))
125+
adapter = load_adapter(using_will_paginate, mock_request(test: 'test'))
126126

127127
assert_equal expected_response_with_pagination_links_and_additional_params,
128128
adapter.serializable_hash

test/adapter/null_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ActiveModelSerializers
44
module Adapter
55
class NullTest < ActiveSupport::TestCase
66
def setup
7-
profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
7+
profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
88
serializer = ProfileSerializer.new(profile)
99

1010
@adapter = Null.new(serializer)

test/adapter_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_create_adapter
5151
end
5252

5353
def test_create_adapter_with_override
54-
adapter = ActiveModelSerializers::Adapter.create(@serializer, { adapter: :json_api })
54+
adapter = ActiveModelSerializers::Adapter.create(@serializer, adapter: :json_api)
5555
assert_equal ActiveModelSerializers::Adapter::JsonApi, adapter.class
5656
end
5757

test/collection_serializer_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111
@comment = Comment.new
1212
@post = Post.new
1313
@resource = build_named_collection @comment, @post
14-
@serializer = collection_serializer.new(@resource, { some: :options })
14+
@serializer = collection_serializer.new(@resource, some: :options)
1515
end
1616

1717
def collection_serializer
@@ -44,7 +44,7 @@ def test_each_object_should_be_serialized_with_appropriate_serializer
4444
end
4545

4646
def test_serializer_option_not_passed_to_each_serializer
47-
serializers = collection_serializer.new([@post], { serializer: PostSerializer }).to_a
47+
serializers = collection_serializer.new([@post], serializer: PostSerializer).to_a
4848

4949
refute serializers.first.custom_options.key?(:serializer)
5050
end

test/serializable_resource_test.rb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module ActiveModelSerializers
44
class SerializableResourceTest < ActiveSupport::TestCase
55
def setup
6-
@resource = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
6+
@resource = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
77
@serializer = ProfileSerializer.new(@resource)
88
@adapter = ActiveModelSerializers::Adapter.create(@serializer)
99
@serializable_resource = SerializableResource.new(@resource)
@@ -32,11 +32,11 @@ def test_serializable_resource_delegates_as_json_to_the_adapter
3232
end
3333

3434
def test_use_adapter_with_adapter_option
35-
assert SerializableResource.new(@resource, { adapter: 'json' }).use_adapter?
35+
assert SerializableResource.new(@resource, adapter: 'json').use_adapter?
3636
end
3737

3838
def test_use_adapter_with_adapter_option_as_false
39-
refute SerializableResource.new(@resource, { adapter: false }).use_adapter?
39+
refute SerializableResource.new(@resource, adapter: false).use_adapter?
4040
end
4141

4242
class SerializableResourceErrorsTest < Minitest::Test
@@ -45,10 +45,8 @@ def test_serializable_resource_with_errors
4545
resource = ModelWithErrors.new
4646
resource.errors.add(:name, 'must be awesome')
4747
serializable_resource = ActiveModelSerializers::SerializableResource.new(
48-
resource, {
49-
serializer: ActiveModel::Serializer::ErrorSerializer,
50-
adapter: :json_api
51-
}
48+
resource, serializer: ActiveModel::Serializer::ErrorSerializer,
49+
adapter: :json_api
5250
)
5351
expected_response_document = {
5452
errors: [
@@ -65,11 +63,9 @@ def test_serializable_resource_with_collection_containing_errors
6563
resource.errors.add(:title, 'must be amazing')
6664
resources << ModelWithErrors.new
6765
serializable_resource = SerializableResource.new(
68-
resources, {
69-
serializer: ActiveModel::Serializer::ErrorsSerializer,
70-
each_serializer: ActiveModel::Serializer::ErrorSerializer,
71-
adapter: :json_api
72-
}
66+
resources, serializer: ActiveModel::Serializer::ErrorsSerializer,
67+
each_serializer: ActiveModel::Serializer::ErrorSerializer,
68+
adapter: :json_api
7369
)
7470
expected_response_document = {
7571
errors: [

test/serializers/associations_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ def setup
77
@author = Author.new(name: 'Steve K.')
88
@author.bio = nil
99
@author.roles = []
10-
@blog = Blog.new({ name: 'AMS Blog' })
11-
@post = Post.new({ title: 'New Post', body: 'Body' })
12-
@tag = Tag.new({ name: '#hashtagged' })
13-
@comment = Comment.new({ id: 1, body: 'ZOMG A COMMENT' })
10+
@blog = Blog.new(name: 'AMS Blog')
11+
@post = Post.new(title: 'New Post', body: 'Body')
12+
@tag = Tag.new(name: '#hashtagged')
13+
@comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
1414
@post.comments = [@comment]
1515
@post.tags = [@tag]
1616
@post.blog = @blog
@@ -19,7 +19,7 @@ def setup
1919
@post.author = @author
2020
@author.posts = [@post]
2121

22-
@post_serializer = PostSerializer.new(@post, { custom_options: true })
22+
@post_serializer = PostSerializer.new(@post, custom_options: true)
2323
@author_serializer = AuthorSerializer.new(@author)
2424
@comment_serializer = CommentSerializer.new(@comment)
2525
end

0 commit comments

Comments
 (0)