diff --git a/vsg/check/is_lowercase.py b/vsg/check/is_lowercase.py index bb23efc0..5e8b92a7 100644 --- a/vsg/check/is_lowercase.py +++ b/vsg/check/is_lowercase.py @@ -13,3 +13,6 @@ def is_lowercase(self, sString, iLineNumber): ''' if not sString == sString.lower(): self.add_violation(iLineNumber) + return False + + return True diff --git a/vsg/check/is_uppercase.py b/vsg/check/is_uppercase.py index 45014781..94794228 100644 --- a/vsg/check/is_uppercase.py +++ b/vsg/check/is_uppercase.py @@ -13,3 +13,6 @@ def is_uppercase(self, sString, iLineNumber): ''' if not sString == sString.upper(): self.add_violation(iLineNumber) + return False + + return True diff --git a/vsg/rules/case_rule.py b/vsg/rules/case_rule.py index ecb06eac..8704e3f7 100644 --- a/vsg/rules/case_rule.py +++ b/vsg/rules/case_rule.py @@ -41,27 +41,24 @@ class case_rule(rule.rule): self.sTrigger = sTrigger self.extractFunction = extractFunction self.case = 'lower' - self.words = [] + self.words_to_fix = set() def _analyze(self, oFile, oLine, iLineNumber): if oLine.__dict__[self.sTrigger]: - self.words = self.words + self.extractFunction(oLine) - if self.case == 'lower': - check_function = check.is_lowercase - else: - check_function = check.is_uppercase + words = self.extractFunction(oLine) - for word in self.words: - check_function(self, word, iLineNumber) + if self.case == 'lower': + check_function = check.is_lowercase + else: + check_function = check.is_uppercase + + for word in words: + if check_function(self, word, iLineNumber) == False: + self.words_to_fix.add(word) def _fix_violations(self, oFile): for iLineNumber in self.violations: - print('***') - print(self.words) - print('***') - for word in self.words: - print(word) - + for word in self.words_to_fix: if self.case == 'lower': fix_function = fix.lower_case else: diff --git a/vsg/tests/constant/test_fix_rule_constant.py b/vsg/tests/constant/test_fix_rule_constant.py index d7e50377..d5097090 100644 --- a/vsg/tests/constant/test_fix_rule_constant.py +++ b/vsg/tests/constant/test_fix_rule_constant.py @@ -93,6 +93,19 @@ class testFixRuleConstantMethods(unittest.TestCase): self.assertEqual(self.oFile.lines[9].line, 'constant const : STD_LOGIC:=\'0\';') self.assertEqual(self.oFile.lines[10].line, ' constant c_const: std_logic') + oRule = constant.rule_004() + oRule.case = 'upper' + dExpected = [] + oRule.fix(self.oFile) + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, dExpected) + self.assertEqual(self.oFile.lines[5].line, ' constant C_CONST : std_logic := \'1\';') + self.assertEqual(self.oFile.lines[6].line, ' constant CONST : std_logic := \'0\';') + self.assertEqual(self.oFile.lines[7].line, ' COnstant C_CONST : std_logic := \'1\';') + self.assertEqual(self.oFile.lines[8].line, 'Constant C_CONST : std_logic := \'0\';') + self.assertEqual(self.oFile.lines[9].line, 'constant CONST : STD_LOGIC:=\'0\';') + self.assertEqual(self.oFile.lines[10].line, ' constant C_CONST: std_logic') + def test_fix_rule_005(self): oRule = constant.rule_005() dExpected = [] diff --git a/vsg/utils.py b/vsg/utils.py index f4e2e4ab..4ed618d6 100644 --- a/vsg/utils.py +++ b/vsg/utils.py @@ -98,7 +98,6 @@ def change_word(oLine, sWord, sNewWord, iMax=1): sNewWord: (string) ''' - print('### Changing word ' + sWord + ' to ' + sNewWord + ' ###') sLine = oLine.line tLine = re.subn(r'\b' + sWord + r'\b', sNewWord, sLine, iMax, flags=re.IGNORECASE) sLine = tLine[0]