26 lines
731 B
Python
26 lines
731 B
Python
|
|
from vsg import rule
|
|
|
|
import re
|
|
|
|
|
|
class rule_020(rule.rule):
|
|
'''
|
|
Case rule 020 checks for labels after the "end case" keywords.
|
|
'''
|
|
|
|
def __init__(self):
|
|
rule.rule.__init__(self, 'case', '020')
|
|
self.phase = 1
|
|
self.solution = 'Remove label after the "end case" keywords'
|
|
|
|
def _analyze(self, oFile, oLine, iLineNumber):
|
|
if oLine.hasEndCaseLabel:
|
|
self.add_violation(iLineNumber)
|
|
|
|
def _fix_violations(self, oFile):
|
|
for iLineNumber in self.violations:
|
|
oLine = oFile.lines[iLineNumber]
|
|
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
|