rubocop 0.17.0 → 0.18.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -42
  3. data/CONTRIBUTING.md +20 -3
  4. data/config/enabled.yml +10 -0
  5. data/lib/rubocop.rb +7 -0
  6. data/lib/rubocop/cop/cop.rb +4 -13
  7. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  8. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
  9. data/lib/rubocop/cop/lint/loop.rb +1 -1
  10. data/lib/rubocop/cop/lint/require_parentheses.rb +72 -0
  11. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
  12. data/lib/rubocop/cop/style/access_modifier_indentation.rb +3 -1
  13. data/lib/rubocop/cop/style/align_array.rb +1 -1
  14. data/lib/rubocop/cop/style/align_hash.rb +1 -1
  15. data/lib/rubocop/cop/style/align_parameters.rb +1 -1
  16. data/lib/rubocop/cop/style/def_parentheses.rb +1 -1
  17. data/lib/rubocop/cop/style/line_end_concatenation.rb +53 -0
  18. data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
  19. data/lib/rubocop/cop/style/proc.rb +6 -0
  20. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  21. data/lib/rubocop/cop/style/space_after_method_name.rb +1 -1
  22. data/lib/rubocop/cop/style/trailing_comma.rb +7 -0
  23. data/lib/rubocop/cop/style/word_array.rb +27 -0
  24. data/lib/rubocop/cop/util.rb +1 -0
  25. data/lib/rubocop/formatter/simple_text_formatter.rb +6 -2
  26. data/lib/rubocop/options.rb +1 -1
  27. data/lib/rubocop/path_util.rb +22 -0
  28. data/lib/rubocop/rake_task.rb +17 -3
  29. data/lib/rubocop/version.rb +1 -1
  30. data/rubocop.gemspec +2 -2
  31. data/spec/project_spec.rb +93 -0
  32. data/spec/rubocop/cli_spec.rb +27 -22
  33. data/spec/rubocop/cop/cop_spec.rb +1 -1
  34. data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +2 -2
  35. data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
  36. data/spec/rubocop/cop/lint/block_alignment_spec.rb +5 -5
  37. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +2 -2
  38. data/spec/rubocop/cop/lint/require_parentheses_spec.rb +82 -0
  39. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +1 -1
  40. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +9 -9
  41. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +54 -54
  42. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +6 -6
  43. data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +49 -8
  44. data/spec/rubocop/cop/style/align_array_spec.rb +1 -1
  45. data/spec/rubocop/cop/style/align_hash_spec.rb +1 -1
  46. data/spec/rubocop/cop/style/align_parameters_spec.rb +2 -2
  47. data/spec/rubocop/cop/style/blocks_spec.rb +1 -1
  48. data/spec/rubocop/cop/style/case_indentation_spec.rb +1 -1
  49. data/spec/rubocop/cop/style/dot_position_spec.rb +1 -1
  50. data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +2 -2
  51. data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +3 -3
  52. data/spec/rubocop/cop/style/indentation_consistency_spec.rb +4 -4
  53. data/spec/rubocop/cop/style/indentation_width_spec.rb +3 -3
  54. data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +27 -0
  55. data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +1 -1
  56. data/spec/rubocop/cop/style/proc_spec.rb +5 -0
  57. data/spec/rubocop/cop/style/regexp_literal_spec.rb +4 -4
  58. data/spec/rubocop/cop/style/string_literals_spec.rb +7 -7
  59. data/spec/rubocop/cop/style/trailing_comma_spec.rb +27 -6
  60. data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
  61. data/spec/rubocop/cop/style/variable_interpolation_spec.rb +2 -2
  62. data/spec/rubocop/cop/style/word_array_spec.rb +10 -0
  63. data/spec/rubocop/cop/variable_inspector/variable_table_spec.rb +4 -4
  64. data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +1 -1
  65. data/spec/rubocop/formatter/formatter_set_spec.rb +1 -1
  66. data/spec/rubocop/path_util_spec.rb +42 -0
  67. data/spec/spec_helper.rb +3 -1
  68. metadata +29 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 552c566c61ce3c52d1ce2a3e7eaaf49e44c3713b
4
- data.tar.gz: bf4a50153a0972e4bc98c07824a4172832167efd
3
+ metadata.gz: 449eac86969013808cd868da4a3f30a19ed9fee4
4
+ data.tar.gz: e90bbbb51afe783b1e6cbaaee26776b215c37b0a
5
5
  SHA512:
6
- metadata.gz: 59e5976c14e691499c402cbf1200373c0eace5e5304d6a54af9d976818f56a6d1ed27f4634256fcd32ddbeff428f1f265840150a88cf7ce461caf98d561285af
7
- data.tar.gz: 43c064daba533bbbfcaaace9f57849db7ebb4b7baa154327f777fcc34eb499139161e5d21fcc28bd42e8309109b63b28f3adceffbf644f5a72ff348d75c14d84
6
+ metadata.gz: 0cbce187b2372414f314b7c79a1046a3951aa32d6056bd0324ee48b85bb3a7f85b48745cb3937d5f52a43b032def66e1b8d8c5c31847ec078b88b8b65ad8bae3
7
+ data.tar.gz: 94d82a1c2921ba2dbb630cb0a1a2d69b2df8ad32b9410580c6a61d86868e48b05bd83cba89e3ab8a47c773a4255e22397d985c380c9980708ddbb1883c0eeff5
@@ -2,6 +2,28 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.18.0 (30/01/2014)
6
+
7
+ ### New features
8
+
9
+ * [#714](https://github.com/bbatsov/rubocop/issues/714): New cop `RequireParentheses` checks for method calls without parentheses together with a boolean operator indicating that a mistake about precedence may have been made. ([@jonas054][])
10
+ * [#743](https://github.com/bbatsov/rubocop/issues/743): `WordArray` cop does auto-correction. ([@jonas054][])
11
+ * [#743](https://github.com/bbatsov/rubocop/issues/743): `Proc` cop does auto-correction. ([@bbatsov][])
12
+ * [#743](https://github.com/bbatsov/rubocop/issues/743): `AccessModifierIndentation` cop does auto-correction. ([@jonas054][])
13
+ * [#768](https://github.com/bbatsov/rubocop/issues/768): Rake task now supports `requires` and `options`. ([@nevir][])
14
+ * [#759](https://github.com/bbatsov/rubocop/issues/759): New cop `EndLineConcatenation` checks for string literal concatenation with `+` at line end. ([@bbatsov][])
15
+
16
+ ### Changes
17
+
18
+ * [#762](https://github.com/bbatsov/rubocop/issues/762): Support Rainbow gem both 1.99.x and 2.x. ([@yujinakayama][])
19
+ * [#761](https://github.com/bbatsov/rubocop/issues/761): Relax `json` requirement to `>= 1.7.7`. ([@bbatsov][])
20
+ * [#757](https://github.com/bbatsov/rubocop/issues/757): `Include/Exclude` supports relative globbing to some extent. ([@nevir][])
21
+
22
+ ### Bugs fixed
23
+
24
+ * [#764](https://github.com/bbatsov/rubocop/issues/764): Handle heredocs in `TrailingComma`. ([@jonas054][])
25
+ * Guide for contributors now points to correct issues page. ([@scottmatthewman][])
26
+
5
27
  ## 0.17.0 (25/01/2014)
6
28
 
7
29
  ### New features
@@ -16,7 +38,7 @@
16
38
 
17
39
  ### Changes
18
40
 
19
- * [581](https://github.com/bbatsov/rubocop/pull/581): Extracted a new cop `AmbiguousOperator` from `Syntax` cop. It checks for ambiguous operators in the first argument of a method invocation without parentheses. ([@yujinakayama][])
41
+ * [#581](https://github.com/bbatsov/rubocop/pull/581): Extracted a new cop `AmbiguousOperator` from `Syntax` cop. It checks for ambiguous operators in the first argument of a method invocation without parentheses. ([@yujinakayama][])
20
42
  * Extracted a new cop `AmbiguousRegexpLiteral` from `Syntax` cop. It checks for ambiguous regexp literals in the first argument of a method invocation without parentheses. ([@yujinakayama][])
21
43
  * Extracted a new cop `UselessElseWithoutRescue` from `Syntax` cop. It checks for useless `else` in `begin..end` without `rescue`. ([@yujinakayama][])
22
44
  * Extracted a new cop `InvalidCharacterLiteral` from `Syntax` cop. It checks for invalid character literals with a non-escaped whitespace character (e.g. `? `). ([@yujinakayama][])
@@ -59,7 +81,7 @@
59
81
  * Rake task now support setting formatters. ([@pmenglund][])
60
82
  * [#653](https://github.com/bbatsov/rubocop/issues/653): `CaseIndentation` cop is now configurable with parameters `IndentWhenRelativeTo` and `IndentOneStep`. ([@jonas054][])
61
83
  * [#654](https://github.com/bbatsov/rubocop/pull/654): `For` cop is now configurable to enforce either `each` (default) or `for`. ([@jonas054][])
62
- * [#661](https://github.com/bbatsov/rubocop/issue/661): `EndAlignment` cop is now configurable for alignment with `keyword` (default) or `variable`. ([@jonas054][])
84
+ * [#661](https://github.com/bbatsov/rubocop/issues/661): `EndAlignment` cop is now configurable for alignment with `keyword` (default) or `variable`. ([@jonas054][])
63
85
  * Allow to overwrite the severity of a cop with the new `Severity` param. ([@codez][])
64
86
  * New cop `FlipFlop` checks for flip flops. ([@agrimm][])
65
87
  * [#577](https://github.com/bbatsov/rubocop/issues/577): Introduced `MethodDefParentheses` to allow for for requiring either parentheses or no parentheses in method definitions. Replaces `DefWithoutParentheses`. ([@skanev][])
@@ -78,7 +100,7 @@
78
100
  * Handle properly heredocs in `StringLiterals` cop. ([@bbatsov][])
79
101
  * Fix `SpaceAroundOperators` to not report missing space around operator for `def self.method *args`. ([@jonas054][])
80
102
  * Properly handle `['AllCops']['Includes']` and `['AllCops']['Excludes']` when passing config via `-c`. ([@fancyremarker][], [@codez][])
81
- * [#611](https://github.com/bbatsov/rubocop/pull/611): Fix crash when loading an empty config file ([@sinisterchipmunk][])
103
+ * [#611](https://github.com/bbatsov/rubocop/pull/611): Fix crash when loading an empty config file. ([@sinisterchipmunk][])
82
104
  * Fix `DotPosition` cop with `trailing` style for method calls on same line. ([@vonTronje][])
83
105
  * [#627](https://github.com/bbatsov/rubocop/pull/627): Fix counting of slashes in complicated regexps in `RegexpLiteral` cop. ([@jonas054][])
84
106
  * [#638](https://github.com/bbatsov/rubocop/issues/638): Fix bug in auto-correct that changes `each{ |x|` to `each d o |x|`. ([@jonas054][])
@@ -123,7 +145,7 @@
123
145
  * Encoding errors are reported as fatal offences rather than printed with red text. ([@jonas054][])
124
146
  * `AccessControl` cop is now configurable with the `EnforcedStyle` option. ([@sds][])
125
147
  * Split `AccessControl` cop to `AccessModifierIndentation` and `EmptyLinesAroundAccessModifier`. ([@bbatsov][])
126
- * [#594](https://github.com/bbatsov/rubocop/pull/594): Add configuration parameter `EnforcedStyleForEmptyBraces` to `SpaceInsideHashLiteralBraces` cop, and change `EnforcedStyleIsWithSpaces` (values `true`, `false`) to `EnforcedStyle` (values `space`, `no_space`) ([@jonas054][])
148
+ * [#594](https://github.com/bbatsov/rubocop/pull/594): Add configuration parameter `EnforcedStyleForEmptyBraces` to `SpaceInsideHashLiteralBraces` cop, and change `EnforcedStyleIsWithSpaces` (values `true`, `false`) to `EnforcedStyle` (values `space`, `no_space`). ([@jonas054][])
127
149
  * Coverage builds linked from the README page are enabled again. ([@jonas054][])
128
150
 
129
151
  ### Bugs fixed
@@ -142,7 +164,7 @@
142
164
  * [#600](https://github.com/bbatsov/rubocop/pull/600): Don't require an empty line for access modifiers at the beginning of class/module body. ([@bbatsov][])
143
165
  * [#608](https://github.com/bbatsov/rubocop/pull/608): `RescueException` no longer crashes when the namespace of a rescued class is in a local variable. ([@jonas054][])
144
166
  * [#173](https://github.com/bbatsov/rubocop/issues/173): Allow the use of `alias` in the body of an `instance_exec`. ([@bbatsov][])
145
- * [#554](https://github.com/bbatsov/rubocop/issues/554): Handle properly multi-line arrays with comments in them in `WordArray` ([@bbatsov][])
167
+ * [#554](https://github.com/bbatsov/rubocop/issues/554): Handle properly multi-line arrays with comments in them in `WordArray`. ([@bbatsov][])
146
168
 
147
169
  ## 0.14.1 (10/10/2013)
148
170
 
@@ -263,8 +285,8 @@
263
285
 
264
286
  ### New features
265
287
 
266
- * [#439](https://github.com/bbatsov/rubocop/issues/439) Added formatter 'OffenceCount' which outputs a summary list of cops and their offence count.
267
- * [#395](https://github.com/bbatsov/rubocop/issues/395) Added `--show-cops` option to show available cops.
288
+ * [#439](https://github.com/bbatsov/rubocop/issues/439): Added formatter 'OffenceCount' which outputs a summary list of cops and their offence count.
289
+ * [#395](https://github.com/bbatsov/rubocop/issues/395): Added `--show-cops` option to show available cops.
268
290
  * New cop `NilComparison` keeps track of comparisons like `== nil`.
269
291
  * New cop `EvenOdd` keeps track of occasions where `Fixnum#even?` or `Fixnum#odd?` should have been used (like `x % 2 == 0`).
270
292
  * New cop `IndentationWidth` checks for files using indentation that is not two spaces.
@@ -323,7 +345,7 @@
323
345
  ### Bugs fixed
324
346
 
325
347
  * [#374](https://github.com/bbatsov/rubocop/issues/374): Fixed error at post condition loop (`begin-end-while`, `begin-end-until`) in `UnusedLocalVariable` and `ShadowingOuterLocalVariable`.
326
- * [#373](https://github.com/bbatsov/rubocop/issues/373) and [#376](https://github.com/bbatsov/rubocop/issues/376): allow braces around multi-line blocks if `do`-`end` would change the meaning of the code.
348
+ * [#373](https://github.com/bbatsov/rubocop/issues/373) and [#376](https://github.com/bbatsov/rubocop/issues/376): Allow braces around multi-line blocks if `do`-`end` would change the meaning of the code.
327
349
  * `RedundantSelf` now allows `self.` followed by any ruby keyword.
328
350
  * [#391](https://github.com/bbatsov/rubocop/issues/391): Fix bug in counting slashes in a regexp.
329
351
  * [#394](https://github.com/bbatsov/rubocop/issues/394): `DotPosition` cop handles correctly code like `l.(1)`.
@@ -358,15 +380,15 @@
358
380
 
359
381
  ### Bugs fixed
360
382
 
361
- * [#288](https://github.com/bbatsov/rubocop/issues/288): work with absolute Excludes paths internally (2nd fix for this issue).
383
+ * [#288](https://github.com/bbatsov/rubocop/issues/288): Work with absolute Excludes paths internally (2nd fix for this issue).
362
384
  * `TrivialAccessors` now detects class attributes as well as instance attributes.
363
- * [#338](https://github.com/bbatsov/rubocop/issues/338): fix end alignment of blocks in chained assignments.
364
- * [#345](https://github.com/bbatsov/rubocop/issues/345): add `$SAFE` to the list of built-in global variables.
365
- * [#340](https://github.com/bbatsov/rubocop/issues/340): override config parameters rather than merging them.
366
- * [#349](https://github.com/bbatsov/rubocop/issues/349): fix false positive for `CharacterLiteral` (`%w(?)`).
367
- * [#346](https://github.com/bbatsov/rubocop/issues/346): support method chains for block end alignment checks.
368
- * [#350](https://github.com/bbatsov/rubocop/issues/350): support line breaks between variables on left hand side for block end alignment checks.
369
- * [#356](https://github.com/bbatsov/rubocop/issues/350): allow safe assignment in `ParenthesesAroundCondition`.
385
+ * [#338](https://github.com/bbatsov/rubocop/issues/338): Fix end alignment of blocks in chained assignments.
386
+ * [#345](https://github.com/bbatsov/rubocop/issues/345): Add `$SAFE` to the list of built-in global variables.
387
+ * [#340](https://github.com/bbatsov/rubocop/issues/340): Override config parameters rather than merging them.
388
+ * [#349](https://github.com/bbatsov/rubocop/issues/349): Fix false positive for `CharacterLiteral` (`%w(?)`).
389
+ * [#346](https://github.com/bbatsov/rubocop/issues/346): Support method chains for block end alignment checks.
390
+ * [#350](https://github.com/bbatsov/rubocop/issues/350): Support line breaks between variables on left hand side for block end alignment checks.
391
+ * [#356](https://github.com/bbatsov/rubocop/issues/356): Allow safe assignment in `ParenthesesAroundCondition`.
370
392
 
371
393
  ### Misc
372
394
 
@@ -387,8 +409,8 @@
387
409
 
388
410
  ### Bugs fixed
389
411
 
390
- * [#318](https://github.com/bbatsov/rubocop/issues/318): correct some special cases of block end alignment.
391
- * [#317](https://github.com/bbatsov/rubocop/issues/317): fix a false positive in `LiteralInCondition`.
412
+ * [#318](https://github.com/bbatsov/rubocop/issues/318): Correct some special cases of block end alignment.
413
+ * [#317](https://github.com/bbatsov/rubocop/issues/317): Fix a false positive in `LiteralInCondition`.
392
414
  * [#321](https://github.com/bbatsov/rubocop/issues/321): Ignore variables whose name start with `_` in `ShadowingOuterLocalVariable`.
393
415
  * [#322](https://github.com/bbatsov/rubocop/issues/322): Fix exception of `UnusedLocalVariable` and `ShadowingOuterLocalVariable` when inspecting keyword splat argument.
394
416
  * [#316](https://github.com/bbatsov/rubocop/issues/316): Correct nested postfix unless in `MultilineIfThen`.
@@ -440,19 +462,19 @@
440
462
 
441
463
  ### Bugs fixed
442
464
 
443
- * [#239](https://github.com/bbatsov/rubocop/issues/239): fixed double quotes false positives.
444
- * [#233](https://github.com/bbatsov/rubocop/issues/233): report syntax cop offences.
465
+ * [#239](https://github.com/bbatsov/rubocop/issues/239): Fixed double quotes false positives.
466
+ * [#233](https://github.com/bbatsov/rubocop/issues/233): Report syntax cop offences.
445
467
  * Fix off-by-one error in favor_modifier.
446
- * [#229](https://github.com/bbatsov/rubocop/issues/229): recognize a line with CR+LF as a blank line in AccessControl cop.
447
- * [#235](https://github.com/bbatsov/rubocop/issues/235): handle multiple constant assignment in ConstantName cop.
448
- * [#246](https://github.com/bbatsov/rubocop/issues/246): correct handling of unicode escapes within double quotes.
468
+ * [#229](https://github.com/bbatsov/rubocop/issues/229): Recognize a line with CR+LF as a blank line in AccessControl cop.
469
+ * [#235](https://github.com/bbatsov/rubocop/issues/235): Handle multiple constant assignment in ConstantName cop.
470
+ * [#246](https://github.com/bbatsov/rubocop/issues/246): Correct handling of unicode escapes within double quotes.
449
471
  * Fix crashes in Blocks, CaseEquality, CaseIndentation, ClassAndModuleCamelCase, ClassMethods, CollectionMethods, and ColonMethodCall.
450
- * [#263](https://github.com/bbatsov/rubocop/issues/263): do not check for space around operators called with method syntax.
451
- * [#271](https://github.com/bbatsov/rubocop/issues/271): always allow line breaks inside hash literal braces.
452
- * [#270](https://github.com/bbatsov/rubocop/issues/270): fixed a false positive in ParenthesesAroundCondition.
453
- * [#288](https://github.com/bbatsov/rubocop/issues/288): get config parameter AllCops/Excludes from highest config file in path.
454
- * [#276](https://github.com/bbatsov/rubocop/issues/276): let columns start at 1 instead of 0 in all output of column numbers.
455
- * [#292](https://github.com/bbatsov/rubocop/issues/292): don't check non-regular files (like sockets, etc).
472
+ * [#263](https://github.com/bbatsov/rubocop/issues/263): Do not check for space around operators called with method syntax.
473
+ * [#271](https://github.com/bbatsov/rubocop/issues/271): Always allow line breaks inside hash literal braces.
474
+ * [#270](https://github.com/bbatsov/rubocop/issues/270): Fixed a false positive in ParenthesesAroundCondition.
475
+ * [#288](https://github.com/bbatsov/rubocop/issues/288): Get config parameter AllCops/Excludes from highest config file in path.
476
+ * [#276](https://github.com/bbatsov/rubocop/issues/276): Let columns start at 1 instead of 0 in all output of column numbers.
477
+ * [#292](https://github.com/bbatsov/rubocop/issues/292): Don't check non-regular files (like sockets, etc).
456
478
  * Fix crashes in WordArray on arrays of character literals such as `[?\r, ?\n]`.
457
479
  * Fix crashes in Documentation on empty modules.
458
480
 
@@ -472,7 +494,7 @@
472
494
 
473
495
  * Correct calculation of whether a modifier version of a conditional statement will fit.
474
496
  * Fix an error in `MultilineIfThen` cop that occurred in some special cases.
475
- * [#231](https://github.com/bbatsov/rubocop/issues/231): fix a false positive for modifier if.
497
+ * [#231](https://github.com/bbatsov/rubocop/issues/231): Fix a false positive for modifier if.
476
498
 
477
499
  ## 0.8.1 (05/30/2013)
478
500
 
@@ -487,8 +509,8 @@
487
509
 
488
510
  ### Bugs fixed
489
511
 
490
- * [#210](https://github.com/bbatsov/rubocop/issues/210): fix a false positive for double quotes in regexp literals.
491
- * [#211](https://github.com/bbatsov/rubocop/issues/211): fix a false positive for `initialize` method looking like a trivial writer.
512
+ * [#210](https://github.com/bbatsov/rubocop/issues/210): Fix a false positive for double quotes in regexp literals.
513
+ * [#211](https://github.com/bbatsov/rubocop/issues/211): Fix a false positive for `initialize` method looking like a trivial writer.
492
514
  * [#215](https://github.com/bbatsov/rubocop/issues/215): Fixed a lot of modifier `if/unless/while/until` issues.
493
515
  * [#213](https://github.com/bbatsov/rubocop/issues/213): Make sure even disabled cops get their configuration set.
494
516
  * [#214](https://github.com/bbatsov/rubocop/issues/214): Fix SpaceInsideHashLiteralBraces to handle string interpolation right.
@@ -512,11 +534,11 @@
512
534
 
513
535
  ### Bugs fixed
514
536
 
515
- * [#155](https://github.com/bbatsov/rubocop/issues/155) 'Do not use semicolons to terminate expressions.' is not implemented correctly.
537
+ * [#155](https://github.com/bbatsov/rubocop/issues/155): 'Do not use semicolons to terminate expressions.' is not implemented correctly.
516
538
  * `OpMethod` now handles definition of unary operators without crashing.
517
539
  * `SymbolSnakeCase` now handles aliasing of operators without crashing.
518
540
  * `RescueException` now handles the splat operator `*` in a `rescue` clause without crashing.
519
- * [#159](https://github.com/bbatsov/rubocop/issues/159) AvoidFor cop misses many violations.
541
+ * [#159](https://github.com/bbatsov/rubocop/issues/159): AvoidFor cop misses many violations.
520
542
 
521
543
  ## 0.7.1 (05/11/2013)
522
544
 
@@ -538,7 +560,7 @@
538
560
  * New cop `BlockComments` tracks uses of block comments(`=begin/=end` comments).
539
561
  * New cop `EmptyLines` tracks consecutive blank lines.
540
562
  * New cop `WordArray` tracks arrays of words.
541
- * [#108](https://github.com/bbatsov/rubocop/issues/108) New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable.
563
+ * [#108](https://github.com/bbatsov/rubocop/issues/108): New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable.
542
564
  * New cop `LineContinuation` tracks uses of the line continuation character (`\`).
543
565
  * New cop `SymbolArray` tracks arrays of symbols.
544
566
  * Print warnings for unrecognized names in configuration files.
@@ -552,14 +574,14 @@
552
574
 
553
575
  ### Bugs fixed
554
576
 
555
- * [#101](https://github.com/bbatsov/rubocop/issues/101) `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string.
577
+ * [#101](https://github.com/bbatsov/rubocop/issues/101): `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string.
556
578
  * Fix `BraceAfterPercent` for `%W`, `%i` and `%I` and added more tests.
557
579
  * Fix a false positive in the `Alias` cop. `:alias` is no longer treated as keyword.
558
580
  * `ArrayLiteral` now properly detects `Array.new`.
559
581
  * `HashLiteral` now properly detects `Hash.new`.
560
582
  * `VariableInterpolation` now detects regexp back references and doesn't crash.
561
583
  * Don't generate pathnames like some/project//some.rb.
562
- * [#151](https://github.com/bbatsov/rubocop/issues/151) Don't print the unrecognized cop warning several times for the same `.rubocop.yml`.
584
+ * [#151](https://github.com/bbatsov/rubocop/issues/151): Don't print the unrecognized cop warning several times for the same `.rubocop.yml`.
563
585
 
564
586
  ### Misc
565
587
 
@@ -574,15 +596,15 @@
574
596
 
575
597
  ### Bugs fixed
576
598
 
577
- * [#90](https://github.com/bbatsov/rubocop/issues/90) Two cops crash when scanning code using `super`.
578
- * [#93](https://github.com/bbatsov/rubocop/issues/93) Issue with `whitespace?': undefined method`.
579
- * [#97](https://github.com/bbatsov/rubocop/issues/97) Build fails.
580
- * [#100](https://github.com/bbatsov/rubocop/issues/100) `OpMethod` cop doesn't work if method arg is not in braces.
599
+ * [#90](https://github.com/bbatsov/rubocop/issues/90): Two cops crash when scanning code using `super`.
600
+ * [#93](https://github.com/bbatsov/rubocop/issues/93): Issue with `whitespace?': undefined method`.
601
+ * [#97](https://github.com/bbatsov/rubocop/issues/97): Build fails.
602
+ * [#100](https://github.com/bbatsov/rubocop/issues/100): `OpMethod` cop doesn't work if method arg is not in braces.
581
603
  * `SymbolSnakeCase` now tracks Ruby 1.9 hash labels as well as regular symbols.
582
604
 
583
605
  ### Misc
584
606
 
585
- * [#88](https://github.com/bbatsov/rubocop/issues/88) Abort gracefully when interrupted with Ctrl-C.
607
+ * [#88](https://github.com/bbatsov/rubocop/issues/88): Abort gracefully when interrupted with Ctrl-C.
586
608
  * No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed.
587
609
  * Replaced `Term::ANSIColor` with `Rainbow`.
588
610
  * Add an option to disable colors in the output.
@@ -656,3 +678,4 @@
656
678
  [@skanev]: http://github.com/skanev
657
679
  [@claco]: http://github.com/claco
658
680
  [@rifraf]: http://github.com/rifraf
681
+ [@scottmatthewman]: https://github.com/scottmatthewman
@@ -13,7 +13,7 @@ do so.
13
13
  * Be clear, concise and precise in your description of the problem.
14
14
  * Open an issue with a descriptive title and a summary in grammatically correct,
15
15
  complete sentences.
16
- * Include the output of `rubocop -v`:
16
+ * Include the output of `rubocop -V`:
17
17
 
18
18
  ```
19
19
  $ rubocop -V
@@ -32,7 +32,7 @@ $ rubocop -V
32
32
  * Commit and push until you are happy with your contribution.
33
33
  * Make sure to add tests for it. This is important so I don't break it
34
34
  in a future version unintentionally.
35
- * Update the [Changelog](CHANGELOG.md) accordingly.
35
+ * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
36
36
  * Please try not to mess with the Rakefile, version, or history. If
37
37
  you want to have your own version, or is otherwise necessary, that
38
38
  is fine, but please isolate to its own commit so I can cherry-pick
@@ -43,8 +43,25 @@ $ rubocop -V
43
43
  * Open a [pull request][4] that relates to *only* one subject with a clear title
44
44
  and description in grammatically correct, complete sentences.
45
45
 
46
- [1]: https://github.com/clojure-emacs/cider/issues
46
+ ### Changelog entry format
47
+
48
+ Here are a few examples:
49
+
50
+ ```
51
+ * [#716](https://github.com/bbatsov/rubocop/issues/716): Fixed a regression in the auto-correction logic of `MethodDefParentheses`. ([@bbatsov][])
52
+ * New cop `ElseLayout` checks for odd arrangement of code in the `else` branch of a conditional expression. ([@bbatsov][])
53
+ ```
54
+
55
+ * Mark it up in [Markdown syntax][6].
56
+ * The entry line should start with `* ` (an asterisk and a space).
57
+ * If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/bbatsov/rubocop/issues/123): `.
58
+ * Describe the brief of the change. The sentence should end with a punctuation.
59
+ * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
60
+ * If this is your first contribution to RuboCop project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
61
+
62
+ [1]: https://github.com/bbatsov/rubocop/issues
47
63
  [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
48
64
  [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
49
65
  [4]: https://help.github.com/articles/using-pull-requests
50
66
  [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
67
+ [6]: http://daringfireball.net/projects/markdown/syntax
@@ -241,6 +241,10 @@ LeadingCommentSpace:
241
241
  Description: 'Comments should start with a space.'
242
242
  Enabled: true
243
243
 
244
+ LineEndConcatenation:
245
+ Description: 'Use \\ instead of + to concatenate two string literals at line end.'
246
+ Enabled: true
247
+
244
248
  LineLength:
245
249
  Description: 'Limit lines to 79 characters.'
246
250
  Enabled: true
@@ -581,6 +585,12 @@ ParenthesesAsGroupedExpression:
581
585
  parenthesis.
582
586
  Enabled: true
583
587
 
588
+ RequireParentheses:
589
+ Description: >-
590
+ Use parentheses in the method call to avoid confusion
591
+ about precedence.
592
+ Enabled: true
593
+
584
594
  RescueException:
585
595
  Description: 'Avoid rescuing the Exception class.'
586
596
  Enabled: true
@@ -1,6 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'rainbow'
4
+ # Rainbow 2.0 does not load the monkey-patch for String by default.
5
+ require 'rainbow/ext/string' unless String.method_defined?(:color)
6
+
4
7
  require 'English'
5
8
  require 'set'
6
9
  require 'parser/current'
@@ -9,6 +12,8 @@ require 'powerpack'
9
12
 
10
13
  require 'rubocop/version'
11
14
 
15
+ require 'rubocop/path_util'
16
+
12
17
  require 'rubocop/cop/util'
13
18
  require 'rubocop/cop/offence'
14
19
  require 'rubocop/cop/ignored_node'
@@ -62,6 +67,7 @@ require 'rubocop/cop/lint/literal_in_condition'
62
67
  require 'rubocop/cop/lint/loop'
63
68
  require 'rubocop/cop/lint/parentheses_as_grouped_expression'
64
69
  require 'rubocop/cop/lint/rescue_exception'
70
+ require 'rubocop/cop/lint/require_parentheses'
65
71
  require 'rubocop/cop/lint/shadowing_outer_local_variable'
66
72
  require 'rubocop/cop/lint/syntax'
67
73
  require 'rubocop/cop/lint/unreachable_code'
@@ -127,6 +133,7 @@ require 'rubocop/cop/style/indentation_width'
127
133
  require 'rubocop/cop/style/lambda'
128
134
  require 'rubocop/cop/style/lambda_call'
129
135
  require 'rubocop/cop/style/leading_comment_space'
136
+ require 'rubocop/cop/style/line_end_concatenation'
130
137
  require 'rubocop/cop/style/line_length'
131
138
  require 'rubocop/cop/style/method_call_parentheses'
132
139
  require 'rubocop/cop/style/method_called_on_do_end_block'
@@ -162,19 +162,10 @@ module Rubocop
162
162
  private
163
163
 
164
164
  def buffer_name_matches_any?(parameter, default_result)
165
- paths = cop_config && cop_config[parameter]
166
- return default_result unless paths
167
- paths.any? { |path| match_path?(path, processed_source.buffer.name) }
168
- end
169
-
170
- def match_path?(pattern, path)
171
- case pattern
172
- when String
173
- basename = File.basename(path)
174
- basename == pattern || File.fnmatch(pattern, basename)
175
- when Regexp
176
- path =~ pattern
177
- end
165
+ patterns = cop_config && cop_config[parameter]
166
+ return default_result unless patterns
167
+ path = relative_path(processed_source.buffer.name)
168
+ patterns.any? { |pattern| match_path?(pattern, path) }
178
169
  end
179
170
 
180
171
  def disabled_line?(line_number)
@@ -28,7 +28,7 @@ module Rubocop
28
28
  hash[:operator] = key
29
29
  end
30
30
 
31
- MSG_FORMAT = 'Ambiguous %{actual} operator. Parenthesize the method ' +
31
+ MSG_FORMAT = 'Ambiguous %{actual} operator. Parenthesize the method ' \
32
32
  "arguments if it's surely a %{actual} operator, or add " +
33
33
  'a whitespace to the right of the %{operator} if it ' +
34
34
  'should be a %{possible}.'
@@ -17,7 +17,7 @@ module Rubocop
17
17
  class AmbiguousRegexpLiteral < Cop
18
18
  include ParserDiagnostic
19
19
 
20
- MSG = 'Ambiguous regexp literal. Parenthesize the method arguments ' +
20
+ MSG = 'Ambiguous regexp literal. Parenthesize the method arguments ' \
21
21
  "if it's surely a regexp literal, or add a whitespace to the " +
22
22
  'right of the / if it should be a division.'
23
23
 
@@ -5,7 +5,7 @@ module Rubocop
5
5
  module Lint
6
6
  # This cop checks for uses of *begin...end while/until something*.
7
7
  class Loop < Cop
8
- MSG = 'Use Kernel#loop with break rather than ' +
8
+ MSG = 'Use Kernel#loop with break rather than ' \
9
9
  'begin/end/until(or while).'
10
10
 
11
11
  def on_while_post(node)
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ module Rubocop
4
+ module Cop
5
+ module Lint
6
+ # This cop checks for expressions where there is a call to a predicate
7
+ # method with at least one argument, where no parentheses are used around
8
+ # the parameter list, and a boolean operator, && or ||, is used in the
9
+ # last argument.
10
+ #
11
+ # The idea behind warning for these constructs is that the user might
12
+ # be under the impression that the return value from the method call is
13
+ # an operand of &&/||.
14
+ #
15
+ # @example
16
+ #
17
+ # if day.is? :tuesday && month == :jan
18
+ # ...
19
+ # end
20
+ class RequireParentheses < Cop
21
+ include IfNode
22
+
23
+ MSG = 'Use parentheses in the method call to avoid confusion about ' \
24
+ 'precedence.'
25
+
26
+ def on_send(node)
27
+ _receiver, method_name, *args = *node
28
+
29
+ return if parentheses?(node)
30
+ return if args.empty?
31
+
32
+ if ternary_op?(args.first)
33
+ check_ternary(args.first, node)
34
+ else
35
+ # We're only checking predicate methods. There would be false
36
+ # positives otherwise.
37
+ check_send(args.last, node) if predicate?(method_name)
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def check_ternary(arg, node)
44
+ condition, _, _ = *arg
45
+ if offence?(condition)
46
+ expr = node.loc.expression
47
+ range = Parser::Source::Range.new(expr.source_buffer,
48
+ expr.begin_pos,
49
+ condition.loc.expression.end_pos)
50
+ add_offence(range, range)
51
+ end
52
+ end
53
+
54
+ def check_send(arg, node)
55
+ add_offence(node, :expression) if offence?(arg)
56
+ end
57
+
58
+ def predicate?(method_name)
59
+ method_name =~ /\w\?$/
60
+ end
61
+
62
+ def parentheses?(node)
63
+ node.loc.respond_to?(:end) && !!node.loc.end
64
+ end
65
+
66
+ def offence?(node)
67
+ [:and, :or].include?(node.type)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end