Skip to content

Files

Latest commit

 

History

History
25 lines (17 loc) · 519 Bytes

Style-RedundantRegexpConstructor.md

File metadata and controls

25 lines (17 loc) · 519 Bytes

Pattern: Redundant Regexp constructor

Issue: -

Description

Checks for the instantiation of Regexp using redundant Regexp.new or Regexp.compile. Autocorrect replaces to Regexp literal which is the simplest and fastest.

Examples

# bad
Regexp.new(/regexp/)
Regexp.compile(/regexp/)

# good
/regexp/
Regexp.new('regexp')
Regexp.compile('regexp')

Further Reading