1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00

Filename-format rule: fix filename extension regex: ".go" to "\\.go". (#1132)

This commit is contained in:
Väinö Leppänen
2024-11-16 17:12:26 +02:00
committed by GitHub
parent 660968fda3
commit dff4dc9495
4 changed files with 5 additions and 5 deletions

View File

@@ -521,7 +521,7 @@ Example:
```
## filename-format
_Description_: enforces conventions on source file names. By default, the rule enforces filenames of the form `^[_A-Za-z0-9][_A-Za-z0-9-]*.go$`: Optionally, the rule can be configured to enforce other forms.
_Description_: enforces conventions on source file names. By default, the rule enforces filenames of the form `^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$`: Optionally, the rule can be configured to enforce other forms.
_Configuration_: (string) regular expression for source filenames.
@@ -529,7 +529,7 @@ Example:
```toml
[rule.filename-format]
arguments=["^[_a-z][_a-z0-9]*.go$"]
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
```
## flag-parameter

View File

@@ -21,7 +21,7 @@ warningCode = 1
[rule.exported]
[rule.filename-format]
# Override the default pattern to forbid .go files with uppercase letters and dashes.
arguments=["^[_a-z][_a-z0-9]*.go$"]
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
[rule.increment-decrement]
[rule.indent-error-flow]
[rule.line-length-limit]

View File

@@ -53,7 +53,7 @@ func (*FilenameFormatRule) Name() string {
return "filename-format"
}
var defaultFormat = regexp.MustCompile("^[_A-Za-z0-9][_A-Za-z0-9-]*.go$")
var defaultFormat = regexp.MustCompile(`^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$`)
func (r *FilenameFormatRule) configure(arguments lint.Arguments) {
argsCount := len(arguments)

View File

@@ -1,3 +1,3 @@
package main
// MATCH:1 /Filename filenamе_with_non_ascii_char.go is not of the format ^[_A-Za-z0-9][_A-Za-z0-9-]*.go$. Non ASCII character е (U+0435) found./
// MATCH:1 /Filename filenamе_with_non_ascii_char.go is not of the format ^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$. Non ASCII character е (U+0435) found./