diff --git a/vsg/rules/comment/rule_004.py b/vsg/rules/comment/rule_004.py index 5b79ada8..c7386648 100644 --- a/vsg/rules/comment/rule_004.py +++ b/vsg/rules/comment/rule_004.py @@ -1,5 +1,7 @@ from vsg import rule +from vsg import utils + import re # Regex to find comments that ignores contents of double quoted strings, @@ -23,13 +25,12 @@ class rule_004(rule.rule): return idx = match.start("comment") if oLine.line[idx - 1] != ' ': - self.add_violation(iLineNumber) + dViolation = utils.create_violation_dict(iLineNumber) + self.add_violation(dViolation) def _fix_violations(self, oFile): - for iLineNumber in self.violations: - oLine = oFile.lines[iLineNumber] + for dViolation in self.violations: + oLine = oFile.lines[dViolation['lineNumber']] match = has_comment_re.match(oLine.line) idx = match.start("comment") oLine.update_line(" ".join((oLine.line[:idx], oLine.line[idx:]))) - - diff --git a/vsg/tests/comment/test_rule_comment.py b/vsg/tests/comment/test_rule_comment.py index a08365d1..825b529d 100644 --- a/vsg/tests/comment/test_rule_comment.py +++ b/vsg/tests/comment/test_rule_comment.py @@ -58,7 +58,7 @@ class testRuleCommentMethods(unittest.TestCase): def test_rule_004(self): oRule = comment.rule_004() - dExpected = [39, 58, 61, 62] + dExpected = utils.add_violation_list([39, 58, 61, 62]) oRule.analyze(oFile) self.assertEqual(oRule.violations, dExpected)