Code Inspections in RegExp
This topic lists all GoLand code inspections available in RegExp.
|Anonymous capturing group or numeric back reference|| |
Reports anonymous capturing groups and numeric back references in a RegExp. These are only reported when the RegExp dialect supports named group and named group references. Named groups and named back references improve code readability and are recommended to use instead. When a capture is not needed, matching can be more performant and use less memory by using a non-capturing group, i.e. (?:xxx) instead of (xxx).
|Begin or end anchor in unexpected position|| |
|Consecutive spaces|| |
Reports multiple consecutive spaces in a RegExp. Because spaces are not visible by default, it can be hard to see how many spaces are required. The RegExp can be made more clear by replacing the consecutive spaces with a single space and a counted quantifier.
|Duplicate branch in alternation|| |
Reports duplicate branches in a RegExp alternation. For example
|Empty branch in alternation|| |
Reports empty branches in a RegExp alternation. For example:
|Escaped meta character|| |
Reports the escaped meta characters, e.g.
|Octal escape|| |
Reports octal escapes, which are easily confused with back references. Use hexadecimal escapes to avoid confusion.
|Redundant character escape|| |
Reports character escapes that are replaceable with the unescaped character without a change in meaning. Note that inside the square brackets of a character class, many escapes are unnecessary that would be necessary outside of a character class. For example the regex
|Single character alternation|| |
Reports single char alternation (e.g.