rubocop-airbnb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +2 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +68 -0
  6. data/config/default.yml +39 -0
  7. data/config/rubocop-airbnb.yml +96 -0
  8. data/config/rubocop-bundler.yml +8 -0
  9. data/config/rubocop-gemspec.yml +9 -0
  10. data/config/rubocop-layout.yml +514 -0
  11. data/config/rubocop-lint.yml +315 -0
  12. data/config/rubocop-metrics.yml +47 -0
  13. data/config/rubocop-naming.yml +68 -0
  14. data/config/rubocop-performance.yml +143 -0
  15. data/config/rubocop-rails.yml +193 -0
  16. data/config/rubocop-rspec.yml +281 -0
  17. data/config/rubocop-security.yml +13 -0
  18. data/config/rubocop-style.yml +953 -0
  19. data/lib/rubocop-airbnb.rb +11 -0
  20. data/lib/rubocop/airbnb.rb +16 -0
  21. data/lib/rubocop/airbnb/inflections.rb +14 -0
  22. data/lib/rubocop/airbnb/inject.rb +20 -0
  23. data/lib/rubocop/airbnb/rails_autoloading.rb +55 -0
  24. data/lib/rubocop/airbnb/version.rb +8 -0
  25. data/lib/rubocop/cop/airbnb/class_name.rb +47 -0
  26. data/lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb +138 -0
  27. data/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb +74 -0
  28. data/lib/rubocop/cop/airbnb/continuation_slash.rb +25 -0
  29. data/lib/rubocop/cop/airbnb/default_scope.rb +20 -0
  30. data/lib/rubocop/cop/airbnb/factory_attr_references_class.rb +74 -0
  31. data/lib/rubocop/cop/airbnb/factory_class_use_string.rb +39 -0
  32. data/lib/rubocop/cop/airbnb/mass_assignment_accessible_modifier.rb +18 -0
  33. data/lib/rubocop/cop/airbnb/module_method_in_wrong_file.rb +104 -0
  34. data/lib/rubocop/cop/airbnb/no_timeout.rb +19 -0
  35. data/lib/rubocop/cop/airbnb/opt_arg_parameters.rb +38 -0
  36. data/lib/rubocop/cop/airbnb/phrase_bundle_keys.rb +67 -0
  37. data/lib/rubocop/cop/airbnb/risky_activerecord_invocation.rb +63 -0
  38. data/lib/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace.rb +114 -0
  39. data/lib/rubocop/cop/airbnb/rspec_environment_modification.rb +58 -0
  40. data/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb +23 -0
  41. data/lib/rubocop/cop/airbnb/spec_constant_assignment.rb +55 -0
  42. data/lib/rubocop/cop/airbnb/unsafe_yaml_marshal.rb +47 -0
  43. data/rubocop-airbnb.gemspec +32 -0
  44. data/spec/rubocop/cop/airbnb/class_name_spec.rb +78 -0
  45. data/spec/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file_spec.rb +174 -0
  46. data/spec/rubocop/cop/airbnb/const_assigned_in_wrong_file_spec.rb +178 -0
  47. data/spec/rubocop/cop/airbnb/continuation_slash_spec.rb +162 -0
  48. data/spec/rubocop/cop/airbnb/default_scope_spec.rb +38 -0
  49. data/spec/rubocop/cop/airbnb/factory_attr_references_class_spec.rb +160 -0
  50. data/spec/rubocop/cop/airbnb/factory_class_use_string_spec.rb +26 -0
  51. data/spec/rubocop/cop/airbnb/mass_assignment_accessible_modifier_spec.rb +28 -0
  52. data/spec/rubocop/cop/airbnb/module_method_in_wrong_file_spec.rb +181 -0
  53. data/spec/rubocop/cop/airbnb/no_timeout_spec.rb +30 -0
  54. data/spec/rubocop/cop/airbnb/opt_arg_parameter_spec.rb +103 -0
  55. data/spec/rubocop/cop/airbnb/phrase_bundle_keys_spec.rb +74 -0
  56. data/spec/rubocop/cop/airbnb/risky_activerecord_invocation_spec.rb +54 -0
  57. data/spec/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace_spec.rb +284 -0
  58. data/spec/rubocop/cop/airbnb/rspec_environment_modification_spec.rb +64 -0
  59. data/spec/rubocop/cop/airbnb/simple_modifier_conditional_spec.rb +122 -0
  60. data/spec/rubocop/cop/airbnb/spec_constant_assignment_spec.rb +80 -0
  61. data/spec/rubocop/cop/airbnb/unsafe_yaml_marshal_spec.rb +50 -0
  62. data/spec/spec_helper.rb +35 -0
  63. metadata +150 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e606bf47c06053d42acc1100abc09b8984b80ebf
4
+ data.tar.gz: 03d2d05b1ec2d6e656b59e697618c8f020afbc92
5
+ SHA512:
6
+ metadata.gz: a14424158bccca0d2506cedd884b77eeeaafa72680393948455859af6ba0b577278cba32beaa185e9bf6edfb8b0286706d9325fa9a4a54d7058049266a509c7f
7
+ data.tar.gz: f208056c32bc043c4ba9c8f446a83ee24e4b4a0aa1c62193f56ac86df6a96d8724a124f6b359a629bf649c1cb273c2d0367f03fe26c3bb7eed2fb987aac168bb
@@ -0,0 +1,2 @@
1
+ # 1.0.0
2
+ * First public release of rubocop-airbnb
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'pry'
7
+ end
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2012 Airbnb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # RuboCop Airbnb
2
+
3
+ Airbnb specific analysis for [RuboCop](https://github.com/bbatsov/rubocop).
4
+
5
+ It contains Airbnb's internally used configuration for
6
+ [RuboCop](https://github.com/bbatsov/rubocop) and
7
+ [RuboCop RSpec](https://github.com/backus/rubocop-rspec). It also includes a handful custom rules
8
+ that are not currently addressed by other projects.
9
+
10
+ ## Installation
11
+
12
+ Just put this in your `Gemfile` it depends on the appropriate version of rubocop and rubocop-rspec.
13
+
14
+ ```
15
+ gem 'rubocop-airbnb'
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ You need to tell RuboCop to load the Airbnb extension. There are three
21
+ ways to do this:
22
+
23
+ ### RuboCop configuration file
24
+ First Create a new file `.rubocop_airbnb.yml` in the same directory as your `.rubocop.yml`
25
+ this file should contain
26
+ ```
27
+ require:
28
+ - rubocop-airbnb
29
+ ```
30
+
31
+ Next add the following to `.rubocop.yml`
32
+ or add before `.rubocop_todo.yml` in your existin `inherit_from`
33
+
34
+ ```
35
+ inherit_from:
36
+ - .rubocop_airbnb.yml
37
+ - .rubocop_todo.yml
38
+ ```
39
+
40
+ You need to inherit `.rubocop_airbnb.yml` from another file becuase Rubocop order of operations.
41
+ It runs `inherit_from` before `require` commands. If the configuration is not in a separate file
42
+ you could potentially experience a bunch of warnings from `.rubocop_todo.yml` for non-existant
43
+ `Airbnb` rules.
44
+
45
+ Now you can run `rubocop` and it will automatically load the RuboCop Airbnb
46
+ cops together with the standard cops.
47
+
48
+ ### Command line
49
+
50
+ ```bash
51
+ rubocop --require rubocop-airbnb
52
+ ```
53
+
54
+ ## The Cops
55
+
56
+ All cops are located under
57
+ [`lib/rubocop/cop/airbnb`](lib/rubocop/cop/airbnb), and contain
58
+ examples/documentation.
59
+
60
+ In your `.rubocop.yml`, you may treat the Airbnb cops just like any other
61
+ cop. For example:
62
+
63
+ ```yaml
64
+ Airbnb/PhraseBundleKeys:
65
+ Exclude:
66
+ - spec/my_poorly_named_spec_file.rb
67
+ ```
68
+
@@ -0,0 +1,39 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ ##############
5
+ # Global rules
6
+
7
+ AllCops:
8
+ Exclude:
9
+ - '.chefrepo/**/*'
10
+ - '.vagrant/**/*'
11
+ - '.git/**/*'
12
+ - 'node_modules/**/*'
13
+ - 'tungsten/**/*'
14
+ - 'tungsten-support/**/*'
15
+ - 'vendor/**/*'
16
+ - Vagrantfile
17
+ - Guardfile
18
+ RSpec:
19
+ Patterns:
20
+ - _spec.rb
21
+ - "(?:^|/)spec/"
22
+ RSpec/FactoryBot:
23
+ Patterns:
24
+ - spec/factories/**/*.rb
25
+ - features/support/factories/**/*.rb
26
+
27
+ inherit_from:
28
+ - './rubocop-airbnb.yml'
29
+ - './rubocop-bundler.yml'
30
+ - './rubocop-gemspec.yml'
31
+ - './rubocop-layout.yml'
32
+ - './rubocop-lint.yml'
33
+ - './rubocop-metrics.yml'
34
+ - './rubocop-naming.yml'
35
+ - './rubocop-performance.yml'
36
+ - './rubocop-rails.yml'
37
+ - './rubocop-rspec.yml'
38
+ - './rubocop-security.yml'
39
+ - './rubocop-style.yml'
@@ -0,0 +1,96 @@
1
+ # All of these rules are implemented in this gem.
2
+ # They are custom built for use inside Airbnb and address issues that we have experienced in
3
+ # testing and production.
4
+
5
+ Airbnb/ClassName:
6
+ Description: Use :class_name => "Model" instead of :class_name => Model.name
7
+ to avoid a long cascade of autoloading.
8
+ Enabled: true
9
+
10
+ Airbnb/ClassOrModuleDeclaredInWrongFile:
11
+ Description: Declare a class or module in the file that matches its namespace and name.
12
+ Enabled: true
13
+ Include:
14
+ - 'app/**/*'
15
+ - 'lib/**/*'
16
+
17
+ Airbnb/ConstAssignedInWrongFile:
18
+ Description: Assign a const in a file that matches the namespace in which it is scoped.
19
+ Enabled: true
20
+ Include:
21
+ - 'app/**/*'
22
+ - 'lib/**/*'
23
+
24
+ Airbnb/ContinuationSlash:
25
+ Description: Slash continuation should be reserved for string continatuion. Many times it is
26
+ used to get around other existing rules.
27
+ Enabled: true
28
+
29
+ Airbnb/DefaultScope:
30
+ Description: Avoid `default_scope`. Default scopes make it difficult to
31
+ refactor data access patterns since the scope becomes part of every query unless
32
+ explicitly excluded, even when it is unnecessary or incidental to the desired logic.
33
+ Enabled: true
34
+
35
+ Airbnb/FactoryAttrReferencesClass:
36
+ Description: Cop to enforce "attr { CONST }" instead of "attr CONST" in factories,
37
+ because the latter forces autoload, which slows down spec startup time and
38
+ Zeus reload time after touching a model.
39
+ Enabled: true
40
+
41
+ Airbnb/FactoryClassUseString:
42
+ Description: Cop to tell developers to use :class => "MyClass" instead of :class => MyClass,
43
+ because the latter slows down reloading zeus.
44
+ Enabled: true
45
+
46
+ Airbnb/MassAssignmentAccessibleModifier:
47
+ Description: Do no override and objects mass assignment restrictions.
48
+ Enabled: true
49
+
50
+ Airbnb/ModuleMethodInWrongFile:
51
+ Description: Define a module method in the file that defines the module, not a file that
52
+ happens to use the module as a namespace.
53
+ Enabled: true
54
+ Include:
55
+ - 'app/**/*'
56
+ - 'lib/**/*'
57
+
58
+ Airbnb/NoTimeout:
59
+ Description: Do not use Timeout.timeout. In combination with Rails autoloading,
60
+ timeout can cause Segmentation Faults in version of Ruby we use.
61
+ It can also cause logic errors since it can raise in
62
+ any callee scope. Use client library timeouts and monitoring to
63
+ ensure proper timing behavior for web requests.
64
+ Enabled: true
65
+
66
+ Airbnb/OptArgParameters:
67
+ Description: Do not use default arguments. Use an options hash instead.
68
+ Enabled: true
69
+ StyleGuide: https://github.com/airbnb/ruby#no-default-args
70
+
71
+ Airbnb/PhraseBundleKeys:
72
+ Description: Checks for phrase bundle keys that do not match their respective translation keys.
73
+ Enabled: true
74
+
75
+ Airbnb/RiskyActiverecordInvocation:
76
+ Description: Disallow ActiveRecord calls that use interpolated or added strings as arguments.
77
+ Enabled: true
78
+
79
+ Airbnb/RspecEnvironmentModification:
80
+ Description: Disallow Rails.env from being stubbed in half measure ways or from being reassigned
81
+ Use `stub_env` instead.
82
+ Enabled: true
83
+
84
+ Airbnb/SimpleModifierConditional:
85
+ Enabled: true
86
+ StyleGuide: https://github.com/airbnb/ruby#only-simple-if-unless
87
+
88
+ Airbnb/SpecConstantAssignment:
89
+ Description: Constant assignment in specs polute global namespace and are a cause of spurious
90
+ specs. They should be avoided. Also modifing existing constants is bad too, use stub_const
91
+ instead
92
+ Enabled: true
93
+
94
+ Airbnb/UnsafeYamlMarshal:
95
+ Description: Avoid use of YAML/Marshal methods that can trigger RCE on untrusted input.
96
+ Enabled: true
@@ -0,0 +1,8 @@
1
+ Bundler/DuplicatedGem:
2
+ Enabled: true
3
+
4
+ Bundler/InsecureProtocolSource:
5
+ Enabled: false
6
+
7
+ Bundler/OrderedGems:
8
+ Enabled: false
@@ -0,0 +1,9 @@
1
+ Gemspec/OrderedDependencies:
2
+ Enabled: false
3
+
4
+ Gemspec/RequiredRubyVersion:
5
+ Description: Checks that `required_ruby_version` of gemspec and `TargetRubyVersion` of
6
+ .rubocop.yml are equal.
7
+ Enabled: false
8
+ Include:
9
+ - '**/*.gemspec'
@@ -0,0 +1,514 @@
1
+ # Type 'Style' (166):
2
+ # Supports --auto-correct
3
+ Layout/AccessModifierIndentation:
4
+ Description: Check indentation of private/protected visibility modifiers.
5
+ # Airbnb: https://github.com/airbnb/ruby#access-modifiers
6
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
7
+ Enabled: true
8
+ EnforcedStyle: indent
9
+ SupportedStyles:
10
+ - outdent
11
+ - indent
12
+
13
+ # Supports --auto-correct
14
+ Layout/AlignArray:
15
+ Description: Align the elements of an array literal if they span more than one line.
16
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays
17
+ Enabled: true
18
+
19
+ # Supports --auto-correct
20
+ Layout/AlignHash:
21
+ Description: Align the elements of a hash literal if they span more than one line.
22
+ Enabled: true
23
+ EnforcedHashRocketStyle: key
24
+ EnforcedColonStyle: key
25
+ EnforcedLastArgumentHashStyle: always_inspect
26
+ SupportedLastArgumentHashStyles:
27
+ - always_inspect
28
+ - always_ignore
29
+ - ignore_implicit
30
+ - ignore_explicit
31
+
32
+ # Supports --auto-correct
33
+ Layout/AlignParameters:
34
+ Description: Align the parameters of a method call if they span more than one line.
35
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-double-indent
36
+ Enabled: true
37
+ EnforcedStyle: with_first_parameter
38
+ SupportedStyles:
39
+ - with_first_parameter
40
+ - with_fixed_indentation
41
+
42
+ # Supports --auto-correct
43
+ Layout/BlockEndNewline:
44
+ Description: Put end statement of multiline block on its own line.
45
+ Enabled: true
46
+
47
+ # Supports --auto-correct
48
+ Layout/CaseIndentation:
49
+ Description: Indentation of when in a case/when/[else/]end.
50
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-when-to-case
51
+ Enabled: true
52
+ EnforcedStyle: case
53
+ IndentOneStep: false
54
+
55
+ Layout/ClassStructure:
56
+ Enabled: false
57
+ Categories:
58
+ module_inclusion:
59
+ - include
60
+ - prepend
61
+ - extend
62
+ ExpectedOrder:
63
+ - module_inclusion
64
+ - constants
65
+ - public_class_methods
66
+ - initializer
67
+ - instance_methods
68
+ - protected_methods
69
+ - private_methods
70
+
71
+ # Supports --auto-correct
72
+ Layout/ClosingParenthesisIndentation:
73
+ Description: Checks the indentation of hanging closing parentheses.
74
+ Enabled: true
75
+
76
+ # Supports --auto-correct
77
+ Layout/CommentIndentation:
78
+ Description: Indentation of comments.
79
+ Enabled: true
80
+
81
+ # Use trailing commas, because there are safer in ruby.
82
+ Layout/DotPosition:
83
+ Enabled: true
84
+ EnforcedStyle: trailing
85
+
86
+ # Supports --auto-correct
87
+ Layout/ElseAlignment:
88
+ Description: Align elses and elsifs correctly.
89
+ Enabled: true
90
+
91
+ Layout/EmptyLineAfterMagicComment:
92
+ Enabled: true
93
+
94
+ # Supports --auto-correct
95
+ Layout/EmptyLineBetweenDefs:
96
+ Description: Use empty lines between defs.
97
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods
98
+ Enabled: true
99
+ AllowAdjacentOneLineDefs: false
100
+
101
+ # Supports --auto-correct
102
+ Layout/EmptyLines:
103
+ Description: Don't use several empty lines in a row.
104
+ Enabled: true
105
+
106
+ # Supports --auto-correct
107
+ Layout/EmptyLinesAroundAccessModifier:
108
+ Description: Keep blank lines around access modifiers.
109
+ Enabled: true
110
+
111
+ Layout/EmptyLinesAroundArguments:
112
+ Description: "Keeps track of empty lines around method arguments."
113
+ Enabled: false
114
+
115
+ Layout/EmptyLinesAroundBeginBody:
116
+ Enabled: true
117
+
118
+ # Supports --auto-correct
119
+ Layout/EmptyLinesAroundBlockBody:
120
+ Description: Keeps track of empty lines around block bodies.
121
+ Enabled: true
122
+ EnforcedStyle: no_empty_lines
123
+ SupportedStyles:
124
+ - empty_lines
125
+ - no_empty_lines
126
+
127
+ # Supports --auto-correct
128
+ Layout/EmptyLinesAroundClassBody:
129
+ Description: Keeps track of empty lines around class bodies.
130
+ Enabled: true
131
+ EnforcedStyle: no_empty_lines
132
+ SupportedStyles:
133
+ - empty_lines
134
+ - no_empty_lines
135
+
136
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
137
+ Enabled: false
138
+
139
+ # Supports --auto-correct
140
+ Layout/EmptyLinesAroundMethodBody:
141
+ Description: Keeps track of empty lines around method bodies.
142
+ Enabled: true
143
+
144
+ # Supports --auto-correct
145
+ Layout/EmptyLinesAroundModuleBody:
146
+ Description: Keeps track of empty lines around module bodies.
147
+ Enabled: true
148
+ EnforcedStyle: no_empty_lines
149
+ SupportedStyles:
150
+ - empty_lines
151
+ - no_empty_lines
152
+
153
+ Layout/EndOfLine:
154
+ Description: Use Unix-style line endings.
155
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#crlf
156
+ Enabled: false
157
+
158
+ # Supports --auto-correct
159
+ Layout/ExtraSpacing:
160
+ Description: Do not use unnecessary spacing.
161
+ Enabled: true
162
+ AllowForAlignment: true
163
+
164
+ # Supports --auto-correct
165
+ Layout/FirstArrayElementLineBreak:
166
+ Description: Checks for a line break before the first element in a multi-line array.
167
+ Enabled: true
168
+
169
+ # Supports --auto-correct
170
+ Layout/FirstHashElementLineBreak:
171
+ Description: Checks for a line break before the first element in a multi-line hash.
172
+ Enabled: true
173
+
174
+ # Supports --auto-correct
175
+ Layout/FirstMethodArgumentLineBreak:
176
+ Description: Checks for a line break before the first argument in a multi-line method
177
+ call.
178
+ Enabled: false
179
+
180
+ # Supports --auto-correct
181
+ Layout/FirstMethodParameterLineBreak:
182
+ Description: Checks for a line break before the first parameter in a multi-line method
183
+ parameter definition.
184
+ Enabled: false
185
+
186
+ # Supports --auto-correct
187
+ Layout/FirstParameterIndentation:
188
+ Description: Checks the indentation of the first parameter in a method call.
189
+ Enabled: true
190
+ EnforcedStyle: consistent
191
+ SupportedStyles:
192
+ - consistent
193
+ - special_for_inner_method_call
194
+ - special_for_inner_method_call_in_parentheses
195
+
196
+
197
+ # Supports --auto-correct
198
+ Layout/IndentArray:
199
+ Description: Checks the indentation of the first element in an array literal.
200
+ Enabled: true
201
+ EnforcedStyle: consistent
202
+
203
+ # Supports --auto-correct
204
+ Layout/IndentAssignment:
205
+ Description: Checks the indentation of the first line of the right-hand-side of a
206
+ multi-line assignment.
207
+ Enabled: true
208
+ IndentationWidth:
209
+
210
+ # Supports --auto-correct
211
+ Layout/IndentHash:
212
+ Description: Checks the indentation of the first key in a hash literal.
213
+ Enabled: true
214
+ EnforcedStyle: consistent
215
+ SupportedStyles:
216
+ - special_inside_parentheses
217
+ - consistent
218
+
219
+ Layout/IndentHeredoc:
220
+ Enabled: false
221
+
222
+ # Supports --auto-correct
223
+ Layout/IndentationConsistency:
224
+ Description: Keep indentation straight.
225
+ Enabled: true
226
+ EnforcedStyle: normal
227
+ SupportedStyles:
228
+ - normal
229
+ - rails
230
+
231
+ # Supports --auto-correct
232
+ Layout/IndentationWidth:
233
+ Description: Use 2 spaces for indentation.
234
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
235
+ Enabled: true
236
+ Width: 2
237
+
238
+ # Supports --auto-correct
239
+ Layout/InitialIndentation:
240
+ Description: Checks the indentation of the first non-blank non-comment line in a file.
241
+ Enabled: true
242
+
243
+ # Supports --auto-correct
244
+ Layout/LeadingCommentSpace:
245
+ Description: Comments should start with a space.
246
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-space
247
+ Enabled: true
248
+
249
+ # Supports --auto-correct
250
+ Layout/MultilineArrayBraceLayout:
251
+ Description: Checks that the closing brace in an array literal is symmetrical with
252
+ respect to the opening brace and the array elements.
253
+ Enabled: true
254
+
255
+ # Supports --auto-correct
256
+ Layout/MultilineAssignmentLayout:
257
+ Description: Check for a newline after the assignment operator in multi-line assignments.
258
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-conditional-assignment
259
+ Enabled: false
260
+ SupportedTypes:
261
+ - block
262
+ - case
263
+ - class
264
+ - if
265
+ - kwbegin
266
+ - module
267
+ EnforcedStyle: new_line
268
+ SupportedStyles:
269
+ - same_line
270
+ - new_line
271
+
272
+ # Supports --auto-correct
273
+ Layout/MultilineBlockLayout:
274
+ Description: Ensures newlines after multiline block do statements.
275
+ Enabled: true
276
+
277
+ Layout/MultilineHashBraceLayout:
278
+ Description: >-
279
+ Checks that the closing brace in a hash literal is
280
+ symmetrical with respect to the opening brace and the
281
+ hash elements.
282
+ Enabled: true
283
+
284
+ Layout/MultilineMethodCallBraceLayout:
285
+ Description: >-
286
+ Checks that the closing brace in a method call is
287
+ symmetrical with respect to the opening brace and the
288
+ method arguments.
289
+ Enabled: true
290
+ EnforcedStyle: symmetrical
291
+
292
+ # Supports --auto-correct
293
+ Layout/MultilineMethodCallIndentation:
294
+ Description: Checks indentation of method calls with the dot operator that span more
295
+ than one line.
296
+ Enabled: true
297
+ EnforcedStyle: indented
298
+ SupportedStyles:
299
+ - aligned
300
+ - indented
301
+ IndentationWidth:
302
+
303
+ Layout/MultilineMethodDefinitionBraceLayout:
304
+ Description: >-
305
+ Checks that the closing brace in a method definition is
306
+ symmetrical with respect to the opening brace and the
307
+ method parametters.
308
+ Enabled: true
309
+
310
+ # The default (aligned) would force multi line operations to look like this
311
+ # balance = Balance.
312
+ # where(cond).
313
+ # where(cond).
314
+ # first
315
+ Layout/MultilineOperationIndentation:
316
+ Enabled: false
317
+ EnforcedStyle: indented
318
+
319
+ # Supports --auto-correct
320
+ Layout/RescueEnsureAlignment:
321
+ Description: Align rescues and ensures correctly.
322
+ Enabled: true
323
+
324
+ # Supports --auto-correct
325
+ Layout/SpaceAfterColon:
326
+ Description: Use spaces after colons.
327
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
328
+ Enabled: true
329
+
330
+ # Supports --auto-correct
331
+ Layout/SpaceAfterComma:
332
+ Description: Use spaces after commas.
333
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
334
+ Enabled: true
335
+
336
+ # Supports --auto-correct
337
+ Layout/SpaceAfterMethodName:
338
+ Description: Do not put a space between a method name and the opening parenthesis
339
+ in a method definition.
340
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-no-spaces
341
+ Enabled: true
342
+
343
+ # Supports --auto-correct
344
+ Layout/SpaceAfterNot:
345
+ Description: Tracks redundant space after the ! operator.
346
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-bang
347
+ Enabled: true
348
+
349
+ # Supports --auto-correct
350
+ Layout/SpaceAfterSemicolon:
351
+ Description: Use spaces after semicolons.
352
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
353
+ Enabled: true
354
+
355
+ # Supports --auto-correct
356
+ Layout/SpaceAroundBlockParameters:
357
+ Description: Checks the spacing inside and after block parameters pipes.
358
+ Enabled: true
359
+ EnforcedStyleInsidePipes: no_space
360
+
361
+ # Supports --auto-correct
362
+ Layout/SpaceAroundEqualsInParameterDefault:
363
+ Description: Checks that the equals signs in parameter default assignments have or
364
+ don't have surrounding space depending on configuration.
365
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-around-equals
366
+ Enabled: true
367
+ EnforcedStyle: space
368
+ SupportedStyles:
369
+ - space
370
+ - no_space
371
+
372
+ Layout/SpaceAroundKeyword:
373
+ Description: 'Use a space around keywords if appropriate.'
374
+ Enabled: true
375
+
376
+ # Supports --auto-correct
377
+ Layout/SpaceAroundOperators:
378
+ Description: Use a single space around operators.
379
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
380
+ Enabled: true
381
+ AllowForAlignment: true
382
+
383
+ # Supports --auto-correct
384
+ Layout/SpaceBeforeBlockBraces:
385
+ Description: Checks that the left block brace has or doesn't have space before it.
386
+ Enabled: true
387
+ EnforcedStyle: space
388
+ SupportedStyles:
389
+ - space
390
+ - no_space
391
+
392
+ # Supports --auto-correct
393
+ Layout/SpaceBeforeComma:
394
+ Description: No spaces before commas.
395
+ Enabled: true
396
+
397
+ # Supports --auto-correct
398
+ Layout/SpaceBeforeComment:
399
+ Description: Checks for missing space between code and a comment on the same line.
400
+ Enabled: true
401
+
402
+ # Supports --auto-correct
403
+ Layout/SpaceBeforeFirstArg:
404
+ Description: Put a space between a method name and the first argument in a method
405
+ call without parentheses.
406
+ Enabled: true
407
+
408
+ # Supports --auto-correct
409
+ Layout/SpaceBeforeSemicolon:
410
+ Description: No spaces before semicolons.
411
+ Enabled: true
412
+
413
+ Layout/SpaceInLambdaLiteral:
414
+ Enabled: false
415
+
416
+ Layout/SpaceInsideArrayPercentLiteral:
417
+ Enabled: false
418
+
419
+ # Supports --auto-correct
420
+ Layout/SpaceInsideBlockBraces:
421
+ Description: Checks that block braces have or don't have surrounding space. For blocks
422
+ taking parameters, checks that the left brace has or doesn't have trailing space.
423
+ Enabled: true
424
+ EnforcedStyle: space
425
+ SupportedStyles:
426
+ - space
427
+ - no_space
428
+ EnforcedStyleForEmptyBraces: no_space
429
+ SpaceBeforeBlockParameters: true
430
+
431
+ Layout/SpaceInsideParens:
432
+ Description: 'No spaces after ( or before ).'
433
+ StyleGuide: '#spaces-braces'
434
+ Enabled: true
435
+
436
+ Layout/SpaceInsideArrayLiteralBrackets:
437
+ EnforcedStyle: no_space
438
+ SupportedStyles:
439
+ - space
440
+ - no_space
441
+ # 'compact' normally requires a space inside the brackets, with the exception
442
+ # that successive left brackets or right brackets are collapsed together
443
+ - compact
444
+ EnforcedStyleForEmptyBrackets: no_space
445
+ SupportedStylesForEmptyBrackets:
446
+ - space
447
+ - no_space
448
+ Enabled: true
449
+
450
+ Layout/SpaceInsideReferenceBrackets:
451
+ EnforcedStyle: no_space
452
+ SupportedStyles:
453
+ - space
454
+ - no_space
455
+ Enabled: true
456
+
457
+ # Supports --auto-correct
458
+ Layout/SpaceInsideHashLiteralBraces:
459
+ Description: Use spaces inside hash literal braces - or don't.
460
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
461
+ Enabled: true
462
+ EnforcedStyle: space
463
+ EnforcedStyleForEmptyBraces: no_space
464
+ SupportedStyles:
465
+ - space
466
+ - no_space
467
+
468
+ # Supports --auto-correct
469
+ Layout/SpaceInsideParens:
470
+ Description: No spaces after ( or before ).
471
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-spaces-braces
472
+ Enabled: true
473
+
474
+ Layout/SpaceInsidePercentLiteralDelimiters:
475
+ Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
476
+ Enabled: true
477
+
478
+ # Supports --auto-correct
479
+ Layout/SpaceInsideRangeLiteral:
480
+ Description: No spaces inside range literals.
481
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-inside-range-literals
482
+ Enabled: true
483
+
484
+ # Supports --auto-correct
485
+ Layout/SpaceInsideStringInterpolation:
486
+ Description: Checks for padding/surrounding spaces inside string interpolation.
487
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#string-interpolation
488
+ Enabled: true
489
+ EnforcedStyle: no_space
490
+ SupportedStyles:
491
+ - space
492
+ - no_space
493
+
494
+ # Supports --auto-correct
495
+ Layout/Tab:
496
+ Description: No hard tabs.
497
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
498
+ Enabled: true
499
+
500
+ # Supports --auto-correct
501
+ Layout/TrailingBlankLines:
502
+ Description: Checks trailing blank lines and final newline.
503
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#newline-eof
504
+ Enabled: true
505
+ EnforcedStyle: final_newline
506
+ SupportedStyles:
507
+ - final_newline
508
+ - final_blank_line
509
+
510
+ # Supports --auto-correct
511
+ Layout/TrailingWhitespace:
512
+ Description: Avoid trailing whitespace.
513
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace
514
+ Enabled: true