-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlinter.sh
executable file
·42 lines (35 loc) · 1.08 KB
/
linter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/env bash
# Get the current date and time
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Get the name of the person from git config
NAME=$(git config --get user.name)
# path from the root of project to the directory where the log files will be saved
PATHLOG=$(git rev-parse --show-toplevel)/errors_logs/linting
# Check if pylint is installed
if ! command -v pylint &> /dev/null
then
echo "pylint is not installed"
exit 1
fi
# Check if person's name is set in git config
if [ -z "$(git config --get user.name)" ]
then
echo "Please set your name in git config"
exit 1
fi
if [ ! -d "$PATHLOG" ]
then
mkdir -p "$PATHLOG"
fi
# Loop over all command line arguments
for file in "$@"
do
# Change the file suffix to .txt
filename=$(basename "$file")
output_file="${filename%.py}.txt"
echo -e "\n\nName: $NAME\n" >> "${PATHLOG}/${output_file}"
echo -e "Date: $CURRENT_DATE\n" >> "${PATHLOG}/${output_file}"
pylint "$file"
# Run pylint with the current command line argument
pylint "$file" --reports=y -f parseable >> "${PATHLOG}/${output_file}"
done