rubocop 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -4
  3. data/assets/output.html.erb +1 -1
  4. data/bin/console +9 -0
  5. data/config/default.yml +23 -3
  6. data/config/disabled.yml +2 -2
  7. data/config/enabled.yml +29 -13
  8. data/{bin → exe}/rubocop +0 -0
  9. data/lib/rubocop.rb +6 -2
  10. data/lib/rubocop/ast/node.rb +3 -1
  11. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +26 -5
  12. data/lib/rubocop/config_loader.rb +0 -1
  13. data/lib/rubocop/config_loader_resolver.rb +4 -2
  14. data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -1
  15. data/lib/rubocop/cop/generator.rb +1 -1
  16. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  17. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +130 -0
  18. data/lib/rubocop/cop/layout/dot_position.rb +2 -6
  19. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -1
  20. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +0 -1
  21. data/lib/rubocop/cop/layout/extra_spacing.rb +2 -2
  22. data/lib/rubocop/cop/layout/indent_heredoc.rb +29 -5
  23. data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
  24. data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
  25. data/lib/rubocop/cop/layout/leading_blank_lines.rb +53 -0
  26. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +11 -2
  27. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  28. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +4 -3
  29. data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
  30. data/lib/rubocop/cop/mixin/array_syntax.rb +1 -1
  31. data/lib/rubocop/cop/mixin/range_help.rb +3 -7
  32. data/lib/rubocop/cop/rails/assert_not.rb +1 -1
  33. data/lib/rubocop/cop/rails/bulk_change_table.rb +272 -0
  34. data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
  35. data/lib/rubocop/cop/rails/file_path.rb +40 -10
  36. data/lib/rubocop/cop/rails/http_positional_arguments.rb +1 -1
  37. data/lib/rubocop/cop/rails/time_zone.rb +3 -3
  38. data/lib/rubocop/cop/style/access_modifier_declarations.rb +111 -0
  39. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
  40. data/lib/rubocop/cop/style/command_literal.rb +1 -5
  41. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +30 -7
  42. data/lib/rubocop/cop/style/mixin_grouping.rb +8 -3
  43. data/lib/rubocop/cop/style/next.rb +1 -1
  44. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +26 -3
  45. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  46. data/lib/rubocop/cop/style/unneeded_condition.rb +73 -0
  47. data/lib/rubocop/cop/style/unneeded_percent_q.rb +13 -0
  48. data/lib/rubocop/cop/variable_force.rb +16 -17
  49. data/lib/rubocop/options.rb +15 -5
  50. data/lib/rubocop/result_cache.rb +3 -3
  51. data/lib/rubocop/string_util.rb +2 -147
  52. data/lib/rubocop/token.rb +2 -1
  53. data/lib/rubocop/version.rb +1 -1
  54. metadata +28 -9
  55. data/lib/rubocop/cop/lint/splat_keyword_arguments.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb9916f20b5502d5f82b3dda566fc49d305b165e
4
- data.tar.gz: 0eb589fa94973ba3c4d06e147312982cb8cfe35c
3
+ metadata.gz: 18bcf8548b6c61400893885a6ef649baeae5d368
4
+ data.tar.gz: edd6b617b454f944d114b9a9e40f4bd7b60e6629
5
5
  SHA512:
6
- metadata.gz: 60768e70eb0d1066092c6d45b22be8d1f5bb154c5996296a32e48ba8aec05514bad6e5492d97849b70f0b357f99050237503a0da1ef33afdfb56c76e7f493126
7
- data.tar.gz: 3d62fe67836732767da27fb00ab203103050466fd1064295a71109892ba10741ceaeea6f82a19c7866df6d77dbcec7af7d8cfe52bce3800457f5107f1d4ac3bb
6
+ metadata.gz: '08121a25d44c4a2a976adf2a1dcc894fa0c432443518e17dc07588294cdb2d18fecee5aea9e57bd21de7e0b8af125a37214fe9b4daabda4262ff4cfbac798626'
7
+ data.tar.gz: 4f5f292778ffa5e92480d931a0a12a784e0fc9e825aabcd9145adbe4704382feef4166b651ecfdb7522670501ff7a87781509da4995ac91ac14b3f485f8d5a37
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](http://badge.fury.io/rb/rubocop)
2
- [![Dependency Status](https://gemnasium.com/bbatsov/rubocop.svg)](https://gemnasium.com/bbatsov/rubocop)
3
- [![Travis Status](https://travis-ci.org/bbatsov/rubocop.svg?branch=master)](https://travis-ci.org/bbatsov/rubocop)
4
- [![Appveyor status](https://ci.appveyor.com/api/projects/status/e5jdwocv30oqm4sm?svg=true)](https://ci.appveyor.com/project/bbatsov/rubocop)
2
+ [![Travis Status](https://travis-ci.org/rubocop-hq/rubocop.svg?branch=master)](https://travis-ci.org/rubocop-hq/rubocop)
3
+ [![AppVeyor Status](https://ci.appveyor.com/api/projects/status/sj3ye7n5690d0nvg?svg=true)](https://ci.appveyor.com/project/bbatsov/rubocop)
5
4
  [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/bbatsov/rubocop.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
5
  [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
7
6
  [![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
@@ -52,7 +51,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
52
51
  might want to use a conservative version locking in your `Gemfile`:
53
52
 
54
53
  ```rb
55
- gem 'rubocop', '~> 0.56.0', require: false
54
+ gem 'rubocop', '~> 0.57.0', require: false
56
55
  ```
57
56
 
58
57
  ## Quickstart
@@ -254,7 +254,7 @@
254
254
  <% end %>
255
255
  </div>
256
256
  <footer>
257
- Generated by <a href="https://github.com/bbatsov/rubocop">RuboCop</a>
257
+ Generated by <a href="https://github.com/rubocop-hq/rubocop">RuboCop</a>
258
258
  <span class="version"><%= RuboCop::Version::STRING %></span>
259
259
  </footer>
260
260
  </body>
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pry'
5
+ require 'rubocop'
6
+
7
+ ARGV.clear
8
+
9
+ RuboCop.pry
@@ -80,7 +80,7 @@ AllCops:
80
80
  DisplayStyleGuide: false
81
81
  # When specifying style guide URLs, any paths and/or fragments will be
82
82
  # evaluated relative to the base URL.
83
- StyleGuideBaseURL: https://github.com/bbatsov/ruby-style-guide
83
+ StyleGuideBaseURL: https://github.com/rubocop-hq/ruby-style-guide
84
84
  # Extra details are not displayed in offense messages by default. Change
85
85
  # behavior by overriding ExtraDetails, or by giving the
86
86
  # `-E/--extra-details` option.
@@ -809,6 +809,12 @@ Naming/VariableNumber:
809
809
 
810
810
  #################### Style ###########################
811
811
 
812
+ Style/AccessModifierDeclarations:
813
+ EnforcedStyle: group
814
+ SupportedStyles:
815
+ - inline
816
+ - group
817
+
812
818
  Style/Alias:
813
819
  EnforcedStyle: prefer_alias
814
820
  SupportedStyles:
@@ -1405,7 +1411,7 @@ Style/StringMethods:
1405
1411
 
1406
1412
  Style/SymbolArray:
1407
1413
  EnforcedStyle: percent
1408
- MinSize: 0
1414
+ MinSize: 2
1409
1415
  SupportedStyles:
1410
1416
  - percent
1411
1417
  - brackets
@@ -1511,7 +1517,7 @@ Style/WordArray:
1511
1517
  # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
1512
1518
  # smaller than a certain size. The rule is only applied to arrays
1513
1519
  # whose element count is greater than or equal to `MinSize`.
1514
- MinSize: 0
1520
+ MinSize: 2
1515
1521
  # The regular expression `WordRegex` decides what is considered a word.
1516
1522
  WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
1517
1523
 
@@ -1668,6 +1674,14 @@ Rails/Blank:
1668
1674
  # Convert usages of `unless present?` to `if blank?`
1669
1675
  UnlessPresent: true
1670
1676
 
1677
+ Rails/BulkChangeTable:
1678
+ Database: null
1679
+ SupportedDatabases:
1680
+ - mysql
1681
+ - postgresql
1682
+ Include:
1683
+ - db/migrate/*.rb
1684
+
1671
1685
  Rails/CreateTableWithTimestamps:
1672
1686
  Include:
1673
1687
  - db/migrate/*.rb
@@ -1705,6 +1719,12 @@ Rails/Exit:
1705
1719
  Exclude:
1706
1720
  - lib/**/*.rake
1707
1721
 
1722
+ Rails/FilePath:
1723
+ EnforcedStyle: arguments
1724
+ SupportedStyles:
1725
+ - slashes
1726
+ - arguments
1727
+
1708
1728
  Rails/FindBy:
1709
1729
  Include:
1710
1730
  - app/models/**/*.rb
@@ -2,7 +2,7 @@
2
2
 
3
3
  Layout/ClassStructure:
4
4
  Description: 'Enforces a configured order of definitions within a class body.'
5
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-classes'
5
+ StyleGuide: 'https://github.com/rubocop-hq/ruby-style-guide#consistent-classes'
6
6
  Enabled: false
7
7
 
8
8
  Layout/EmptyLineAfterGuardClause:
@@ -49,7 +49,7 @@ Rails:
49
49
 
50
50
  Rails/SaveBang:
51
51
  Description: 'Identifies possible cases where Active Record save! or related should be used.'
52
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#save-bang'
52
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#save-bang'
53
53
  Enabled: false
54
54
 
55
55
  Style/AutoResourceCleanup:
@@ -91,6 +91,10 @@ Layout/CaseIndentation:
91
91
  StyleGuide: '#indent-when-to-case'
92
92
  Enabled: true
93
93
 
94
+ Layout/ClosingHeredocIndentation:
95
+ Description: 'Checks the indenation of here document closings.'
96
+ Enabled: true
97
+
94
98
  Layout/ClosingParenthesisIndentation:
95
99
  Description: 'Checks the indentation of hanging closing parentheses.'
96
100
  Enabled: true
@@ -230,6 +234,10 @@ Layout/InitialIndentation:
230
234
  Checks the indentation of the first non-blank non-comment line in a file.
231
235
  Enabled: true
232
236
 
237
+ Layout/LeadingBlankLines:
238
+ Description: Check for unnecessary blank lines at the beginning of a file.
239
+ Enabled: true
240
+
233
241
  Layout/LeadingCommentSpace:
234
242
  Description: 'Comments should start with a space.'
235
243
  StyleGuide: '#hash-space'
@@ -685,10 +693,6 @@ Lint/ShadowingOuterLocalVariable:
685
693
  for block arguments or block local variables.
686
694
  Enabled: true
687
695
 
688
- Lint/SplatKeywordArguments:
689
- Description: 'Checks for use of splat keyword arguments as a single Hash.'
690
- Enabled: true
691
-
692
696
  Lint/StringConversionInInterpolation:
693
697
  Description: 'Checks for Object#to_s usage in string interpolation.'
694
698
  StyleGuide: '#no-to-s'
@@ -1122,6 +1126,10 @@ Rails/Blank:
1122
1126
  Description: 'Enforces use of `blank?`.'
1123
1127
  Enabled: true
1124
1128
 
1129
+ Rails/BulkChangeTable:
1130
+ Description: 'Check whether alter queries are combinable.'
1131
+ Enabled: true
1132
+
1125
1133
  Rails/CreateTableWithTimestamps:
1126
1134
  Description: >-
1127
1135
  Checks the migration for which timestamps are not included
@@ -1144,7 +1152,7 @@ Rails/DelegateAllowBlank:
1144
1152
 
1145
1153
  Rails/DynamicFindBy:
1146
1154
  Description: 'Use `find_by` instead of dynamic `find_by_*`.'
1147
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1155
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
1148
1156
  Enabled: true
1149
1157
 
1150
1158
  Rails/EnumUniqueness:
@@ -1168,22 +1176,22 @@ Rails/FilePath:
1168
1176
 
1169
1177
  Rails/FindBy:
1170
1178
  Description: 'Prefer find_by over where.first.'
1171
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
1179
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
1172
1180
  Enabled: true
1173
1181
 
1174
1182
  Rails/FindEach:
1175
1183
  Description: 'Prefer all.find_each over all.find.'
1176
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
1184
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find-each'
1177
1185
  Enabled: true
1178
1186
 
1179
1187
  Rails/HasAndBelongsToMany:
1180
1188
  Description: 'Prefer has_many :through to has_and_belongs_to_many.'
1181
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
1189
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has-many-through'
1182
1190
  Enabled: true
1183
1191
 
1184
1192
  Rails/HasManyOrHasOneDependent:
1185
1193
  Description: 'Define the dependent option to the has_many and has_one associations.'
1186
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has_many-has_one-dependent-option'
1194
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has_many-has_one-dependent-option'
1187
1195
  Enabled: true
1188
1196
 
1189
1197
  Rails/HttpPositionalArguments:
@@ -1203,7 +1211,7 @@ Rails/InverseOf:
1203
1211
 
1204
1212
  Rails/LexicallyScopedActionFilter:
1205
1213
  Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
1206
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#lexically-scoped-action-filter'
1214
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
1207
1215
  Enabled: true
1208
1216
 
1209
1217
  Rails/NotNullColumn:
@@ -1234,7 +1242,7 @@ Rails/ReadWriteAttribute:
1234
1242
  Description: >-
1235
1243
  Checks for read_attribute(:attr) and
1236
1244
  write_attribute(:attr, val).
1237
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
1245
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#read-attribute'
1238
1246
  Enabled: true
1239
1247
 
1240
1248
  Rails/RedundantReceiverInWithOptions:
@@ -1255,7 +1263,7 @@ Rails/RequestReferer:
1255
1263
 
1256
1264
  Rails/ReversibleMigration:
1257
1265
  Description: 'Checks whether the change method of the migration file is reversible.'
1258
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#reversible-migration'
1266
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#reversible-migration'
1259
1267
  Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
1260
1268
  Enabled: true
1261
1269
 
@@ -1276,7 +1284,7 @@ Rails/SkipsModelValidations:
1276
1284
 
1277
1285
  Rails/TimeZone:
1278
1286
  Description: 'Checks the correct usage of time zone aware methods.'
1279
- StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
1287
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#time'
1280
1288
  Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
1281
1289
  Enabled: true
1282
1290
 
@@ -1328,6 +1336,10 @@ Security/YAMLLoad:
1328
1336
 
1329
1337
  #################### Style ###############################
1330
1338
 
1339
+ Style/AccessModifierDeclarations:
1340
+ Description: 'Checks style of how access modifiers are used.'
1341
+ Enabled: true
1342
+
1331
1343
  Style/Alias:
1332
1344
  Description: 'Use alias instead of alias_method.'
1333
1345
  StyleGuide: '#alias-method'
@@ -2030,6 +2042,10 @@ Style/UnneededCapitalW:
2030
2042
  Description: 'Checks for %W when interpolation is not needed.'
2031
2043
  Enabled: true
2032
2044
 
2045
+ Style/UnneededCondition:
2046
+ Description: 'Checks for unnecessary conditional expressions.'
2047
+ Enabled: true
2048
+
2033
2049
  Style/UnneededInterpolation:
2034
2050
  Description: 'Checks for strings that are just an interpolated expression.'
2035
2051
  Enabled: true
File without changes
@@ -11,7 +11,7 @@ require 'powerpack/enumerable/drop_last'
11
11
  require 'powerpack/hash/symbolize_keys'
12
12
  require 'powerpack/string/blank'
13
13
  require 'powerpack/string/strip_indent'
14
- require 'unicode/display_width'
14
+ require 'unicode/display_width/no_string_ext'
15
15
 
16
16
  require_relative 'rubocop/version'
17
17
 
@@ -173,6 +173,7 @@ require_relative 'rubocop/cop/layout/block_alignment'
173
173
  require_relative 'rubocop/cop/layout/block_end_newline'
174
174
  require_relative 'rubocop/cop/layout/case_indentation'
175
175
  require_relative 'rubocop/cop/layout/class_structure'
176
+ require_relative 'rubocop/cop/layout/closing_heredoc_indentation'
176
177
  require_relative 'rubocop/cop/layout/closing_parenthesis_indentation'
177
178
  require_relative 'rubocop/cop/layout/comment_indentation'
178
179
  require_relative 'rubocop/cop/layout/condition_position'
@@ -207,6 +208,7 @@ require_relative 'rubocop/cop/layout/indentation_width'
207
208
  require_relative 'rubocop/cop/layout/indent_hash'
208
209
  require_relative 'rubocop/cop/layout/indent_heredoc'
209
210
  require_relative 'rubocop/cop/layout/initial_indentation'
211
+ require_relative 'rubocop/cop/layout/leading_blank_lines'
210
212
  require_relative 'rubocop/cop/layout/leading_comment_space'
211
213
  require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
212
214
  require_relative 'rubocop/cop/layout/multiline_assignment_layout'
@@ -301,7 +303,6 @@ require_relative 'rubocop/cop/lint/script_permission'
301
303
  require_relative 'rubocop/cop/lint/shadowed_argument'
302
304
  require_relative 'rubocop/cop/lint/shadowed_exception'
303
305
  require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
304
- require_relative 'rubocop/cop/lint/splat_keyword_arguments'
305
306
  require_relative 'rubocop/cop/lint/string_conversion_in_interpolation'
306
307
  require_relative 'rubocop/cop/lint/syntax'
307
308
  require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
@@ -378,6 +379,7 @@ require_relative 'rubocop/cop/performance/unfreeze_string'
378
379
  require_relative 'rubocop/cop/performance/unneeded_sort'
379
380
  require_relative 'rubocop/cop/performance/uri_default_parser'
380
381
 
382
+ require_relative 'rubocop/cop/style/access_modifier_declarations'
381
383
  require_relative 'rubocop/cop/style/alias'
382
384
  require_relative 'rubocop/cop/style/and_or'
383
385
  require_relative 'rubocop/cop/style/array_join'
@@ -526,6 +528,7 @@ require_relative 'rubocop/cop/style/trailing_underscore_variable'
526
528
  require_relative 'rubocop/cop/style/trivial_accessors'
527
529
  require_relative 'rubocop/cop/style/unless_else'
528
530
  require_relative 'rubocop/cop/style/unneeded_capital_w'
531
+ require_relative 'rubocop/cop/style/unneeded_condition'
529
532
  require_relative 'rubocop/cop/style/unneeded_interpolation'
530
533
  require_relative 'rubocop/cop/style/unneeded_percent_q'
531
534
  require_relative 'rubocop/cop/style/unpack_first'
@@ -544,6 +547,7 @@ require_relative 'rubocop/cop/rails/application_job'
544
547
  require_relative 'rubocop/cop/rails/application_record'
545
548
  require_relative 'rubocop/cop/rails/assert_not'
546
549
  require_relative 'rubocop/cop/rails/blank'
550
+ require_relative 'rubocop/cop/rails/bulk_change_table'
547
551
  require_relative 'rubocop/cop/rails/create_table_with_timestamps'
548
552
  require_relative 'rubocop/cop/rails/date'
549
553
  require_relative 'rubocop/cop/rails/dynamic_find_by'
@@ -91,7 +91,7 @@ module RuboCop
91
91
  @mutable_attributes.frozen?
92
92
  end
93
93
 
94
- protected :parent=
94
+ protected :parent= # rubocop:disable Style/AccessModifierDeclarations
95
95
 
96
96
  # Override `AST::Node#updated` so that `AST::Processor` does not try to
97
97
  # mutate our ASTs. Since we keep references from children to parents and
@@ -321,7 +321,9 @@ module RuboCop
321
321
  (casgn $_ $_ (send (const nil? {:Class :Module}) :new ...))
322
322
  (casgn $_ $_ (block (send (const nil? {:Class :Module}) :new ...) ...))}
323
323
  PATTERN
324
+ # rubocop:disable Style/AccessModifierDeclarations
324
325
  private :defined_module0
326
+ # rubocop:enable Style/AccessModifierDeclarations
325
327
 
326
328
  def defined_module
327
329
  namespace, name = *defined_module0
@@ -40,12 +40,29 @@ module RuboCop
40
40
  !receiver && macro_scope?
41
41
  end
42
42
 
43
- # Checks whether the dispatched method is a bare access modifier affects
44
- # all methods defined after the macro.
43
+ # Checks whether the dispatched method is an access modifier.
45
44
  #
46
- # @return [Boolean] whether the dispatched method is access modifier
45
+ # @return [Boolean] whether the dispatched method is an access modifier
47
46
  def access_modifier?
48
- macro? && bare_access_modifier?
47
+ bare_access_modifier? || non_bare_access_modifier?
48
+ end
49
+
50
+ # Checks whether the dispatched method is a bare access modifier that
51
+ # affects all methods defined after the macro.
52
+ #
53
+ # @return [Boolean] whether the dispatched method is a bare
54
+ # access modifier
55
+ def bare_access_modifier?
56
+ macro? && bare_access_modifier_declaration?
57
+ end
58
+
59
+ # Checks whether the dispatched method is a non-bare access modifier that
60
+ # affects only the method it receives.
61
+ #
62
+ # @return [Boolean] whether the dispatched method is a non-bare
63
+ # access modifier
64
+ def non_bare_access_modifier?
65
+ macro? && non_bare_access_modifier_declaration?
49
66
  end
50
67
 
51
68
  # Checks whether the name of the dispatched method matches the argument
@@ -166,9 +183,13 @@ module RuboCop
166
183
  (send nil? _ ({def defs} ...))
167
184
  PATTERN
168
185
 
169
- def_node_matcher :bare_access_modifier?, <<-PATTERN
186
+ def_node_matcher :bare_access_modifier_declaration?, <<-PATTERN
170
187
  (send nil? {:public :protected :private :module_function})
171
188
  PATTERN
189
+
190
+ def_node_matcher :non_bare_access_modifier_declaration?, <<-PATTERN
191
+ (send nil? {:public :protected :private :module_function} _)
192
+ PATTERN
172
193
  end
173
194
  end
174
195
  end
@@ -49,7 +49,6 @@ module RuboCop
49
49
  resolver.resolve_inheritance(path, hash, file, debug?)
50
50
 
51
51
  hash.delete('inherit_from')
52
- hash.delete('inherit_mode')
53
52
 
54
53
  Config.create(hash, path)
55
54
  end
@@ -70,7 +70,9 @@ module RuboCop
70
70
  config = handle_disabled_by_default(config, default_configuration)
71
71
  end
72
72
 
73
- Config.new(merge(default_configuration, config), config_file)
73
+ Config.new(merge(default_configuration, config,
74
+ inherit_mode: config['inherit_mode'] || {}),
75
+ config_file)
74
76
  end
75
77
 
76
78
  # Returns a new hash where the parameters of the given config hash have
@@ -83,7 +85,7 @@ module RuboCop
83
85
  keys_appearing_in_both = base_hash.keys & derived_hash.keys
84
86
  keys_appearing_in_both.each do |key|
85
87
  if base_hash[key].is_a?(Hash)
86
- result[key] = merge(base_hash[key], derived_hash[key])
88
+ result[key] = merge(base_hash[key], derived_hash[key], **opts)
87
89
  elsif should_union?(base_hash, key, opts[:inherit_mode])
88
90
  result[key] = base_hash[key] | derived_hash[key]
89
91
  elsif opts[:debug]
@@ -57,7 +57,7 @@ module RuboCop
57
57
  return [] unless node.is_a?(Parser::AST::Node)
58
58
 
59
59
  node.each_node(:dstr)
60
- .select { |n| n.loc.respond_to?(:heredoc_body) }
60
+ .select(&:heredoc?)
61
61
  .map { |n| n.loc.heredoc_body.join(n.loc.heredoc_end) }
62
62
  end
63
63
 
@@ -52,7 +52,7 @@ module RuboCop
52
52
  # TODO: Implement the cop in here.
53
53
  #
54
54
  # In many cases, you can use a node matcher for matching node pattern.
55
- # See https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/node_pattern.rb
55
+ # See https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/node_pattern.rb
56
56
  #
57
57
  # For example
58
58
  MSG = 'Use `#good_method` instead of `#bad_method`.'.freeze
@@ -103,7 +103,7 @@ module RuboCop
103
103
  # end
104
104
  # end
105
105
  #
106
- # @see https://github.com/bbatsov/ruby-style-guide#consistent-classes
106
+ # @see https://github.com/rubocop-hq/ruby-style-guide#consistent-classes
107
107
  class ClassStructure < Cop
108
108
  HUMANIZED_NODE_TYPE = {
109
109
  casgn: :constants,