Improve H202 to cover more cases

H202 should cover both of following cases:

self.assertRaises(Exception)
self.assertRaises(Exception, foo)

Change to regex to match both cases.

Bug #1214629

Change-Id: I73ac39765b6274f6df9d5251175d9386effae71c
This commit is contained in:
Kui Shi 2013-08-21 09:55:19 +08:00
parent 1bcf93164a
commit 59bf3567b0

View File

@ -253,8 +253,9 @@ def hacking_except_format_assert(logical_line):
Okay: self.assertRaises(NovaException, foo)
Okay: self.assertRaises(ExceptionStrangeNotation, foo)
H202: self.assertRaises(Exception, foo)
H202: self.assertRaises(Exception)
"""
if logical_line.startswith("self.assertRaises(Exception,"):
if re.match(r"self\.assertRaises\(Exception[,\)]", logical_line):
yield 1, "H202: assertRaises Exception too broad"