@@ -25,6 +25,11 @@ BASE_DIR="$(dirname $0)/.."
25
25
RET=0
26
26
CHECK=$1
27
27
28
+
29
+ function quote_if_needed {
30
+ awk ' { print $0 ~ /.*\s+.*/ ? "\""$0"\"" : $0 }'
31
+ }
32
+
28
33
function invgrep {
29
34
# grep with inverse exist status and formatting for azure-pipelines
30
35
#
@@ -38,13 +43,27 @@ function invgrep {
38
43
return $(( ! $EXIT_STATUS ))
39
44
}
40
45
46
+ function if_gh_actions {
47
+ # If this is running on GitHub Actions, echo the argument list, otherwise
48
+ # echo the empty string.
49
+ # Used to conditionally pass command-line arguments as in
50
+ # $(if_gh_actions --baz spam) | xargs foo --bar
51
+ if [[ " $GITHUB_ACTIONS " == " true" ]]; then
52
+ for arg in " $@ " ; do echo $arg ; done | quote_if_needed
53
+ else
54
+ echo " "
55
+ fi
56
+ }
57
+
58
+
41
59
if [[ " $GITHUB_ACTIONS " == " true" ]]; then
42
60
FLAKE8_FORMAT=" ##[error]%(path)s:%(row)s:%(col)s:%(code)s:%(text)s"
43
61
INVGREP_PREPEND=" ##[error]"
44
62
else
45
63
FLAKE8_FORMAT=" default"
46
64
fi
47
65
66
+
48
67
# ## LINTING ###
49
68
if [[ -z " $CHECK " || " $CHECK " == " lint" ]]; then
50
69
@@ -93,36 +112,24 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
93
112
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/* .h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime pandas/_libs/* .cpp
94
113
RET=$(( $RET + $? )) ; echo $MSG " DONE"
95
114
115
+
116
+ VALIDATE_CMD=$BASE_DIR /scripts/validate_unwanted_patterns.py
117
+ FMT_ARGS=$( if_gh_actions --format=" ##[error]{source_path}:{line_number}:{msg}" )
118
+
96
119
MSG=' Check for use of not concatenated strings' ; echo $MSG
97
- if [[ " $GITHUB_ACTIONS " == " true" ]]; then
98
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" strings_to_concatenate" --format=" ##[error]{source_path}:{line_number}:{msg}" .
99
- else
100
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" strings_to_concatenate" .
101
- fi
120
+ echo $FMT_ARGS | xargs $VALIDATE_CMD --validation-type=" strings_to_concatenate" .
102
121
RET=$(( $RET + $? )) ; echo $MSG " DONE"
103
122
104
123
MSG=' Check for strings with wrong placed spaces' ; echo $MSG
105
- if [[ " $GITHUB_ACTIONS " == " true" ]]; then
106
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" strings_with_wrong_placed_whitespace" --format=" ##[error]{source_path}:{line_number}:{msg}" .
107
- else
108
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" strings_with_wrong_placed_whitespace" .
109
- fi
124
+ echo $FMT_ARGS | xargs $VALIDATE_CMD --validation-type=" strings_with_wrong_placed_whitespace" .
110
125
RET=$(( $RET + $? )) ; echo $MSG " DONE"
111
126
112
127
MSG=' Check for import of private attributes across modules' ; echo $MSG
113
- if [[ " $GITHUB_ACTIONS " == " true" ]]; then
114
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" private_import_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored --format=" ##[error]{source_path}:{line_number}:{msg}" pandas/
115
- else
116
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" private_import_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored pandas/
117
- fi
128
+ echo $FMT_ARGS | xargs $VALIDATE_CMD --validation-type=" private_import_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored pandas/
118
129
RET=$(( $RET + $? )) ; echo $MSG " DONE"
119
130
120
131
MSG=' Check for use of private functions across modules' ; echo $MSG
121
- if [[ " $GITHUB_ACTIONS " == " true" ]]; then
122
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" private_function_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ --format=" ##[error]{source_path}:{line_number}:{msg}" pandas/
123
- else
124
- $BASE_DIR /scripts/validate_unwanted_patterns.py --validation-type=" private_function_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ pandas/
125
- fi
132
+ echo $FMT_ARGS | xargs $VALIDATE_CMD --validation-type=" private_function_across_module" --included-file-extensions=" py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ pandas/
126
133
RET=$(( $RET + $? )) ; echo $MSG " DONE"
127
134
128
135
echo " isort --version-number"
0 commit comments