Commit e1786b54 authored by Anthony Sottile's avatar Anthony Sottile Committed by Jason R. Coombs

bpo-36853: Fix suspicious.py to actually print the unused rules (#13579)

* Fix suspicious.py to actually print the unused rules

* Fix the other `self.warn` calls
parent 102e9b40
...@@ -115,10 +115,12 @@ class CheckSuspiciousMarkupBuilder(Builder): ...@@ -115,10 +115,12 @@ class CheckSuspiciousMarkupBuilder(Builder):
def finish(self): def finish(self):
unused_rules = [rule for rule in self.rules if not rule.used] unused_rules = [rule for rule in self.rules if not rule.used]
if unused_rules: if unused_rules:
self.logger.warn('Found %s/%s unused rules:' % self.logger.warning(
(len(unused_rules), len(self.rules))) 'Found %s/%s unused rules: %s' % (
for rule in unused_rules: len(unused_rules), len(self.rules),
self.logger.info(repr(rule)) ''.join(repr(rule) for rule in unused_rules),
)
)
return return
def check_issue(self, line, lineno, issue): def check_issue(self, line, lineno, issue):
...@@ -151,14 +153,15 @@ class CheckSuspiciousMarkupBuilder(Builder): ...@@ -151,14 +153,15 @@ class CheckSuspiciousMarkupBuilder(Builder):
self.any_issue = True self.any_issue = True
self.write_log_entry(lineno, issue, text) self.write_log_entry(lineno, issue, text)
if py3: if py3:
self.logger.warn('[%s:%d] "%s" found in "%-.120s"' % self.logger.warning('[%s:%d] "%s" found in "%-.120s"' %
(self.docname, lineno, issue, text)) (self.docname, lineno, issue, text))
else: else:
self.logger.warn('[%s:%d] "%s" found in "%-.120s"' % ( self.logger.warning(
self.docname.encode(sys.getdefaultencoding(),'replace'), '[%s:%d] "%s" found in "%-.120s"' % (
lineno, self.docname.encode(sys.getdefaultencoding(),'replace'),
issue.encode(sys.getdefaultencoding(),'replace'), lineno,
text.strip().encode(sys.getdefaultencoding(),'replace'))) issue.encode(sys.getdefaultencoding(),'replace'),
text.strip().encode(sys.getdefaultencoding(),'replace')))
self.app.statuscode = 1 self.app.statuscode = 1
def write_log_entry(self, lineno, issue, text): def write_log_entry(self, lineno, issue, text):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment