Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line option to display summary of issues #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion rflint/rflint.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def run(self, args):
self._describe_rules(self.args.args)
return 0

self.counts = { ERROR: 0, WARNING: 0, "other": 0}
self.counts = {ERROR: 0, WARNING: 0, "other": 0}

for filename in self.args.args:
if not (os.path.exists(filename)):
Expand All @@ -111,6 +111,12 @@ def run(self, args):
else:
self._process_file(filename)

if self.args.summary:
print("----------------------------------------------------------------------",
f"Found {sum([x for x in self.counts.values()])} issues: "
f"{self.counts['E']} ERROR(s), {self.counts['W']} WARNING(s), {self.counts['other']} other(s).",
sep="\n")

if self.counts[ERROR] > 0:
return self.counts[ERROR] if self.counts[ERROR] < 254 else 255

Expand Down Expand Up @@ -290,6 +296,8 @@ def parse_and_process_args(self, args):
help="Display version number and exit")
parser.add_argument("--verbose", "-v", action="store_true", default=False,
help="Give verbose output")
parser.add_argument("--summary", "-s", action="store_true", default=False,
help="Show summary for found issues at the end")
parser.add_argument("--configure", "-c", action=ConfigureAction,
help="Configure a rule")
parser.add_argument("--recursive", "-r", action="store_true", default=False,
Expand Down