Skip to content

Commit 6ebb3b5

Browse files
committed
linter exec improved
- linter keeps going through all files without stopping and reports failure at the end - added prints fo better user experience
1 parent d1629e1 commit 6ebb3b5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixed
66
- Type inference in grammar
7+
- Improved linter exec user experience
78

89
## [3.2.2] 2020-02-03
910

gdtoolkit/linter/__main__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,26 @@ def main(): # pylint: disable=too-many-branches
8181
)
8282
config[key] = DEFAULT_CONFIG[key]
8383

84+
problems_total = 0
8485
for file_path in arguments["<file>"]:
8586
with open(file_path, "r") as fh: # TODO: handle exception
8687
content = fh.read()
8788
problems = lint_code(content, config)
89+
problems_total += len(problems)
8890
if len(problems) > 0: # TODO: friendly frontend like in halint
8991
for problem in problems:
9092
print_problem(problem, file_path)
91-
sys.exit(1)
9293

93-
logging.info("Success: no problems found")
94+
if problems_total > 0:
95+
print(
96+
"Failure: {} problem{} found".format(
97+
problems_total, "" if problems_total == 1 else "s"
98+
),
99+
file=sys.stderr,
100+
)
101+
sys.exit(1)
102+
103+
print("Success: no problems found")
94104

95105

96106
if __name__ == "__main__":

0 commit comments

Comments
 (0)