generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint.py
31 lines (25 loc) · 1.12 KB
/
lint.py
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
import sys
import subprocess
from pylint import lint
# "Perfect code": Some organizations strive for perfection and aim for a pylint score of 10.
# "Good code": Many organizations consider a pylint score between 8 and 9 as acceptable.
# "Acceptable" code: For less critical projects or projects with specific constraints,
# a pylint score between 6 and 7 might be acceptable.
# "Minimum threshold": In some cases, a project may have a minimum threshold to ensure a basic level of code quality.
# This threshold could be set anywhere between 4 and 6.
THRESHOLD = 5
FOLDER_PATH = "."
file_list = subprocess.check_output(["find", FOLDER_PATH, "-type", "f", "-name", "*.py"]).decode().splitlines()
scores = []
for file_path in file_list:
run = lint.Run(["--rcfile=.pylintrc", file_path], do_exit=False)
score = run.linter.stats.global_note
scores.append(score)
print("Scores:", scores)
print("Length:", len(scores))
average_score = sum(scores) / len(scores)
print("Average score:", average_score)
if average_score < THRESHOLD:
print("Linter failed: Average score < threshold value=" + str(THRESHOLD))
sys.exit(1)
sys.exit(0)