Closed bnkamalesh closed 9 months ago
Hello,
your issue is not clear: do you mean that ignore-words
doesn't work?
Hello @ldez , thank you for the quick response and sorry for the confusion.
ignore-words
is working as expected. The expected behaviour of misspell should only be correcting comments, but in this case it corrected a constant's name, which was imported from an external package.
The expected behaviour of misspell should only be correcting comments
I understand that can be surprising because it's a constant from another module but misspell checks all the code, neither just comments nor just code "own" by the current module, so the current behavior is expected.
The ignore-words
is a solution but you can use different solutions based on exclusions like nolint
.
func main() {
//nolint:misspell
fmt.Println(lib.Status_STATUS_CANCELLED)
}
Hello @ldez , I think there's some miscommunication if the expected behaviour of misspell is to correct any tokens. Because in the Readme it is mentioned explicitly
Are there special rules for golang source files? Yes! If the file ends in .go, then misspell will only check spelling in comments.
And it does make sense to have this behaviour as auto-correcting spellings of tokens would easily break our applications.
The misspell
readme says something wrong: the scope of the analysis is not related to file extension but to a specific mode, and the default mode is neither related to Go nor file extension.
This mode is related to a CLI flag (-source
) and the doc of this flag is also wrong and misleading.
The doc of this flag says that there are 3 modes but, in the reality of the code, there are only 2: text
(default) and go
.
I also think that the go
mode is misleading because it's not expected that a mode related to go
only checks comments.
The current behavior of misspell
inside golangci-lint is related to user's feedback (from 2019) https://github.com/golangci/golangci-lint/issues/522
EDIT: I fixed the documentation (readme and CLI flags) of misspell
.
@ldez thanks for the clarification, and the quick responses are much appreciated. I'm closing the thread/issue as I believe it is solved.
@bnkamalesh I will add an option inside golangci-lint to handle the mode.
Misspell linter corrected a constant's name which was imported from a protobuff generated package. The problematic constant name
Status_STATUS_CANCELLED
, was corrected to a single L. This broke our CI as well, becauseautofix: true
is the default setting.Ref: https://github.com/microsoft/vscode/issues/200638 https://github.com/golang/vscode-go/issues/3087
Below I have provided the configuration of misspell.
p.s: I added the respective word as a config under
ignore-words
as a work around.