golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.43k stars 1.38k forks source link

misspell: support multiple correction words #4834

Closed alexandear closed 3 months ago

alexandear commented 3 months ago

Allows to have multiple corrections.

extra-words.correction can accept either a single word or a list of words separated by commas:

linters-settings:
  misspell:
    extra-words:
      - typo: "iff"
        correction: "if"
      - typo: "successed"
        correction: "successful,success,succeeded"

When a misspelling is detected, the following lint message is displayed:

`successed` is a misspelling of `successful,success,succeeded`

However, during the fix process, only the first word in the list of corrections is used: "successed" is replaced with "successful".

The feature was requested in Slack discussion.

ldez commented 3 months ago

I declined this PR because misspell is made to match one word with another.

The fact of picking the first one proves that this is not adapted.

I can see several problems:

misspell is not a real typo detector, it's more an opiniated linter based on a set of known typos. A known typo is a tuple of one misspelled word and one correction. Because it's a misspelled word, the correction is also known.