Skip to content

Commit 024b2d5

Browse files
committed
re: RuboCop - replace rocket style hashes
1 parent 004f143 commit 024b2d5

19 files changed

+99
-108
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ Style/ClassAndModuleChildren:
4545

4646

4747

48-
# Offense count: 58
49-
# Cop supports --auto-correct.
50-
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
51-
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
52-
Style/HashSyntax:
53-
Enabled: false
54-
55-
5648
# Offense count: 3
5749
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
5850
# NamePrefix: is_, has_, have_

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ else
100100
end
101101

102102
desc 'CI test task'
103-
task :ci => [:default]
103+
task ci: [:default]

lib/active_model_serializers/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Railtie < Rails::Railtie
2323
# This hook is run after the action_controller railtie has set the configuration
2424
# based on the *environment* configuration and before any config/initializers are run
2525
# and also before eager_loading (if enabled).
26-
initializer 'active_model_serializers.set_configs', :after => 'action_controller.set_configs' do
26+
initializer 'active_model_serializers.set_configs', after: 'action_controller.set_configs' do
2727
ActiveModelSerializers.logger = Rails.configuration.action_controller.logger
2828
ActiveModelSerializers.config.perform_caching = Rails.configuration.action_controller.perform_caching
2929
# We want this hook to run after the config has been set, even if ActionController has already loaded.

lib/active_model_serializers/register_jsonapi_renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def self.install
5353
def self.parser
5454
lambda do |body|
5555
data = JSON.parse(body)
56-
data = { :_json => data } unless data.is_a?(Hash)
56+
data = { _json: data } unless data.is_a?(Hash)
5757
data.with_indifferent_access
5858
end
5959
end

lib/generators/rails/serializer_generator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ module Rails
22
module Generators
33
class SerializerGenerator < NamedBase
44
source_root File.expand_path('../templates', __FILE__)
5-
check_class_collision :suffix => 'Serializer'
5+
check_class_collision suffix: 'Serializer'
66

7-
argument :attributes, :type => :array, :default => [], :banner => 'field:type field:type'
7+
argument :attributes, type: :array, default: [], banner: 'field:type field:type'
88

9-
class_option :parent, :type => :string, :desc => 'The parent class for the generated serializer'
9+
class_option :parent, type: :string, desc: 'The parent class for the generated serializer'
1010

1111
def create_serializer_file
1212
template 'serializer.rb.erb', File.join('app/serializers', class_path, "#{file_name}_serializer.rb")

test/action_controller/json_api/errors_test.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ def test_active_model_with_multiple_errors
88
get :render_resource_with_errors
99

1010
expected_errors_object = {
11-
:errors =>
12-
[
13-
{ :source => { :pointer => '/data/attributes/name' }, :detail => 'cannot be nil' },
14-
{ :source => { :pointer => '/data/attributes/name' }, :detail => 'must be longer' },
15-
{ :source => { :pointer => '/data/attributes/id' }, :detail => 'must be a uuid' }
16-
]
11+
errors: [
12+
{ source: { pointer: '/data/attributes/name' }, detail: 'cannot be nil' },
13+
{ source: { pointer: '/data/attributes/name' }, detail: 'must be longer' },
14+
{ source: { pointer: '/data/attributes/id' }, detail: 'must be a uuid' }
15+
]
1716
}.to_json
1817
assert_equal json_reponse_body.to_json, expected_errors_object
1918
end

test/action_controller/json_api/linked_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def render_collection_with_include
8787
setup do
8888
@routes = Rails.application.routes.draw do
8989
ActiveSupport::Deprecation.silence do
90-
match ':action', :to => LinkedTestController, via: [:get, :post]
90+
match ':action', to: LinkedTestController, via: [:get, :post]
9191
end
9292
end
9393
end

test/active_model_serializers/key_transform_test.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ def test_camel
55
obj = Object.new
66
scenarios = [
77
{
8-
value: { :"some-key" => 'value' },
9-
expected: { :SomeKey => 'value' }
8+
value: { "some-key": 'value' },
9+
expected: { SomeKey: 'value' }
1010
},
1111
{
12-
value: { :someKey => 'value' },
13-
expected: { :SomeKey => 'value' }
12+
value: { someKey: 'value' },
13+
expected: { SomeKey: 'value' }
1414
},
1515
{
16-
value: { :some_key => 'value' },
17-
expected: { :SomeKey => 'value' }
16+
value: { some_key: 'value' },
17+
expected: { SomeKey: 'value' }
1818
},
1919
{
2020
value: { 'some-key' => 'value' },
@@ -71,16 +71,16 @@ def test_camel_lower
7171
obj = Object.new
7272
scenarios = [
7373
{
74-
value: { :"some-key" => 'value' },
75-
expected: { :someKey => 'value' }
74+
value: { "some-key": 'value' },
75+
expected: { someKey: 'value' }
7676
},
7777
{
78-
value: { :SomeKey => 'value' },
79-
expected: { :someKey => 'value' }
78+
value: { SomeKey: 'value' },
79+
expected: { someKey: 'value' }
8080
},
8181
{
82-
value: { :some_key => 'value' },
83-
expected: { :someKey => 'value' }
82+
value: { some_key: 'value' },
83+
expected: { someKey: 'value' }
8484
},
8585
{
8686
value: { 'some-key' => 'value' },
@@ -137,24 +137,24 @@ def test_dash
137137
obj = Object.new
138138
scenarios = [
139139
{
140-
value: { :some_key => 'value' },
141-
expected: { :"some-key" => 'value' }
140+
value: { some_key: 'value' },
141+
expected: { "some-key": 'value' }
142142
},
143143
{
144144
value: { 'some_key' => 'value' },
145145
expected: { 'some-key' => 'value' }
146146
},
147147
{
148-
value: { :SomeKey => 'value' },
149-
expected: { :"some-key" => 'value' }
148+
value: { SomeKey: 'value' },
149+
expected: { "some-key": 'value' }
150150
},
151151
{
152152
value: { 'SomeKey' => 'value' },
153153
expected: { 'some-key' => 'value' }
154154
},
155155
{
156-
value: { :someKey => 'value' },
157-
expected: { :"some-key" => 'value' }
156+
value: { someKey: 'value' },
157+
expected: { "some-key": 'value' }
158158
},
159159
{
160160
value: { 'someKey' => 'value' },
@@ -199,24 +199,24 @@ def test_underscore
199199
obj = Object.new
200200
scenarios = [
201201
{
202-
value: { :"some-key" => 'value' },
203-
expected: { :some_key => 'value' }
202+
value: { "some-key": 'value' },
203+
expected: { some_key: 'value' }
204204
},
205205
{
206206
value: { 'some-key' => 'value' },
207207
expected: { 'some_key' => 'value' }
208208
},
209209
{
210-
value: { :SomeKey => 'value' },
211-
expected: { :some_key => 'value' }
210+
value: { SomeKey: 'value' },
211+
expected: { some_key: 'value' }
212212
},
213213
{
214214
value: { 'SomeKey' => 'value' },
215215
expected: { 'some_key' => 'value' }
216216
},
217217
{
218-
value: { :someKey => 'value' },
219-
expected: { :some_key => 'value' }
218+
value: { someKey: 'value' },
219+
expected: { some_key: 'value' }
220220
},
221221
{
222222
value: { 'someKey' => 'value' },

test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class WithoutRenderer < JsonApiRendererTest
4444

4545
Rails.application.routes.draw do
4646
ActiveSupport::Deprecation.silence do
47-
match ':action', :to => TestController, via: [:get, :post]
47+
match ':action', to: TestController, via: [:get, :post]
4848
end
4949
end
5050
end
@@ -95,7 +95,7 @@ class WithRenderer < JsonApiRendererTest
9595

9696
Rails.application.routes.draw do
9797
ActiveSupport::Deprecation.silence do
98-
match ':action', :to => TestController, via: [:get, :post]
98+
match ':action', to: TestController, via: [:get, :post]
9999
end
100100
end
101101
end

test/adapter/json/transform_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_transform_undefined
6363
def test_transform_dash
6464
mock_request(:dash)
6565
assert_equal({
66-
blog: { id: 1, :"special-attribute" => 'neat', articles: nil }
66+
blog: { id: 1, "special-attribute": 'neat', articles: nil }
6767
}, @adapter.serializable_hash)
6868
end
6969

0 commit comments

Comments
 (0)