diff --git a/vsg/rules/case/rule_016.py b/vsg/rules/case/rule_016.py index 29fd9fbc..f478a7f7 100644 --- a/vsg/rules/case/rule_016.py +++ b/vsg/rules/case/rule_016.py @@ -1,12 +1,13 @@ -from vsg.rules import lower_case_rule +from vsg.rules import case_rule +from vsg import utils -class rule_016(lower_case_rule): +class rule_016(case_rule): ''' - Entity rule 016 checks the when keyword is lower case. + Entity rule 016 checks the when keyword has proper case. ''' def __init__(self): - lower_case_rule.__init__(self, 'case', '016', 'isCaseWhenKeyword', 'when') - self.solution = 'Change "when" keyword to lowercase.' + case_rule.__init__(self, 'case', '016', 'isCaseWhenKeyword', utils.extract_when_keyword) + self.solution = 'Change when keyword to ' + self.case + 'case' diff --git a/vsg/utils.py b/vsg/utils.py index 52a9a293..85c147b6 100644 --- a/vsg/utils.py +++ b/vsg/utils.py @@ -717,7 +717,7 @@ def _extract_keyword(sLine, keyword): keyword: keyword to extract - Returns: (one element list of strings) + Returns: (one element or empty list of strings) ''' line = sLine.replace('(', ' ') line = line.replace(')', ' ') @@ -726,6 +726,8 @@ def _extract_keyword(sLine, keyword): if word.lower() == keyword: return [word] + return [] + def extract_is_keyword(oLine): ''' @@ -753,6 +755,19 @@ def extract_begin_keyword(oLine): return _extract_keyword(oLine.line, 'begin') +def extract_when_keyword(oLine): + ''' + Returns begin keyword from line. + + Parameters: + + oLine: (line object) + + Returns: (one element list of strings) + ''' + return _extract_keyword(oLine.line, 'when') + + def remove_comment_attributes_from_line(oLine): ''' Sets all comment attributes on a line to indicate no comment is present.