feature/fix_linter_fuckup #4
29
Jenkinsfile
vendored
29
Jenkinsfile
vendored
@@ -7,20 +7,33 @@ pipeline {
|
||||
script {
|
||||
// Check for spaces or mixed indentation
|
||||
sh '''
|
||||
FILE_EXTENSIONS="css json js java py ps1 cs cmd bat htm html cpp c h hpp"
|
||||
FILETYPES="css|json|js|java|py|ps1|cs|cmd|bat|htm|html|cpp|c|h|hpp"
|
||||
|
||||
# Convert FILE_EXTENSIONS to --include pattern
|
||||
INCLUDE_PATTERNS=$(echo $FILE_EXTENSIONS | sed 's/ /,*./g; s/^/*./')
|
||||
|
||||
echo "Checking for lines starting with spaces in $FILE_EXTENSIONS files..."
|
||||
grep -nrP '^[ ]+' --include="$INCLUDE_PATTERNS" . | sed 's/\\([^:]*\\):\\([^:]*\\):\\([ ]*\\).*/File: \\1, Line: \\2, Found: \\3/' || echo "No lines with spaces found."
|
||||
FILES=$(find . -regextype awk -regex '.*($FILETYPES)' -type f)
|
||||
|
||||
echo "Checking for lines with mixed tabs and spaces in $FILE_EXTENSIONS files..."
|
||||
grep -nrP '^\t+ +' --include="$INCLUDE_PATTERNS" . | sed 's/\\([^:]*\\):\\([^:]*\\):\\(\\t* +\\).*/File: \\1, Line: \\2, Found: \\3/' || echo "No lines with mixed indentation found."
|
||||
# Initialize the PROBLEMS variable
|
||||
PROBLEMS=""
|
||||
|
||||
if grep -nrP '^[ ]+' --include="$INCLUDE_PATTERNS" . || \
|
||||
grep -nrP '^\t+ +' --include="$INCLUDE_PATTERNS" .; then
|
||||
echo "$FILES" | while IFS= read -r file; do
|
||||
# Check for lines with spaces
|
||||
GREP_RESULT=$(grep -nrP '^[ ]+' "$file" | sed 's/\([^:]*\):\([^:]*\):\([ ]*\).*/File: \1, Line: \2, Found: \3/')
|
||||
if [ -n "$GREP_RESULT" ]; then
|
||||
PROBLEMS="$PROBLEMS$GREP_RESULT"$'\n' # Append the result to PROBLEMS
|
||||
fi
|
||||
|
||||
# Check for lines with mixed tabs and spaces
|
||||
GREP_RESULT=$(grep -nrP '^\t+ +' "$file" | sed 's/\([^:]*\):\([^:]*\):\([ ]*\).*/File: \1, Line: \2, Found: \3/')
|
||||
if [ -n "$GREP_RESULT" ]; then
|
||||
PROBLEMS="$PROBLEMS$GREP_RESULT"$'\n' # Append the result to PROBLEMS
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if there were any problems
|
||||
if [ -n "$PROBLEMS" ]; then
|
||||
echo "Indentation issues detected. Please fix the above lines."
|
||||
echo "$PROBLEMS"
|
||||
exit 1
|
||||
else
|
||||
echo "No indentation issues detected."
|
||||
|
||||
Reference in New Issue
Block a user