Updates for issue #335
Updated case rules to use violation dictionary for violation list. 1) Updated code 2) Updated tests
This commit is contained in:
parent
b06ee2ee63
commit
f7fc866fbc
|
|
@ -16,10 +16,12 @@ class rule_012(rule.rule):
|
|||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.isCaseWhenEnd and re.match('^.*=>\s*\w', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
dViolation = utils.create_violation_dict(iLineNumber)
|
||||
self.add_violation(dViolation)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
for dViolation in self.violations[::-1]:
|
||||
iLineNumber = dViolation['lineNumber']
|
||||
utils.split_line_after_word(oFile, iLineNumber, '=>')
|
||||
oFile.lines[iLineNumber + 1].isCaseWhenEnd = False
|
||||
oFile.lines[iLineNumber + 1].insideCaseWhen = False
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import utils
|
||||
|
||||
import re
|
||||
|
||||
|
|
@ -16,10 +17,11 @@ class rule_019(rule.rule):
|
|||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.hasCaseLabel:
|
||||
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']]
|
||||
oLine.update_line(re.sub('^(\s*)(\w+\s*:\s*)', r'\1', oLine.line, 1))
|
||||
oLine.hasCaseLabel = False
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import utils
|
||||
|
||||
import re
|
||||
|
||||
|
|
@ -16,10 +17,11 @@ class rule_020(rule.rule):
|
|||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.hasEndCaseLabel:
|
||||
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']]
|
||||
oLine.update_line(re.sub('^(\s*end\s+case)(\s*\w+\s*)(;\s*$)', r'\1\3', oLine.line, 1, flags=re.IGNORECASE))
|
||||
oLine.hasEndCaseLabel = False
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class testRuleCaseMethods(unittest.TestCase):
|
|||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'case')
|
||||
self.assertEqual(oRule.identifier, '012')
|
||||
dExpected = [11,12,16,22,23]
|
||||
dExpected = utils.add_violation_list([11,12,16,22,23])
|
||||
oRule.analyze(oFileSequential)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ class testRuleCaseMethods(unittest.TestCase):
|
|||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'case')
|
||||
self.assertEqual(oRule.identifier, '019')
|
||||
dExpected = [87]
|
||||
dExpected = [utils.add_violation(87)]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
|
|
@ -198,6 +198,6 @@ class testRuleCaseMethods(unittest.TestCase):
|
|||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'case')
|
||||
self.assertEqual(oRule.identifier, '020')
|
||||
dExpected = [98]
|
||||
dExpected = [utils.add_violation(98)]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
Loading…
Reference in New Issue