golangci / misspell

Correct commonly misspelled English words in source files
MIT License
22 stars 11 forks source link

Adding new words #16

Closed silverwind closed 6 months ago

silverwind commented 6 months ago

I'd like to add new words, but words.go has a DO NOT EDIT comment, while it actually seems to have been edited in the past. Is it ok to edit?

I would like to add these words found in the gitea codebase, hopefully all unambiguous:

acounts,accounts
canidate,candidate
comfirm,confirm
commiter,committer
converage,coverage
currrently,currently
delimeter,delimiter
differrent,different
exclusing,excluding
finshed,finished
formated,formatted
inderect,indirect
insuficient,insufficient
likly,likely
mergable,mergeable
overrided,overridden
priortized,prioritized
registeration,registration
reuqest,request
reviwer,reviewer
superceded,superseded
underlaying,underlying
ccoVeille commented 6 months ago

You are joining me somehow with the ticket I opened #15

ldez commented 6 months ago

Is it ok to edit?

word.go is generated, so this should not be edited.

Inside golangci-lint, you should use extra-words.

https://golangci-lint.run/usage/linters/#misspell

silverwind commented 6 months ago

I wanted to contribute the new words to the project so all users can benefit. If you check the history of words.go, it was edited multiple times in the past:

https://github.com/golangci/misspell/commits/master/words.go

silverwind commented 6 months ago

PS: extra-words does not work for our use case because we run misspell standalone and lint various non-go files as well, so it would have to be made an option to misspell itself.

ccoVeille commented 6 months ago

PS: extra-words does not work for our use case because we run misspell standalone and lint various non-go files as well, so it would have to be made an option to misspell itself.

if you are using misspell as a standalone thing, so maybe outside a Go tool, I would like you to look at the following projects:

And if you have a need to code something in golang, you can use misspell.Replacer.AddRules

https://github.com/golangci/misspell/blob/fd7b9c19e1ad76725ab4dde024afb12457cf1539/replace.go#L70-L76

silverwind commented 6 months ago

I had a look at some of these projects, but my experience so far is that they are too aggressive and often require an extensive configuration which would be a nightmare to maintain.

I do like misspell because it does produce reasonably good results without any configuration.

Yes, I will consider running misspell in go, but would prefer if there were a CLI flag to supply extra words.

ldez commented 6 months ago

If you check the history of words.go, it was edited multiple times in the past:

Yes, but the commits that are not by the original author were backported of PRs from the original repo and IMO this was an error. This file should not be modified by hand.

we run misspell standalone

I will think about a CLI flag to define a path to a list of external words.

ccoVeille commented 6 months ago

I had a look at some of these projects, but my experience so far is that they are too aggressive and often require an extensive configuration which would be a nightmare to maintain.

I do like misspell because it does produce reasonably good results without any configuration.

I agree with you about cspell and vale. But you should take a look at typos it works very well, same for codespell.

silverwind commented 6 months ago

I had a look at some of these projects, but my experience so far is that they are too aggressive and often require an extensive configuration which would be a nightmare to maintain. I do like misspell because it does produce reasonably good results without any configuration.

I agree with you about cspell and vale. But you should take a look at typos it works very well, same for codespell.

Thanks, will check out typos.

The last time I tried codespell required a ton of configuration, even with it's clear dictionary. For example, it flagged var names like crossReference to be renamed to cross-reference which would be an invalid identifier in golang. So I do not consider it currently.

ldez commented 6 months ago

I added a new option -dict: the option takes a path to a CSV file.

config.example.csv ```csv acounts,accounts canidate,candidate comfirm,confirm commiter,committer converage,coverage currrently,currently delimeter,delimiter differrent,different exclusing,excluding finshed,finished formated,formatted inderect,indirect insuficient,insufficient likly,likely mergable,mergeable overrided,overridden priortized,prioritized registeration,registration reuqest,request reviwer,reviewer superceded,superseded underlaying,underlying ```
$ misspell -dict config.example.csv ./temp
temp/temp.go:4:4: "acounts" is a misspelling of "accounts"
temp/temp.go:5:4: "canidate" is a misspelling of "candidate"
temp/temp.go:6:4: "comfirm" is a misspelling of "confirm"
temp/temp.go:7:4: "commiter" is a misspelling of "committer"
temp/temp.go:8:4: "converage" is a misspelling of "coverage"
temp/temp.go:9:4: "currrently" is a misspelling of "currently"
temp/temp.go:10:4: "delimeter" is a misspelling of "delimiter"
temp/temp.go:11:4: "differrent" is a misspelling of "different"
temp/temp.go:12:4: "exclusing" is a misspelling of "excluding"
temp/temp.go:13:4: "finshed" is a misspelling of "finished"
temp/temp.go:14:4: "formated" is a misspelling of "formatted"
temp/temp.go:15:4: "inderect" is a misspelling of "indirect"
temp/temp.go:16:4: "insuficient" is a misspelling of "insufficient"
temp/temp.go:17:4: "likly" is a misspelling of "likely"
temp/temp.go:18:4: "mergable" is a misspelling of "mergeable"
temp/temp.go:19:4: "overrided" is a misspelling of "overridden"
temp/temp.go:20:4: "priortized" is a misspelling of "prioritized"
temp/temp.go:21:4: "registeration" is a misspelling of "registration"
temp/temp.go:22:4: "reuqest" is a misspelling of "request"
temp/temp.go:23:4: "reviwer" is a misspelling of "reviewer"
temp/temp.go:24:4: "superceded" is a misspelling of "superseded"
temp/temp.go:25:4: "underlaying" is a misspelling of "underlying"
silverwind commented 6 months ago

Awesome, thanks!

ccoVeille commented 6 months ago

Great ! thanks @ldez