From 762249868136febf62bc118571bd5abf5748d213 Mon Sep 17 00:00:00 2001 From: Tejas Bubane Date: Thu, 10 Sep 2020 10:19:24 +0530 Subject: [PATCH] [Fix #8684] Fix an error for `Lint/InterpolationCheck` cop Closes https://github.com/rubocop-hq/rubocop/issues/8684 --- changelog/fix_fix_an_error_for_lintinterpolationcheck.md | 1 + lib/rubocop/cop/lint/interpolation_check.rb | 9 +++++++-- spec/rubocop/cop/lint/interpolation_check_spec.rb | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 changelog/fix_fix_an_error_for_lintinterpolationcheck.md diff --git a/changelog/fix_fix_an_error_for_lintinterpolationcheck.md b/changelog/fix_fix_an_error_for_lintinterpolationcheck.md new file mode 100644 index 00000000000..59819ab1a64 --- /dev/null +++ b/changelog/fix_fix_an_error_for_lintinterpolationcheck.md @@ -0,0 +1 @@ +* [#8684](https://github.com/rubocop-hq/rubocop/issues/8684): Fix an error for `Lint/InterpolationCheck` cop. ([@tejasbubane][]) diff --git a/lib/rubocop/cop/lint/interpolation_check.rb b/lib/rubocop/cop/lint/interpolation_check.rb index 70d3fa9e02a..b6edc43e490 100644 --- a/lib/rubocop/cop/lint/interpolation_check.rb +++ b/lib/rubocop/cop/lint/interpolation_check.rb @@ -23,10 +23,11 @@ class InterpolationCheck < Base 'Use double quoted strings if you need interpolation.' def on_str(node) - parent = node.parent - return if parent && (parent.dstr_type? || parent.regexp_type?) + return unless node + return if string_or_regex?(node.parent) return unless /(?