From 778375186426aa52641a26e39e314cbfc56c9d9d Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Sun, 22 Mar 2020 00:16:46 +0800 Subject: [PATCH] [Fix #7236] Prevent bad auto-correction from Style/InverseMethods and Style/SymbolProc (#7243) These two cops had an interaction between their auto-corrections which produced code that wasn't semantically equivalent to the original. This change fixes that by marking `Style/InverseMethods` auto-correct as incompatible with that of `Style/SymbolProc`. --- CHANGELOG.md | 1 + lib/rubocop/cop/style/inverse_methods.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1510762aa2b..46f0d1f4a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -247,6 +247,7 @@ * [#6861](https://github.com/rubocop-hq/rubocop/issues/6861): Fix a false positive for `Layout/IndentationWidth` when using `EnforcedStyle: outdent` of `Layout/AccessModifierIndentation`. ([@koic][]) * [#7235](https://github.com/rubocop-hq/rubocop/issues/7235): Fix an error where `Style/ConditionalAssignment` would swallow a nested `if` condition. ([@buehmann][]) * [#7242](https://github.com/rubocop-hq/rubocop/issues/7242): Make `Style/ConstantVisibility` work on non-trivial class and module bodies. ([@buehmann][]) +* [#7236](https://github.com/rubocop-hq/rubocop/pull/7236): Mark `Style/InverseMethods` auto-correct as incompatible with `Style/SymbolProc`. ([@drenmi][]) ### Changes diff --git a/lib/rubocop/cop/style/inverse_methods.rb b/lib/rubocop/cop/style/inverse_methods.rb index d437b6e1a08..79ed0d2df24 100644 --- a/lib/rubocop/cop/style/inverse_methods.rb +++ b/lib/rubocop/cop/style/inverse_methods.rb @@ -44,7 +44,7 @@ class InverseMethods < Cop CAMEL_CASE = /[A-Z]+[a-z]+/.freeze def self.autocorrect_incompatible_with - [Style::Not] + [Style::Not, Style::SymbolProc] end def_node_matcher :inverse_candidate?, <<~PATTERN