Updates issue #335:
Updated rules using vsg.check.has_prefix to use the violations list in the fix phase: 1) Updated tests 2) Updated vsg.check.has_prefix to push a dictionary into the violation list
This commit is contained in:
parent
fb4c5ca972
commit
fdcdf2d909
|
|
@ -18,4 +18,4 @@ def has_prefix(self, prefixes, words, iLineNumber):
|
|||
if word.lower().startswith(prefix.lower()):
|
||||
break
|
||||
else:
|
||||
self.add_violation(iLineNumber)
|
||||
self.add_violation({'lineNumber' : iLineNumber})
|
||||
|
|
|
|||
|
|
@ -138,13 +138,13 @@ class testRuleConstantMethods(unittest.TestCase):
|
|||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'constant')
|
||||
self.assertEqual(oRule.identifier, '015')
|
||||
lExpected = [6,9,18,28,30,38]
|
||||
lExpected = utils.add_violation_list([6,9,18,28,30,38])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
||||
def test_rule_015_with_override(self):
|
||||
oRule = constant.rule_015()
|
||||
oRule.prefixes = ['c_', 'ro']
|
||||
lExpected = [6,9,18,28,38]
|
||||
lExpected = utils.add_violation_list([6,9,18,28,38])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
|
|
|||
|
|
@ -221,11 +221,11 @@ class testRuleGenericMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'generic')
|
||||
self.assertEqual(oRule.identifier, '020')
|
||||
|
||||
dExpected = [67,96,116]
|
||||
dExpected = utils.add_violation_list([67,96,116])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_020_with_override(self):
|
||||
def test_rule_020_with_2_overrides(self):
|
||||
oRule = generic.rule_020()
|
||||
oRule.prefixes = ['G_', 'A_']
|
||||
|
||||
|
|
@ -237,6 +237,6 @@ class testRuleGenericMethods(unittest.TestCase):
|
|||
oRule = generic.rule_020()
|
||||
oRule.prefixes = ['A_']
|
||||
|
||||
dExpected = [5,6,21,22,36,37,52,53,68,83,84,97,139,140,155,156,170,171]
|
||||
dExpected = utils.add_violation_list([5,6,21,22,36,37,52,53,68,83,84,97,139,140,155,156,170,171])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ class testRulePortMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.identifier, '011')
|
||||
self.assertTrue(oRule.disable)
|
||||
|
||||
dExpected = [12,13,14,29,30,31,43,44,45,60,61,62,74,75,76,99,100,101,152,161,169,170,171,172,173]
|
||||
dExpected.extend(range(181, 186))
|
||||
dExpected = utils.add_violation_list([12,13,14,29,30,31,43,44,45,60,61,62,74,75,76,99,100,101,152,161,169,170,171,172,173])
|
||||
dExpected.extend(utils.add_violation_list(range(181, 186)))
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class testRuleSignalMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'signal')
|
||||
self.assertEqual(oRule.identifier, '008')
|
||||
self.assertTrue(oRule.disable)
|
||||
lExpected = [9,12,13,14,15,16,19,21,23]
|
||||
lExpected = utils.add_violation_list([9,12,13,14,15,16,19,21,23])
|
||||
oRule.prefixes = ['a_','b_','d_','e_']
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
|
|
|||
|
|
@ -47,20 +47,20 @@ class testRuleSubtypeMethods(unittest.TestCase):
|
|||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'subtype')
|
||||
self.assertEqual(oRule.identifier, '004')
|
||||
dExpected = [7,8,10,11]
|
||||
dExpected = utils.add_violation_list([7,8,10,11])
|
||||
oRule.analyze(oFilePrefix)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_004_with_multiple_override(self):
|
||||
oRule = subtype.rule_004()
|
||||
oRule.prefixes = ['st_', 'subt_']
|
||||
dExpected = [10,11]
|
||||
dExpected = utils.add_violation_list([10,11])
|
||||
oRule.analyze(oFilePrefix)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_004_with_single_override(self):
|
||||
oRule = subtype.rule_004()
|
||||
oRule.prefixes = ['subt_']
|
||||
dExpected = [4,5,10,11]
|
||||
dExpected = utils.add_violation_list([4,5,10,11])
|
||||
oRule.analyze(oFilePrefix)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
|
|
@ -145,20 +145,20 @@ class testRuleTypeMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'type')
|
||||
self.assertEqual(oRule.identifier, '015')
|
||||
self.assertTrue(oRule.disable)
|
||||
dExpected = [4,6,11,13,27,29,34,36,43,54,57,69,122,134]
|
||||
dExpected = utils.add_violation_list([4,6,11,13,27,29,34,36,43,54,57,69,122,134])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_015_with_single_override(self):
|
||||
oRule = type_definition.rule_015()
|
||||
oRule.prefixes = ['mem']
|
||||
dExpected = [4,6,11,13,27,29,34,36,43,57,69,122]
|
||||
dExpected = utils.add_violation_list([4,6,11,13,27,29,34,36,43,57,69,122])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_015_with_multiple_override(self):
|
||||
oRule = type_definition.rule_015()
|
||||
oRule.prefixes = ['mem', 'a']
|
||||
dExpected = [13,57,69]
|
||||
dExpected = utils.add_violation_list([13,57,69])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
|
|
@ -106,20 +106,20 @@ class testRuleVariableMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'variable')
|
||||
self.assertEqual(oRule.identifier, '012')
|
||||
self.assertTrue(oRule.disable)
|
||||
dExpected = [5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,27,28,29,37,38,39,47,48,49,57]
|
||||
dExpected = utils.add_violation_list([5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,27,28,29,37,38,39,47,48,49,57])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_012_with_single_override(self):
|
||||
oRule = variable.rule_012()
|
||||
oRule.prefixes = ['a_']
|
||||
dExpected = [7,8,9,10,11,12,13,14,15,16,18,19,20,21,27,28,29,37,38,39,47,48,49,57]
|
||||
dExpected = utils.add_violation_list([7,8,9,10,11,12,13,14,15,16,18,19,20,21,27,28,29,37,38,39,47,48,49,57])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_012_with_multiple_override(self):
|
||||
oRule = variable.rule_012()
|
||||
oRule.prefixes = ['a_','c_','p1_']
|
||||
dExpected = [7,8,9,10,11,12,13,14,15,16,18,20,47,48,49,57]
|
||||
dExpected = utils.add_violation_list([7,8,9,10,11,12,13,14,15,16,18,20,47,48,49,57])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
Loading…
Reference in New Issue