github.com/apache/beam/sdks/v2@v2.48.2/python/scripts/run_whitespacelint.sh (about) 1 #!/bin/bash 2 # 3 # Licensed to the Apache Software Foundation (ASF) under one or more 4 # contributor license agreements. See the NOTICE file distributed with 5 # this work for additional information regarding copyright ownership. 6 # The ASF licenses this file to You under the Apache License, Version 2.0 7 # (the "License"); you may not use this file except in compliance with 8 # the License. You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 # 18 19 set -e 20 21 # The files are gathered by the archiveFilesToLint then unpackFilesToLint tasks. 22 # Currently all *.md (markdown) files and build.gradle (gradle build) files in 23 # the Beam repo are included. 24 pushd ../../../files-to-whitespacelint 25 26 declare -a failed_files 27 28 # Check for trailing spaces in non-code text files. 29 echo "Running whitespacelint..." 30 while IFS= read -r -d '' file; do 31 if ! test -f "$file"; then 32 echo "$file does not exist" 33 continue 34 fi 35 if ! whitespacelint "$file"; then 36 failed_files+=("$file") 37 fi 38 done < <(find . -type f -print0) 39 40 if [ ${#failed_files[@]} -gt 0 ]; then 41 printf '=%.0s' {1..100} 42 echo 43 echo "Whitespacelint has found above issues." 44 echo "You can open the file with vim and remove trailing whitespaces by:" 45 for file in "${failed_files[@]}"; do 46 echo "vim -es -c \":%s/\s\+$//e\" -c \":wq\" \"$file\"" 47 done 48 printf '=%.0s' {1..100} 49 echo 50 popd 51 exit 1 52 else 53 printf '=%.0s' {1..100} 54 echo 55 echo 'Whitespacelint has completed successfully and found no issue.' 56 printf '=%.0s' {1..100} 57 echo 58 popd 59 fi