Empty character classes should not be used in regular expressions

  • BAD_REGEXP
  • Error
  • Medium
  • No tags

This rule applies when a regular expression has empty character classes.

Because empty character classes '[]' in regular expressions do not match anything, they are not likely to be a programmer's intent.

Noncompliant Code Example

var foo = /^abc[]/;

Compliant Code Example

var foo = /^abc/;
var bar = /^abc[a-z]/;

Version

This rule was introduced in DeepScan 1.0.0-alpha.

See