rubocop 0.24.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +12 -8
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +42 -0
  5. data/Gemfile +2 -0
  6. data/README.md +27 -6
  7. data/bin/rubocop +10 -15
  8. data/config/default.yml +72 -25
  9. data/config/enabled.yml +57 -25
  10. data/lib/rubocop.rb +15 -8
  11. data/lib/rubocop/config_loader.rb +11 -7
  12. data/lib/rubocop/cop/cop.rb +16 -16
  13. data/lib/rubocop/cop/ignored_node.rb +11 -4
  14. data/lib/rubocop/cop/lint/block_alignment.rb +29 -4
  15. data/lib/rubocop/cop/lint/debugger.rb +8 -1
  16. data/lib/rubocop/cop/lint/def_end_alignment.rb +5 -1
  17. data/lib/rubocop/cop/lint/end_alignment.rb +5 -5
  18. data/lib/rubocop/cop/lint/end_in_method.rb +2 -2
  19. data/lib/rubocop/cop/lint/useless_setter_call.rb +2 -2
  20. data/lib/rubocop/cop/{style → metrics}/block_nesting.rb +1 -1
  21. data/lib/rubocop/cop/{style → metrics}/class_length.rb +4 -4
  22. data/lib/rubocop/cop/{style → metrics}/cyclomatic_complexity.rb +5 -16
  23. data/lib/rubocop/cop/{style → metrics}/line_length.rb +1 -1
  24. data/lib/rubocop/cop/{style → metrics}/method_length.rb +8 -4
  25. data/lib/rubocop/cop/{style → metrics}/parameter_lists.rb +1 -1
  26. data/lib/rubocop/cop/metrics/perceived_complexity.rb +61 -0
  27. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +10 -2
  28. data/lib/rubocop/cop/mixin/code_length.rb +2 -3
  29. data/lib/rubocop/cop/mixin/configurable_naming.rb +6 -20
  30. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  31. data/lib/rubocop/cop/mixin/if_node.rb +1 -1
  32. data/lib/rubocop/cop/mixin/method_complexity.rb +32 -0
  33. data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
  34. data/lib/rubocop/cop/mixin/{check_methods.rb → on_method.rb} +3 -3
  35. data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +24 -0
  36. data/lib/rubocop/cop/mixin/percent_literal.rb +2 -1
  37. data/lib/rubocop/cop/mixin/space_inside.rb +33 -4
  38. data/lib/rubocop/cop/mixin/statement_modifier.rb +14 -14
  39. data/lib/rubocop/cop/mixin/string_help.rb +4 -0
  40. data/lib/rubocop/cop/mixin/surrounding_space.rb +1 -0
  41. data/lib/rubocop/cop/rails/delegate.rb +2 -2
  42. data/lib/rubocop/cop/rails/output.rb +4 -2
  43. data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
  44. data/lib/rubocop/cop/style/align_hash.rb +9 -1
  45. data/lib/rubocop/cop/style/and_or.rb +37 -3
  46. data/lib/rubocop/cop/style/bare_percent_literals.rb +46 -0
  47. data/lib/rubocop/cop/style/block_end_newline.rb +56 -0
  48. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  49. data/lib/rubocop/cop/style/def_with_parentheses.rb +2 -2
  50. data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +31 -3
  51. data/lib/rubocop/cop/style/empty_lines_around_body.rb +6 -2
  52. data/lib/rubocop/cop/style/end_of_line.rb +3 -14
  53. data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -6
  54. data/lib/rubocop/cop/style/if_with_semicolon.rb +6 -7
  55. data/lib/rubocop/cop/style/indentation_width.rb +3 -8
  56. data/lib/rubocop/cop/style/method_def_parentheses.rb +2 -2
  57. data/lib/rubocop/cop/style/method_name.rb +4 -18
  58. data/lib/rubocop/cop/style/multiline_block_layout.rb +73 -0
  59. data/lib/rubocop/cop/style/multiline_if_then.rb +4 -4
  60. data/lib/rubocop/cop/style/negated_if.rb +1 -1
  61. data/lib/rubocop/cop/style/negated_while.rb +2 -2
  62. data/lib/rubocop/cop/style/next.rb +12 -0
  63. data/lib/rubocop/cop/style/one_line_conditional.rb +6 -6
  64. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +22 -8
  65. data/lib/rubocop/cop/style/percent_q_literals.rb +53 -0
  66. data/lib/rubocop/cop/style/predicate_name.rb +2 -2
  67. data/lib/rubocop/cop/style/redundant_begin.rb +2 -2
  68. data/lib/rubocop/cop/style/redundant_return.rb +2 -2
  69. data/lib/rubocop/cop/style/rescue_modifier.rb +7 -3
  70. data/lib/rubocop/cop/style/single_line_methods.rb +2 -2
  71. data/lib/rubocop/cop/style/space_after_method_name.rb +2 -2
  72. data/lib/rubocop/cop/style/space_inside_block_braces.rb +14 -10
  73. data/lib/rubocop/cop/style/space_inside_brackets.rb +5 -1
  74. data/lib/rubocop/cop/style/string_literals.rb +5 -8
  75. data/lib/rubocop/cop/style/trailing_comma.rb +15 -3
  76. data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
  77. data/lib/rubocop/cop/style/unneeded_capital_w.rb +2 -4
  78. data/lib/rubocop/cop/style/unneeded_percent_q.rb +13 -0
  79. data/lib/rubocop/cop/style/variable_interpolation.rb +14 -2
  80. data/lib/rubocop/cop/style/variable_name.rb +17 -17
  81. data/lib/rubocop/cop/style/while_until_modifier.rb +2 -5
  82. data/lib/rubocop/cop/util.rb +5 -0
  83. data/lib/rubocop/cop/variable_force.rb +7 -6
  84. data/lib/rubocop/formatter/base_formatter.rb +2 -2
  85. data/lib/rubocop/processed_source.rb +5 -22
  86. data/lib/rubocop/version.rb +1 -1
  87. data/relnotes/v0.25.0.md +91 -0
  88. data/rubocop.gemspec +2 -3
  89. data/spec/project_spec.rb +1 -1
  90. data/spec/rubocop/cli_spec.rb +70 -44
  91. data/spec/rubocop/comment_config_spec.rb +6 -6
  92. data/spec/rubocop/config_loader_spec.rb +19 -13
  93. data/spec/rubocop/config_spec.rb +3 -3
  94. data/spec/rubocop/cop/commissioner_spec.rb +1 -1
  95. data/spec/rubocop/cop/cop_spec.rb +3 -3
  96. data/spec/rubocop/cop/lint/block_alignment_spec.rb +113 -6
  97. data/spec/rubocop/cop/lint/debugger_spec.rb +10 -6
  98. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +12 -0
  99. data/spec/rubocop/cop/{style → metrics}/block_nesting_spec.rb +1 -1
  100. data/spec/rubocop/cop/{style → metrics}/class_length_spec.rb +1 -1
  101. data/spec/rubocop/cop/{style → metrics}/cyclomatic_complexity_spec.rb +1 -1
  102. data/spec/rubocop/cop/{style → metrics}/if_unless_modifier_spec.rb +2 -2
  103. data/spec/rubocop/cop/{style → metrics}/line_length_spec.rb +7 -7
  104. data/spec/rubocop/cop/{style → metrics}/method_length_spec.rb +1 -1
  105. data/spec/rubocop/cop/{style → metrics}/parameter_lists_spec.rb +1 -1
  106. data/spec/rubocop/cop/metrics/perceived_complexity_spec.rb +222 -0
  107. data/spec/rubocop/cop/{style → metrics}/while_until_modifier_spec.rb +2 -2
  108. data/spec/rubocop/cop/rails/output_spec.rb +8 -2
  109. data/spec/rubocop/cop/style/align_hash_spec.rb +7 -0
  110. data/spec/rubocop/cop/style/and_or_spec.rb +245 -43
  111. data/spec/rubocop/cop/style/bare_percent_literals_spec.rb +132 -0
  112. data/spec/rubocop/cop/style/block_end_newline_spec.rb +61 -0
  113. data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +34 -0
  114. data/spec/rubocop/cop/style/end_of_line_spec.rb +8 -0
  115. data/spec/rubocop/cop/style/guard_clause_spec.rb +1 -1
  116. data/spec/rubocop/cop/style/multiline_block_layout_spec.rb +138 -0
  117. data/spec/rubocop/cop/style/next_spec.rb +32 -3
  118. data/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +34 -0
  119. data/spec/rubocop/cop/style/percent_q_literals_spec.rb +122 -0
  120. data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +20 -0
  121. data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +26 -2
  122. data/spec/rubocop/cop/style/trailing_comma_spec.rb +112 -0
  123. data/spec/rubocop/cop/style/unneeded_percent_q_spec.rb +86 -31
  124. data/spec/rubocop/cop/style/variable_interpolation_spec.rb +21 -1
  125. data/spec/rubocop/cop/team_spec.rb +14 -9
  126. data/spec/spec_helper.rb +1 -0
  127. metadata +47 -50
  128. data/lib/rubocop/cop/mixin/if_then_else.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df336e05887bac795bd4e9c4f04e3bc3749a154c
4
- data.tar.gz: fad8eb6558bbf7656b4be594a3c4995b566ae4b9
3
+ metadata.gz: 162efdd3846932b1d519b27addb56f9581f28e5a
4
+ data.tar.gz: 0baf6fe4303cda3f842984b1ce7e7ee25b5e08b6
5
5
  SHA512:
6
- metadata.gz: a8c03f04da1bb7f176f622482ac3f4244f736b8318fcc334c680faa752eb063eaac721949849c582d313b71c9fbb0903d82c4f6fd5df2b0b62574f8e7a154c36
7
- data.tar.gz: b5d740c5335105d5256e3b59396776139c79ffd3857072761c00a630eb575df01478a4d98f6980b517c58cf9e32d6897fc9d3018d192f2cfa23d247f67a56837
6
+ metadata.gz: 6aa5d6a37649a89e441f5db7b9c02e4fcc033d52e457e9afcd8927906c1443d1cf6122adaf1af7c344f9f2154694bd33e0f9e71548ace50e7d30441baf9bd972
7
+ data.tar.gz: 828617aef1af7dc5260680d67633fef8135d2d884307b9b566a6b193f685fe061d0c47a1b12ef5f90ffe8bf42266a5d087ff518389c0400605bc4347795c2351
@@ -1,20 +1,24 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-05-17 17:36:04 +0200 using RuboCop version 0.21.0.
2
+ # on 2014-07-27 10:46:47 +0200 using RuboCop version 0.24.1.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 7
8
+ # Offense count: 8
9
9
  # Configuration parameters: CountComments.
10
- Style/ClassLength:
11
- Max: 129
10
+ Metrics/ClassLength:
11
+ Max: 131
12
12
 
13
- # Offense count: 24
14
- Style/CyclomaticComplexity:
13
+ # Offense count: 30
14
+ Metrics/CyclomaticComplexity:
15
15
  Max: 10
16
16
 
17
- # Offense count: 115
17
+ # Offense count: 124
18
18
  # Configuration parameters: CountComments.
19
- Style/MethodLength:
19
+ Metrics/MethodLength:
20
20
  Max: 21
21
+
22
+ # Offense count: 22
23
+ Metrics/PerceivedComplexity:
24
+ Max: 11
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1
@@ -10,6 +9,7 @@ rvm:
10
9
  matrix:
11
10
  allow_failures:
12
11
  - rvm: ruby-head
12
+ - rvm: rbx-2
13
13
  before_install: gem update --remote bundler
14
14
  script:
15
15
  - bundle exec rspec
@@ -2,6 +2,45 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.25.0 (15/08/2014)
6
+
7
+ ### New features
8
+
9
+ * [#1259](https://github.com/bbatsov/rubocop/issues/1259): Allow AndOr cop to autocorrect by adding method call parenthesis. ([@vrthra][])
10
+ * [#1232](https://github.com/bbatsov/rubocop/issues/1232): Add EnforcedStyle option to cop `AndOr` to restrict it to conditionals. ([@vrthra][])
11
+ * [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `PercentQLiterals` checks if use of `%Q` and `%q` matches configuration. ([@jonas054][])
12
+ * [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `BarePercentLiterals` checks if usage of `%()` or `%Q()` matches configuration. ([@jonas054][])
13
+ * [#1079](https://github.com/bbatsov/rubocop/pull/1079): New cop `MultilineBlockLayout` checks if a multiline block has an extpression on the same line as the start of the block. ([@barunio][])
14
+ * [#1217](https://github.com/bbatsov/rubocop/pull/1217): `Style::EmptyLinesAroundAccessModifier` cop does auto-correction. ([@tamird][])
15
+ * [#1220](https://github.com/bbatsov/rubocop/issues/1220): New cop `PerceivedComplexity` is similar to `CyclomaticComplexity`, but reports when methods have a high complexity for a human reader. ([@jonas054][])
16
+ * `Debugger` cop now checks for `binding.pry_remote`. ([@yous][])
17
+ * [#1238](https://github.com/bbatsov/rubocop/issues/1238): Add `MinBodyLength` option to `Next` cop. ([@bbatsov][])
18
+ * [#1241](https://github.com/bbatsov/rubocop/issues/1241): `TrailingComma` cop does auto-correction. ([@yous][])
19
+ * [#1078](https://github.com/bbatsov/rubocop/pull/1078): New cop `BlockEndNewline` checks if the end statement of a multiline block is on its own line. ([@barunio][])
20
+ * [#1078](https://github.com/bbatsov/rubocop/pull/1078): `BlockAlignment` cop does auto-correction. ([@barunio][])
21
+
22
+ ### Changes
23
+
24
+ * [#1220](https://github.com/bbatsov/rubocop/issues/1220): New namespace `Metrics` created and some `Style` cops moved there. ([@jonas054][])
25
+ * Drop support for Ruby 1.9.2 in accordance with [the end of the security maintenance extension](https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/). ([@yujinakayama][])
26
+
27
+ ### Bugs fixed
28
+
29
+ * [#1251](https://github.com/bbatsov/rubocop/issues/1251): Fix `PercentLiteralDelimiters` auto-correct indentation error. ([@hannestyden][])
30
+ * [#1197](https://github.com/bbatsov/rubocop/issues/1197): Fix false positive for new lambda syntax in `SpaceInsideBlockBraces`. ([@jonas054][])
31
+ * [#1201](https://github.com/bbatsov/rubocop/issues/1201): Fix error at anonymous keyword splat arguments in some variable cops. ([@yujinakayama][])
32
+ * Fix false positive in `UnneededPercentQ` for `/%Q(something)/`. ([@jonas054][])
33
+ * Fix `SpacesInsideBrackets` for `Hash#[]` calls with spaces after left bracket. ([@mcls][])
34
+ * [#1210](https://github.com/bbatsov/rubocop/issues/1210): Fix false positive in `UnneededPercentQ` for `%Q(\t")`. ([@jonas054][])
35
+ * Fix false positive in `UnneededPercentQ` for heredoc strings with `%q`/`%Q`. ([@jonas054][])
36
+ * [#1214](https://github.com/bbatsov/rubocop/issues/1214): Don't destroy code in `AlignHash` autocorrect. ([@jonas054][])
37
+ * [#1219](https://github.com/bbatsov/rubocop/issues/1219): Don't report bad alignment for `end` or `}` in `BlockAlignment` if it doesn't begin its line. ([@jonas054][])
38
+ * [#1227](https://github.com/bbatsov/rubocop/issues/1227): Don't permanently change yamler as it can affect other apps. ([@jonas054][])
39
+ * [#1184](https://github.com/bbatsov/rubocop/issues/1184): Fix a false positive in `Output` cop. ([@bbatsov][])
40
+ * [#1256](https://github.com/bbatsov/rubocop/issues/1256): Ignore block-pass in `TrailingComma`. ([@tamird][])
41
+ * [#1255](https://github.com/bbatsov/rubocop/issues/1255): Compare without context in `AutocorrectUnlessChangingAST`. ([@jonas054][])
42
+ * [#1262](https://github.com/bbatsov/rubocop/issues/1262): Handle regexp and backtick literals in `VariableInterpolation`. ([@bbatsov][])
43
+
5
44
  ## 0.24.1 (03/07/2014)
6
45
 
7
46
  ### Bugs fixed
@@ -1014,3 +1053,6 @@
1014
1053
  [@ggilder]: https://github.com/ggilder
1015
1054
  [@salbertson]: https://github.com/salbertson
1016
1055
  [@camilleldn]: https://github.com/camilleldn
1056
+ [@mcls]: https://github.com/mcls
1057
+ [@yous]: https://github.com/yous
1058
+ [@vrthra]: https://github.com/vrthra
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -20,11 +20,18 @@ Most aspects of its behavior can be tweaked via various
20
20
  Apart from reporting problems in your code, RuboCop can also
21
21
  automatically fix some of the problems for you.
22
22
 
23
+ **This documentation tracks the `master` branch of RuboCop. Some of
24
+ the features and settings discussed here might not be available in
25
+ older releases (including the current stable release). Please, consult
26
+ the relevant git repo branch if you need documentation for a specific RuboCop
27
+ release.**
28
+
23
29
  - [Installation](#installation)
24
30
  - [Basic Usage](#basic-usage)
25
31
  - [Cops](#cops)
26
32
  - [Style](#style)
27
33
  - [Lint](#lint)
34
+ - [Metrics](#metrics)
28
35
  - [Rails](#rails)
29
36
  - [Configuration](#configuration)
30
37
  - [Inheritance](#inheritance)
@@ -178,6 +185,14 @@ enabled lint cops plus a selection of other cops.
178
185
 
179
186
  Disabling any of the lint cops is generally a bad idea.
180
187
 
188
+ #### Metrics
189
+
190
+ Metrics cops deal with properties of the source code that can be measured,
191
+ such as class length, method length, etc. Generally speaking, they have a
192
+ configuration parameter called `Max` and when running
193
+ `rubocop --auto-gen-config`, this parameter will be set to the highest value
194
+ found for the inspected code.
195
+
181
196
  #### Rails
182
197
 
183
198
  Rails cops are specific to the Ruby on Rails framework. Unlike style
@@ -188,6 +203,13 @@ specifically:
188
203
  $ rubocop -R
189
204
  ```
190
205
 
206
+ or add the following directive to your `.rubocop.yml`:
207
+
208
+ ```yaml
209
+ AllCops:
210
+ RunRailsCops: true
211
+ ```
212
+
191
213
  ## Configuration
192
214
 
193
215
  The behavior of RuboCop can be controlled via the
@@ -207,7 +229,7 @@ inherit_from: ../.rubocop.yml
207
229
  Style/Encoding:
208
230
  Enabled: false
209
231
 
210
- Style/LineLength:
232
+ Metrics/LineLength:
211
233
  Max: 99
212
234
  ```
213
235
 
@@ -311,7 +333,7 @@ Rails/DefaultScope:
311
333
  Specific cops can be disabled by setting `Enabled` to `false` for that specific cop.
312
334
 
313
335
  ```yaml
314
- Style/LineLength:
336
+ Metrics/LineLength:
315
337
  Enabled: false
316
338
  ```
317
339
 
@@ -319,7 +341,7 @@ Cops can customize their severity level. All cops support the `Severity` param.
319
341
  Allowed params are `refactor`, `convention`, `warning`, `error` and `fatal`.
320
342
 
321
343
  ```yaml
322
- Style/CyclomaticComplexity:
344
+ Metrics/CyclomaticComplexity:
323
345
  Severity: warning
324
346
  ```
325
347
 
@@ -339,9 +361,9 @@ One or more individual cops can be disabled locally in a section of a
339
361
  file by adding a comment such as
340
362
 
341
363
  ```ruby
342
- # rubocop:disable Style/LineLength, Style/StringLiterals
364
+ # rubocop:disable Metrics/LineLength, Style/StringLiterals
343
365
  [...]
344
- # rubocop:enable Style/LineLength, Style/StringLiterals
366
+ # rubocop:enable Metrics/LineLength, Style/StringLiterals
345
367
  ```
346
368
 
347
369
  You can also disable *all* cops with
@@ -583,7 +605,6 @@ $ rubocop --format offenses
583
605
 
584
606
  RuboCop supports the following Ruby implementations:
585
607
 
586
- * MRI 1.9.2 ([until June 2014](https://www.ruby-lang.org/en/news/2013/12/17/maintenance-of-1-8-7-and-1-9-2/))
587
608
  * MRI 1.9.3
588
609
  * MRI 2.0
589
610
  * MRI 2.1
@@ -1,22 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- if RUBY_VERSION >= '1.9.2'
5
- $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
4
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
6
5
 
7
- require 'rubocop'
8
- require 'benchmark'
6
+ require 'rubocop'
7
+ require 'benchmark'
9
8
 
10
- cli = RuboCop::CLI.new
11
- result = 0
9
+ cli = RuboCop::CLI.new
10
+ result = 0
12
11
 
13
- time = Benchmark.realtime do
14
- result = cli.run
15
- end
16
-
17
- puts "Finished in #{time} seconds" if cli.options[:debug]
18
- exit result
19
- else
20
- puts 'RuboCop supports only Ruby 1.9.2+'
21
- exit(-1)
12
+ time = Benchmark.realtime do
13
+ result = cli.run
22
14
  end
15
+
16
+ puts "Finished in #{time} seconds" if cli.options[:debug]
17
+ exit result
@@ -10,7 +10,16 @@ AllCops:
10
10
  # Include gemspec and Rakefile
11
11
  Include:
12
12
  - '**/*.gemspec'
13
+ - '**/*.podspec'
14
+ - '**/*.jbuilder'
15
+ - '**/*.rake'
16
+ - '**/Gemfile'
13
17
  - '**/Rakefile'
18
+ - '**/Capfile'
19
+ - '**/Guardfile'
20
+ - '**/Podfile'
21
+ - '**/Thorfile'
22
+ - '**/Vagrantfile'
14
23
  Exclude:
15
24
  - 'vendor/**/*'
16
25
  # By default, the rails cops are not run. Override in project or home
@@ -107,8 +116,21 @@ Style/AlignParameters:
107
116
  - with_first_parameter
108
117
  - with_fixed_indentation
109
118
 
110
- Style/BlockNesting:
111
- Max: 3
119
+ Style/AndOr:
120
+ # Whether `and` and `or` are banned only in conditionals (conditionals)
121
+ # or completely (always).
122
+ EnforcedStyle: always
123
+ SupportedStyles:
124
+ - always
125
+ - conditionals
126
+
127
+
128
+ # Checks if usage of %() or %Q() matches configuration.
129
+ Style/BarePercentLiterals:
130
+ EnforcedStyle: bare_percent
131
+ SupportedStyles:
132
+ - percent_q
133
+ - bare_percent
112
134
 
113
135
  Style/BracesAroundHashParameters:
114
136
  EnforcedStyle: no_braces
@@ -150,10 +172,6 @@ Style/ClassCheck:
150
172
  SupportedStyles:
151
173
  - is_a?
152
174
  - kind_of?
153
-
154
- Style/ClassLength:
155
- CountComments: false # count full line comments?
156
- Max: 100
157
175
 
158
176
  # Align with the style guide.
159
177
  Style/CollectionMethods:
@@ -179,10 +197,6 @@ Style/CommentAnnotation:
179
197
  - HACK
180
198
  - REVIEW
181
199
 
182
- # Avoid complex methods.
183
- Style/CyclomaticComplexity:
184
- Max: 6
185
-
186
200
  # Multi-line method chaining should be done with leading dots.
187
201
  Style/DotPosition:
188
202
  EnforcedStyle: leading
@@ -208,6 +222,9 @@ Style/FileName:
208
222
  - '**/Rakefile'
209
223
  - '**/Gemfile'
210
224
  - '**/Capfile'
225
+ - '**/Vagrantfile'
226
+ - '**/Podfile'
227
+ - '**/Thorfile'
211
228
 
212
229
  # Checks use of for or each in multiline loops.
213
230
  Style/For:
@@ -262,15 +279,14 @@ Style/LambdaCall:
262
279
  - call
263
280
  - braces
264
281
 
265
- Style/LineLength:
266
- Max: 80
267
- AllowURI: true
268
-
269
282
  Style/Next:
270
283
  # With `always` all conditions at the end of an iteration needs to be
271
- # replace by next - with `skip_modifier_ifs` the modifier if like this one
284
+ # replaced by next - with `skip_modifier_ifs` the modifier if like this one
272
285
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
273
286
  EnforcedStyle: skip_modifier_ifs
287
+ # `MinBodyLength` defines the number of lines of the a body of an if / unless
288
+ # needs to have to trigger this cop
289
+ MinBodyLength: 3
274
290
  SupportedStyles:
275
291
  - skip_modifier_ifs
276
292
  - always
@@ -290,10 +306,6 @@ Style/MethodDefParentheses:
290
306
  - require_parentheses
291
307
  - require_no_parentheses
292
308
 
293
- Style/MethodLength:
294
- CountComments: false # count full line comments?
295
- Max: 10
296
-
297
309
  Style/MethodName:
298
310
  EnforcedStyle: snake_case
299
311
  SupportedStyles:
@@ -303,10 +315,6 @@ Style/MethodName:
303
315
  Style/NumericLiterals:
304
316
  MinDigits: 5
305
317
 
306
- Style/ParameterLists:
307
- Max: 5
308
- CountKeywordArgs: true
309
-
310
318
  # Allow safe assignment in conditions.
311
319
  Style/ParenthesesAroundCondition:
312
320
  AllowSafeAssignment: true
@@ -323,6 +331,12 @@ Style/PercentLiteralDelimiters:
323
331
  '%W': ()
324
332
  '%x': ()
325
333
 
334
+ Style/PercentQLiterals:
335
+ EnforcedStyle: lower_case_q
336
+ SupportedStyles:
337
+ - lower_case_q # Use %q when possible, %Q when necessary
338
+ - upper_case_q # Always use %Q
339
+
326
340
  Style/PredicateName:
327
341
  NamePrefixBlacklist:
328
342
  - is_
@@ -335,7 +349,6 @@ Style/RaiseArgs:
335
349
  - compact # raise Exception.new(msg)
336
350
  - exploded # raise Exception, msg
337
351
 
338
-
339
352
  Style/RedundantReturn:
340
353
  # When true allows code like `return x, y`.
341
354
  AllowMultipleReturnValues: false
@@ -356,7 +369,6 @@ Style/SignalException:
356
369
  - only_fail
357
370
  - semantic
358
371
 
359
-
360
372
  Style/SingleLineBlockParams:
361
373
  Methods:
362
374
  - reduce:
@@ -463,6 +475,34 @@ Style/WhileUntilModifier:
463
475
  Style/WordArray:
464
476
  MinSize: 0
465
477
 
478
+ ##################### Metrics ##################################
479
+
480
+ Metrics/BlockNesting:
481
+ Max: 3
482
+
483
+ Metrics/ClassLength:
484
+ CountComments: false # count full line comments?
485
+ Max: 100
486
+
487
+ # Avoid complex methods.
488
+ Metrics/CyclomaticComplexity:
489
+ Max: 6
490
+
491
+ Metrics/LineLength:
492
+ Max: 80
493
+ AllowURI: true
494
+
495
+ Metrics/MethodLength:
496
+ CountComments: false # count full line comments?
497
+ Max: 10
498
+
499
+ Metrics/ParameterLists:
500
+ Max: 5
501
+ CountKeywordArgs: true
502
+
503
+ Metrics/PerceivedComplexity:
504
+ Max: 7
505
+
466
506
  ##################### Lint ##################################
467
507
 
468
508
  # Allow safe assignment in conditions.
@@ -509,6 +549,13 @@ Rails/HasAndBelongsToMany:
509
549
  Include:
510
550
  - app/models/**/*.rb
511
551
 
552
+ Rails/Output:
553
+ Include:
554
+ - app/**/*.rb
555
+ - config/**/*.rb
556
+ - db/**/*.rb
557
+ - lib/**/*.rb
558
+
512
559
  Rails/ReadWriteAttribute:
513
560
  Include:
514
561
  - app/models/**/*.rb
@@ -54,12 +54,16 @@ Style/BeginBlock:
54
54
  Description: 'Avoid the use of BEGIN blocks.'
55
55
  Enabled: true
56
56
 
57
+ Style/BarePercentLiterals:
58
+ Description: 'Checks if usage of %() or %Q() matches configuration.'
59
+ Enabled: true
60
+
57
61
  Style/BlockComments:
58
62
  Description: 'Do not use block comments.'
59
63
  Enabled: true
60
64
 
61
- Style/BlockNesting:
62
- Description: 'Avoid excessive block nesting'
65
+ Style/BlockEndNewline:
66
+ Description: 'Put end statement of multiline block on its own line.'
63
67
  Enabled: true
64
68
 
65
69
  Style/Blocks:
@@ -97,10 +101,6 @@ Style/ClassCheck:
97
101
  Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
98
102
  Enabled: true
99
103
 
100
- Style/ClassLength:
101
- Description: 'Avoid classes longer than 100 lines of code.'
102
- Enabled: true
103
-
104
104
  Style/ClassMethods:
105
105
  Description: 'Use self when defining module/class methods.'
106
106
  Enabled: true
@@ -131,10 +131,6 @@ Style/ConstantName:
131
131
  Description: 'Constants should use SCREAMING_SNAKE_CASE.'
132
132
  Enabled: true
133
133
 
134
- Style/CyclomaticComplexity:
135
- Description: 'Avoid complex methods.'
136
- Enabled: true
137
-
138
134
  Style/DefWithParentheses:
139
135
  Description: 'Use def with parentheses when there are arguments.'
140
136
  Enabled: true
@@ -271,10 +267,6 @@ Style/LineEndConcatenation:
271
267
  line end.
272
268
  Enabled: true
273
269
 
274
- Style/LineLength:
275
- Description: 'Limit lines to 80 characters.'
276
- Enabled: true
277
-
278
270
  Style/MethodCallParentheses:
279
271
  Description: 'Do not use parentheses for method calls with no arguments.'
280
272
  Enabled: true
@@ -285,10 +277,6 @@ Style/MethodDefParentheses:
285
277
  parentheses.
286
278
  Enabled: true
287
279
 
288
- Style/MethodLength:
289
- Description: 'Avoid methods longer than 10 lines of code.'
290
- Enabled: true
291
-
292
280
  Style/MethodName:
293
281
  Description: 'Use the configured style when naming methods.'
294
282
  Enabled: true
@@ -301,6 +289,10 @@ Style/MultilineBlockChain:
301
289
  Description: 'Avoid multi-line chains of blocks.'
302
290
  Enabled: true
303
291
 
292
+ Style/MultilineBlockLayout:
293
+ Description: 'Ensures newlines after multiline block do statements.'
294
+ Enabled: true
295
+
304
296
  Style/MultilineIfThen:
305
297
  Description: 'Never use then for multi-line if/unless.'
306
298
  Enabled: true
@@ -357,10 +349,6 @@ Style/OpMethod:
357
349
  Description: 'When defining binary operators, name the argument other.'
358
350
  Enabled: true
359
351
 
360
- Style/ParameterLists:
361
- Description: 'Avoid parameter lists longer than three or four parameters.'
362
- Enabled: true
363
-
364
352
  Style/ParenthesesAroundCondition:
365
353
  Description: >-
366
354
  Don't use parentheses around the condition of an
@@ -371,6 +359,10 @@ Style/PercentLiteralDelimiters:
371
359
  Description: 'Use `%`-literal delimiters consistently'
372
360
  Enabled: true
373
361
 
362
+ Style/PercentQLiterals:
363
+ Description: 'Checks if uses of %Q/%q match the configured preference.'
364
+ Enabled: true
365
+
374
366
  Style/PerlBackrefs:
375
367
  Description: 'Avoid Perl-style regex back references.'
376
368
  Enabled: true
@@ -416,7 +408,9 @@ Style/RescueModifier:
416
408
  Enabled: true
417
409
 
418
410
  Style/SelfAssignment:
419
- Description: 'Checks for places where self-assignment shorthand should have been used.'
411
+ Description: >-
412
+ Checks for places where self-assignment shorthand should have
413
+ been used.
420
414
  Enabled: true
421
415
 
422
416
  Style/Semicolon:
@@ -595,6 +589,40 @@ Style/WordArray:
595
589
  Description: 'Use %w or %W for arrays of words.'
596
590
  Enabled: true
597
591
 
592
+ #################### Metrics ################################
593
+
594
+ Metrics/BlockNesting:
595
+ Description: 'Avoid excessive block nesting'
596
+ Enabled: true
597
+
598
+ Metrics/ClassLength:
599
+ Description: 'Avoid classes longer than 100 lines of code.'
600
+ Enabled: true
601
+
602
+ Metrics/CyclomaticComplexity:
603
+ Description: >-
604
+ A complexity metric that is strongy correlated to the number
605
+ of test cases needed to validate a method.
606
+ Enabled: true
607
+
608
+ Metrics/LineLength:
609
+ Description: 'Limit lines to 80 characters.'
610
+ Enabled: true
611
+
612
+ Metrics/MethodLength:
613
+ Description: 'Avoid methods longer than 10 lines of code.'
614
+ Enabled: true
615
+
616
+ Metrics/ParameterLists:
617
+ Description: 'Avoid parameter lists longer than three or four parameters.'
618
+ Enabled: true
619
+
620
+ Metrics/PerceivedComplexity:
621
+ Description: >-
622
+ A complexity metric geared towards measuring complexity for a
623
+ human reader.
624
+ Enabled: true
625
+
598
626
  #################### Lint ################################
599
627
  ### Warnings
600
628
 
@@ -619,7 +647,9 @@ Lint/BlockAlignment:
619
647
  Enabled: true
620
648
 
621
649
  Lint/ConditionPosition:
622
- Description: 'Checks for condition placed in a confusing position relative to the keyword.'
650
+ Description: >-
651
+ Checks for condition placed in a confusing position relative to
652
+ the keyword.
623
653
  Enabled: true
624
654
 
625
655
  Lint/Debugger:
@@ -781,7 +811,9 @@ Rails/Output:
781
811
  Enabled: true
782
812
 
783
813
  Rails/ReadWriteAttribute:
784
- Description: 'Checks for read_attribute(:attr) and write_attribute(:attr, val).'
814
+ Description: >-
815
+ Checks for read_attribute(:attr) and
816
+ write_attribute(:attr, val).
785
817
  Enabled: true
786
818
 
787
819
  Rails/ScopeArgs: