Updates for issue #288:
The follow case rules were made configurable: architecture_004 architecture_019 architecture_020 architecture_021 1) Updated documentation 2) Updated tests 3) Updated rules
This commit is contained in:
parent
1b869ff8af
commit
950c19dd26
|
|
@ -60,7 +60,11 @@ This rule check for a blank line above the **architecture** declaration.
|
|||
architecture_004
|
||||
################
|
||||
|
||||
This rule checks the **architecture** keyword is lower case in the declaration.
|
||||
This rule checks the proper case of the **architecture** keyword in the architecture declaration.
|
||||
|
||||
.. NOTE:: The default is lowercase.
|
||||
|
||||
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
|
||||
|
||||
**Violation**
|
||||
|
||||
|
|
@ -261,7 +265,6 @@ This rule checks the case of the entity name in the architecture declaration.
|
|||
|
||||
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
|
||||
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
|
@ -365,7 +368,11 @@ This rule checks for a blank line above the **end architecture** declaration.
|
|||
architecture_019
|
||||
################
|
||||
|
||||
This rule checks the **of** keyword is lower case in the architecture declaration.
|
||||
This rule checks the proper case of the **of** keyword in the architecture declaration.
|
||||
|
||||
.. NOTE:: The default is lowercase.
|
||||
|
||||
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
|
||||
|
||||
**Violation**
|
||||
|
||||
|
|
@ -382,7 +389,11 @@ This rule checks the **of** keyword is lower case in the architecture declaratio
|
|||
architecture_020
|
||||
################
|
||||
|
||||
This rule checks the **is** keyword is lower case in the architecture declaration.
|
||||
This rule checks the proper case of the **is** keyword in the architecture declaration.
|
||||
|
||||
.. NOTE:: The default is lowercase.
|
||||
|
||||
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
|
||||
|
||||
**Violation**
|
||||
|
||||
|
|
@ -399,7 +410,11 @@ This rule checks the **is** keyword is lower case in the architecture declaratio
|
|||
architecture_021
|
||||
################
|
||||
|
||||
This rule checks the **begin** keyword is lower case.
|
||||
This rule checks the proper case of the **begin** keyword.
|
||||
|
||||
.. NOTE:: The default is lowercase.
|
||||
|
||||
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
|
||||
|
||||
**Violation**
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,16 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import fix
|
||||
|
||||
import re
|
||||
from vsg.rules import case_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_004(rule.rule):
|
||||
class rule_004(case_rule):
|
||||
'''
|
||||
Architecture rule 004 checks the architecture keyword is lower case.
|
||||
Entity rule 004 checks the architecture keyword has proper case.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'architecture', '004')
|
||||
self.solution = 'Change architecture keyword to lowercase.'
|
||||
self.phase = 6
|
||||
case_rule.__init__(self, 'architecture', '004', 'isArchitectureKeyword')
|
||||
self.solution = 'Change "architecture" keyword to '
|
||||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.isArchitectureKeyword and not re.match('^\s*architecture', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.lower_case(oFile.lines[iLineNumber], 'architecture')
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_word(oLine, 'architecture')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,16 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import fix
|
||||
|
||||
import re
|
||||
from vsg.rules import case_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_019(rule.rule):
|
||||
class rule_019(case_rule):
|
||||
'''
|
||||
Architecture rule 019 checks the "of" keyword is lower case.
|
||||
Entity rule 019 checks the of keyword has proper case.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'architecture', '019')
|
||||
self.solution = 'Change "of" keyword to lowercase.'
|
||||
self.phase = 6
|
||||
case_rule.__init__(self, 'architecture', '019', 'isArchitectureKeyword')
|
||||
self.solution = 'Change "of" keyword to '
|
||||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.isArchitectureKeyword and \
|
||||
re.match('^\s*\w+\s+\w+\s+of', oLine.lineLower) and \
|
||||
not re.match('^\s*\w+\s+\w+\s+of', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.lower_case(oFile.lines[iLineNumber], 'of')
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_word(oLine, 'of')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,16 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import fix
|
||||
|
||||
import re
|
||||
from vsg.rules import case_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_020(rule.rule):
|
||||
class rule_020(case_rule):
|
||||
'''
|
||||
Architecture rule 020 checks the "is" keyword is lower case.
|
||||
Entity rule 020 checks the is keyword has proper case.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'architecture', '020')
|
||||
self.solution = 'Change "is" keyword to lowercase.'
|
||||
self.phase = 6
|
||||
case_rule.__init__(self, 'architecture', '020', 'isArchitectureKeyword')
|
||||
self.solution = 'Change "is" keyword to '
|
||||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.isArchitectureKeyword:
|
||||
if re.match('^\s*architecture\s+\w+\s+of\s+\w+\s+is', oLine.lineLower):
|
||||
if not re.match('^\s*\w+\s+\w+\s+\w+\s+\w+\s+is', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.lower_case(oFile.lines[iLineNumber], 'is')
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_word(oLine, 'is')
|
||||
|
|
|
|||
|
|
@ -1,24 +1,16 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import fix
|
||||
|
||||
import re
|
||||
from vsg.rules import case_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_021(rule.rule):
|
||||
class rule_021(case_rule):
|
||||
'''
|
||||
Architecture rule 021 checks the "begin" keyword is lower case.
|
||||
Entity rule 021 checks the begin keyword has proper case.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'architecture', '021')
|
||||
self.solution = 'Change "begin" keyword to lowercase.'
|
||||
self.phase = 6
|
||||
case_rule.__init__(self, 'architecture', '021', 'isArchitectureBegin')
|
||||
self.solution = 'Change "begin" keyword to '
|
||||
|
||||
def _analyze(self, oFile, oLine, iLineNumber):
|
||||
if oLine.isArchitectureBegin and not re.match('^\s*begin', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.lower_case(oFile.lines[iLineNumber], 'begin')
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_word(oLine, 'begin')
|
||||
|
|
|
|||
|
|
@ -41,10 +41,22 @@ class testFixRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_004(self):
|
||||
def test_fix_rule_004_lowercase(self):
|
||||
oRule = architecture.rule_004()
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' architecture ARch Of entity Is')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_004_uppercase(self):
|
||||
oRule = architecture.rule_004()
|
||||
oRule.case = 'upper'
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' ARCHITECTURE ARch Of entity Is')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
|
|
@ -192,24 +204,60 @@ class testFixRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_019(self):
|
||||
def test_fix_rule_019_lowercase(self):
|
||||
oRule = architecture.rule_019()
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch of entity Is')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_020(self):
|
||||
def test_fix_rule_019_uppercase(self):
|
||||
oRule = architecture.rule_019()
|
||||
oRule.case = 'upper'
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch OF entity Is')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_020_lowercase(self):
|
||||
oRule = architecture.rule_020()
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch Of entity is')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_021(self):
|
||||
def test_fix_rule_020_uppercase(self):
|
||||
oRule = architecture.rule_020()
|
||||
oRule.case = 'upper'
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch Of entity IS')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_021_lowercase(self):
|
||||
oRule = architecture.rule_021()
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[29].line, 'begin')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_fix_rule_021_uppercase(self):
|
||||
oRule = architecture.rule_021()
|
||||
oRule.case = 'upper'
|
||||
dExpected = []
|
||||
oRule.fix(self.oFile)
|
||||
self.assertEqual(self.oFile.lines[39].line, 'BEGIN')
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
|
|
|
|||
|
|
@ -68,13 +68,21 @@ class testRuleArchitectureMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'architecture')
|
||||
self.assertEqual(oRule.identifier, '004')
|
||||
|
||||
def test_rule_004(self):
|
||||
def test_rule_004_lowercase(self):
|
||||
oRule = architecture.rule_004()
|
||||
|
||||
dExpected = [20]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_004_uppercase(self):
|
||||
oRule = architecture.rule_004()
|
||||
oRule.case = 'upper'
|
||||
|
||||
dExpected = [3,9,14,20,26,33,37,47,59,81]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_005_exists(self):
|
||||
oRule = architecture.rule_005()
|
||||
self.assertTrue(oRule)
|
||||
|
|
@ -236,7 +244,7 @@ class testRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_019(self):
|
||||
def test_rule_019_lowercase(self):
|
||||
oRule = architecture.rule_019()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'architecture')
|
||||
|
|
@ -245,7 +253,14 @@ class testRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_020(self):
|
||||
def test_rule_019_uppercase(self):
|
||||
oRule = architecture.rule_019()
|
||||
oRule.case = 'upper'
|
||||
dExpected = [3,9,14,20,33,37,47,59,81]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_020_lowercase(self):
|
||||
oRule = architecture.rule_020()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'architecture')
|
||||
|
|
@ -254,7 +269,14 @@ class testRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_021(self):
|
||||
def test_rule_020_uppercase(self):
|
||||
oRule = architecture.rule_020()
|
||||
oRule.case = 'upper'
|
||||
dExpected = [3,9,14,20,33,37,47,59,81]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_021_lowercase(self):
|
||||
oRule = architecture.rule_021()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'architecture')
|
||||
|
|
@ -263,6 +285,13 @@ class testRuleArchitectureMethods(unittest.TestCase):
|
|||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_021_uppercase(self):
|
||||
oRule = architecture.rule_021()
|
||||
oRule.case = 'upper'
|
||||
dExpected = [5,11,16,22,34,39,49,61,83]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_022(self):
|
||||
oRule = architecture.rule_022()
|
||||
self.assertTrue(oRule)
|
||||
|
|
|
|||
Loading…
Reference in New Issue