From 5e9c69700d66f6693fdd0a84d62480f1ff705eae Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Fri, 25 Apr 2025 01:38:40 +0200 Subject: [PATCH 1/8] ci: add typos detection in GitHub actions --- .github/workflows/typos.yml | 12 ++++++++++++ typos.toml | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/typos.yml create mode 100644 typos.toml diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 000000000..239f8962a --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,12 @@ +name: Typos Check +on: + push: + pull_request: +jobs: + typos: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: typos-action + uses: crate-ci/typos@v1.31.2 \ No newline at end of file diff --git a/typos.toml b/typos.toml new file mode 100644 index 000000000..aea29c0c3 --- /dev/null +++ b/typos.toml @@ -0,0 +1,23 @@ +[default] +locale = "en-us" +extend-ignore-re=[ + # UID and equivalent + "[A-Za-z0-9=_-]{30,}", + +] + +# List of words that are ignored +# Please add a comment about why they are ignored +[default.extend-words] +#ba = "ba" # short variable name +datas = "datas" # common errors on datum/data plural, but too many to fix +mosquitto = "mosquitto" # this is a MQQT broker +IIT = "IIT" # Indian Institute of Technology + +[files] +# excluded file +extend-exclude = [ + "go.sum","go.mod", # go.sum and go.mod contains URLs with hash, they can provide false positive + "vendor", # not my dragon + "pkg/gofr/static/swagger*", + ] From 9fb3231ac07bc27a419c407e0f0a815ddc9a536c Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:26:32 +0200 Subject: [PATCH 2/8] ci: configure .typos.toml The configuration was updated to include the following: - ability to ignore specific line - ability to ignore block of code We can then disable the check in CONTRIBUTING.md file, which mentioned "favour" as British English spelling that should be avoided. We had to handle the exception. --- CONTRIBUTING.md | 2 ++ pkg/gofr/http/multipart_file_bind_test.go | 6 ++++-- typos.toml | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87b93c7f1..e6183a7d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,9 @@ * (Optional) If you want to discuss your implementation with the users of GoFr, use the GitHub discussions of this repo. * Configure your editor to use goimport and golangci-lint on file changes. Any code which is not formatted using these tools, will fail on the pipeline. + * We follow **American English** conventions in this project (e.g., *"favor"* instead of *"favour"*). Please keep this consistent across all code comments, documentation, etc. + * All code contributions should have associated tests and all new line additions should be covered in those testcases. No PR should ever decrease the overall code coverage. * Once your code changes are done along with the testcases, submit a PR to development branch. Please note that all PRs diff --git a/pkg/gofr/http/multipart_file_bind_test.go b/pkg/gofr/http/multipart_file_bind_test.go index 7b89b2d51..e7122b457 100644 --- a/pkg/gofr/http/multipart_file_bind_test.go +++ b/pkg/gofr/http/multipart_file_bind_test.go @@ -187,8 +187,10 @@ func TestSetStructValue_Success(t *testing.T) { wantField2: 456, }, { - name: "Mixed Case and invalid field names", - data: `{"FielD1":"value4", "invalidField":"ignored", "FiEld2":789}`, + name: "Mixed Case and invalid field names", + // spellchecker:off # using field with case sensitive variations would be reported as a typo otherwise + data: `{"FielD1":"value4", "invalidField":"ignored", "FiEld2":789}`, + // spellchecker:on wantField1: "value4", wantField2: 789, }, diff --git a/typos.toml b/typos.toml index aea29c0c3..5cce56f1b 100644 --- a/typos.toml +++ b/typos.toml @@ -4,6 +4,12 @@ extend-ignore-re=[ # UID and equivalent "[A-Za-z0-9=_-]{30,}", + # False positive managements with inline comments + # + # disable spellchecker for current line with a comment mentioning "spellchecker:disable-line" + "(?Rm)^.*(|\n)?$", + # disable a block from a "spellchecker:on" comment to "spellchecker:off" one + "(?s)(|[^\n]*\n).*?(