Skip to content

Commit

Permalink
add uri_ignore_words_list option (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
drammock authored Aug 18, 2022
1 parent 2391250 commit 22ff5a2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ with:
ignore_words_list: abandonned,ackward
```

### Parameter: uri_ignore_words_list

Comma-separated list of words which will be ignored by `codespell` in URIs and emails only.
Words are case sensitive based on how they are written in the dictionary file.
If set to "*", all misspelling in URIs and emails will be ignored.

This parameter is optional; by default `codespell` will check all URIs and emails for typos.

```
uses: codespell-project/actions-codespell@master
with:
uri_ignore_words_list: abandonned
```

### Parameter: path

Indicates the path to run `codespell` in.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inputs:
description: 'Comma-separated list of words to be ignored. Words are case sensitive based on how they are written in the dictionary file'
required: false
default: ''
uri_ignore_words_list:
description: 'comma separated list of words to be ignored in URIs and emails only'
required: false
default: ''
path:
description: 'Path to run codespell in'
required: false
Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'"
if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then
command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}"
fi
echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'"
if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then
command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}"
fi
echo "Resulting CLI options ${command_args}"
exec 5>&1
res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`
Expand Down
16 changes: 14 additions & 2 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
# This currently breaks the tests, so only enabling when troubleshooting
#load teardown

ROOT_MISSPELLING_COUNT=5
ROOT_MISSPELLING_COUNT=6
FILENAME_MISSPELLING_COUNT=1
HIDDEN_MISSPELLING_COUNT=1
EXCLUDED_MISSPELLING_COUNT=1
BUILTIN_NAMES_MISSPELLING_COUNT=1
IGNORE_WORDS_MISSPELLING_COUNT=5
URI_IGNORE_WORDS_MISSPELLING_COUNT=1
SUBFOLDER_MISSPELLING_COUNT=1
# From all files called example.txt
EXAMPLE_MISSPELLING_COUNT=5
Expand Down Expand Up @@ -40,6 +41,7 @@ function setup() {
export INPUT_BUILTIN=""
export INPUT_IGNORE_WORDS_FILE=""
export INPUT_IGNORE_WORDS_LIST=""
export INPUT_URI_IGNORE_WORDS_LIST=""
export INPUT_PATH="./test/testdata"
export INPUT_ONLY_WARN=""
}
Expand Down Expand Up @@ -103,7 +105,7 @@ function setup() {
}

@test "Check the skip option" {
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT))
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT - URI_IGNORE_WORDS_MISSPELLING_COUNT))
# codespell's exit status is 0, or 65 if there are errors found
if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi
INPUT_SKIP="example.txt"
Expand Down Expand Up @@ -142,6 +144,16 @@ function setup() {
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
}

@test "Use a URI ignore words list" {
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - URI_IGNORE_WORDS_MISSPELLING_COUNT))
# codespell's exit status is 0, or 65 if there are errors found
if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi
INPUT_URI_IGNORE_WORDS_LIST="bu"
run "./entrypoint.sh"
[ $status -eq $expectedExitStatus ]
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
}

@test "Custom path" {
errorCount=$((SUBFOLDER_MISSPELLING_COUNT))
# codespell's exit status is 0, or 65 if there are errors found
Expand Down
1 change: 1 addition & 0 deletions test/testdata/example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Abandonned
ABANDONNED
AbAnDoNnEd
https://www.bu.edu

0 comments on commit 22ff5a2

Please sign in to comment.