Fixed Style/PerlBackrefs RuboCop offense
authorŽeljko Filipin <zeljko.filipin@gmail.com>
Wed, 18 Mar 2015 17:52:02 +0000 (18:52 +0100)
committerDan Duvall <dduvall@wikimedia.org>
Mon, 23 Mar 2015 18:11:13 +0000 (11:11 -0700)
Refactored to use `Regexp#match`, avoiding use of match globals
entirely.

Bug: T91485
Change-Id: I4b1a40e153c18d92ef9e78291bc4e14781cc6978

.rubocop.yml
.rubocop_todo.yml
maintenance/jsduck/custom_tags.rb

index 3f1af39..8b0f91a 100644 (file)
@@ -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:
index 6c84b52..97ef233 100644 (file)
 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.
index 9130227..a1f37e4 100644 (file)
@@ -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)