Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RULES_DESCRIPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ 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.

Example:

```toml
[rule.filename-format]
arguments=["^[_a-z][_a-z0-9]*.go$"]
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
```

## flag-parameter
Expand Down
2 changes: 1 addition & 1 deletion revive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion rule/filename_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion testdata/filenamе_with_non_ascii_char.go
Original file line number Diff line number Diff line change
@@ -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./