From 97b06ddd7c815d38cda69b9770b7ae1021f7dc22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=BDeljko=20Filipin?= Date: Wed, 18 Mar 2015 18:52:02 +0100 Subject: [PATCH] Fixed Style/PerlBackrefs RuboCop offense Refactored to use `Regexp#match`, avoiding use of match globals entirely. Bug: T91485 Change-Id: I4b1a40e153c18d92ef9e78291bc4e14781cc6978 --- .rubocop.yml | 12 +++++------- .rubocop_todo.yml | 5 ----- maintenance/jsduck/custom_tags.rb | 14 +++++++++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3f1af395be..8b0f91abfe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,11 @@ inherit_from: .rubocop_todo.yml AllCops: - Exclude: - - 'extensions/**/*' - - 'skins/**/*' - - 'tests/frontend/node_modules/**/*' - - 'vendor/**/*' - -AllCops: + Exclude: + - 'extensions/**/*' + - 'skins/**/*' + - 'tests/frontend/node_modules/**/*' + - 'vendor/**/*' StyleGuideCopsOnly: true Metrics/LineLength: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c84b527e0..97ef2333a7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -11,11 +11,6 @@ Style/HashSyntax: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -Style/PerlBackrefs: - Enabled: false - # Offense count: 81 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/maintenance/jsduck/custom_tags.rb b/maintenance/jsduck/custom_tags.rb index 9130227261..a1f37e4a3a 100644 --- a/maintenance/jsduck/custom_tags.rb +++ b/maintenance/jsduck/custom_tags.rb @@ -72,9 +72,11 @@ class SeeTag < CommonTag end def render_long_see(tag, formatter, position) - if tag =~ /\A([^\s]+)( .*)?\Z/m - name = $1 - doc = $2 ? ': ' + $2 : '' + match = /\A([^\s]+)( .*)?\Z/m.match(tag) + + if match + name = match[1] + doc = match[2] ? ': ' + match[2] : '' return formatter.format("{@link #{name}} #{doc}") else JsDuck::Logger.warn(nil, 'Unexpected @see argument: "' + tag + '"', position) @@ -105,8 +107,10 @@ class ContextTag < CommonTag end def render_long_context(tag, formatter, position) - if tag =~ /\A([^\s]+)/m - name = $1 + match = /\A([^\s]+)/m.match(tag) + + if match + name = match[1] return formatter.format("`context` : {@link #{name}}") else JsDuck::Logger.warn(nil, 'Unexpected @context argument: "' + tag + '"', position) -- 2.20.1