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

Adding new words #16

Closed
silverwind opened this issue Apr 18, 2024 · 12 comments
Closed

Adding new words #16

silverwind opened this issue Apr 18, 2024 · 12 comments
Labels
question Further information is requested

Comments

@silverwind
Copy link

silverwind commented Apr 18, 2024

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
Copy link

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

@ldez ldez added the question Further information is requested label Apr 18, 2024
@ldez
Copy link
Member

ldez commented Apr 18, 2024

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

@ldez ldez closed this as completed Apr 18, 2024
@silverwind
Copy link
Author

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
Copy link
Author

silverwind commented Apr 18, 2024

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
Copy link

ccoVeille commented Apr 18, 2024

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

misspell/replace.go

Lines 70 to 76 in fd7b9c1

// AddRuleList appends new rules.
// Input is in the same form as Strings.Replacer: [ old1, new1, old2, new2, ....]
// Note: does not check for duplicates.
func (r *Replacer) AddRuleList(additions []string) {
r.engine = nil
r.Replacements = append(r.Replacements, additions...)
}

@silverwind
Copy link
Author

silverwind commented Apr 18, 2024

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
Copy link
Member

ldez commented Apr 18, 2024

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
Copy link

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
Copy link
Author

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
Copy link
Member

ldez commented Apr 18, 2024

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

config.example.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
Copy link
Author

Awesome, thanks!

@ccoVeille
Copy link

Great ! thanks @ldez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants