Skip to content

Commit 22ff5a2

Browse files
authored
add uri_ignore_words_list option (#46)
1 parent 2391250 commit 22ff5a2

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ with:
9595
ignore_words_list: abandonned,ackward
9696
```
9797

98+
### Parameter: uri_ignore_words_list
99+
100+
Comma-separated list of words which will be ignored by `codespell` in URIs and emails only.
101+
Words are case sensitive based on how they are written in the dictionary file.
102+
If set to "*", all misspelling in URIs and emails will be ignored.
103+
104+
This parameter is optional; by default `codespell` will check all URIs and emails for typos.
105+
106+
```
107+
uses: codespell-project/actions-codespell@master
108+
with:
109+
uri_ignore_words_list: abandonned
110+
```
111+
98112
### Parameter: path
99113

100114
Indicates the path to run `codespell` in.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ inputs:
3030
description: 'Comma-separated list of words to be ignored. Words are case sensitive based on how they are written in the dictionary file'
3131
required: false
3232
default: ''
33+
uri_ignore_words_list:
34+
description: 'comma separated list of words to be ignored in URIs and emails only'
35+
required: false
36+
default: ''
3337
path:
3438
description: 'Path to run codespell in'
3539
required: false

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'"
4040
if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then
4141
command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}"
4242
fi
43+
echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'"
44+
if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then
45+
command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}"
46+
fi
4347
echo "Resulting CLI options ${command_args}"
4448
exec 5>&1
4549
res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`

test/test.bats

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
# This currently breaks the tests, so only enabling when troubleshooting
88
#load teardown
99

10-
ROOT_MISSPELLING_COUNT=5
10+
ROOT_MISSPELLING_COUNT=6
1111
FILENAME_MISSPELLING_COUNT=1
1212
HIDDEN_MISSPELLING_COUNT=1
1313
EXCLUDED_MISSPELLING_COUNT=1
1414
BUILTIN_NAMES_MISSPELLING_COUNT=1
1515
IGNORE_WORDS_MISSPELLING_COUNT=5
16+
URI_IGNORE_WORDS_MISSPELLING_COUNT=1
1617
SUBFOLDER_MISSPELLING_COUNT=1
1718
# From all files called example.txt
1819
EXAMPLE_MISSPELLING_COUNT=5
@@ -40,6 +41,7 @@ function setup() {
4041
export INPUT_BUILTIN=""
4142
export INPUT_IGNORE_WORDS_FILE=""
4243
export INPUT_IGNORE_WORDS_LIST=""
44+
export INPUT_URI_IGNORE_WORDS_LIST=""
4345
export INPUT_PATH="./test/testdata"
4446
export INPUT_ONLY_WARN=""
4547
}
@@ -103,7 +105,7 @@ function setup() {
103105
}
104106

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

147+
@test "Use a URI ignore words list" {
148+
errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - URI_IGNORE_WORDS_MISSPELLING_COUNT))
149+
# codespell's exit status is 0, or 65 if there are errors found
150+
if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi
151+
INPUT_URI_IGNORE_WORDS_LIST="bu"
152+
run "./entrypoint.sh"
153+
[ $status -eq $expectedExitStatus ]
154+
[ "${lines[-4 - $errorCount]}" == "$errorCount" ]
155+
}
156+
145157
@test "Custom path" {
146158
errorCount=$((SUBFOLDER_MISSPELLING_COUNT))
147159
# codespell's exit status is 0, or 65 if there are errors found

test/testdata/example.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
Abandonned
33
ABANDONNED
44
AbAnDoNnEd
5+
https://www.bu.edu

0 commit comments

Comments
 (0)