Skip to content

Commit 9c4c624

Browse files
authored
Add monitoring to detect tabs in the templates (#8738)
* add monitoring for tabs in the templates * rename script * add detect_tab_in_templates.sh * rearrange tests * add kotlin folders * move test to circleci * restore .travis.yml * fix grep
1 parent 4bf0983 commit 9c4c624

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ install:
149149
script:
150150
# fail fast
151151
- set -e
152+
# fail if the template files contains tabs
153+
- /bin/bash ./bin/utils/detect_tab_in_templates.sh
152154
# fail if the test files have changes
153155
- bin/utils/detect_test_file_changes.rb bin/utils/test_file_list.yaml
154156
# fail if templates/generators contain carriage return '\r'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
# Look for \t in the template folders and report errors if found
4+
# as these tabs should be replaced with 4-space instead
5+
6+
## declare an array of folders
7+
declare -a samples=("modules/openapi-generator/src/main/resources/kotlin-server"
8+
"modules/openapi-generator/src/main/resources/kotlin-spring"
9+
"modules/openapi-generator/src/main/resources/dart-dio"
10+
"modules/openapi-generator/src/main/resources/dart"
11+
"modules/openapi-generator/src/main/resources/dart2"
12+
"modules/openapi-generator/src/main/resources/aspnetcore"
13+
"modules/openapi-generator/src/main/resources/powershell"
14+
)
15+
16+
## now loop through the above array
17+
for i in "${samples[@]}"
18+
do
19+
# grep for \t in the folder
20+
RESULT=`grep -R -P "\t" $i`
21+
echo -e "$RESULT"
22+
23+
if [ "$RESULT" != "" ]; then
24+
echo "Template files contain tab '\\t'. Please remove it or replace it with 4-space."
25+
exit 1;
26+
fi
27+
done
28+

0 commit comments

Comments
 (0)