Updates for issue #56
1) Added port_018 to enforce alignment of comments in entity declarations.
This commit is contained in:
parent
25ded2af68
commit
ebd4dee840
|
|
@ -426,3 +426,37 @@ class rule_017(entity_rule):
|
|||
def _fix_violations(self, oFile):
|
||||
self._fix_keyword_alignment(oFile)
|
||||
|
||||
|
||||
class rule_018(entity_rule):
|
||||
'''
|
||||
Entity rule 018 ensures the alignment of comments in the entity.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
entity_rule.__init__(self)
|
||||
self.identifier = '018'
|
||||
self.solution = 'Inconsistent alignment of comments in entity.'
|
||||
self.phase = 5
|
||||
|
||||
def analyze(self, oFile):
|
||||
lGroup = []
|
||||
fGroupFound = False
|
||||
iStartGroupIndex = None
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if not fGroupFound and oLine.insideEntity:
|
||||
fGroupFound = True
|
||||
iStartGroupIndex = iLineNumber
|
||||
if oLine.isEndEntityDeclaration:
|
||||
lGroup.append(oLine)
|
||||
fGroupFound = False
|
||||
self._check_keyword_alignment(iStartGroupIndex, '--', lGroup)
|
||||
lGroup = []
|
||||
iStartGroupIndex = None
|
||||
if fGroupFound:
|
||||
if oLine.isPortDeclaration:
|
||||
lGroup.append(oLine)
|
||||
else:
|
||||
lGroup.append(line.line('Removed line'))
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
self._fix_keyword_alignment(oFile)
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ end entity ENTITY1
|
|||
|
||||
entITy entiTY2 IS
|
||||
generic (
|
||||
G_GENERIC1 : std_logic :='0';
|
||||
G_generic2 : std_logic := '1'
|
||||
G_GENERIC1 : std_logic :='0';-- Comment
|
||||
G_generic2 : std_logic := '1' -- Comment
|
||||
);
|
||||
|
||||
PORt (
|
||||
i_port1 : in std_logic;
|
||||
o_port2 : out std_logic;
|
||||
io_port3 : inout std_logic;
|
||||
PORT4 :in std_logic;
|
||||
PORT5 : out std_logic;
|
||||
PORT6 : inout std_logic );
|
||||
i_port1 : in std_logic; -- Comment
|
||||
o_port2 : out std_logic; -- Comment
|
||||
io_port3 : inout std_logic; -- Comment
|
||||
PORT4 :in std_logic; -- Comment
|
||||
PORT5 : out std_logic;--Comment
|
||||
PORT6 : inout std_logic );--Comment
|
||||
|
||||
end entity entiTY2
|
||||
eNTITY entiTY3 is
|
||||
|
|
|
|||
|
|
@ -115,3 +115,9 @@ class testFixRuleEntityMethods(unittest.TestCase):
|
|||
oRule.fix(oFile)
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
||||
def test_fix_rule_018(self):
|
||||
oRule = entity.rule_018()
|
||||
oRule.fix(oFile)
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, [])
|
||||
|
|
|
|||
|
|
@ -181,3 +181,13 @@ class testRuleEntityMethods(unittest.TestCase):
|
|||
dExpected = ['8-15','25-31','39-46','56-62','70-77','86-90','98-102','118-122','128-132']
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_018(self):
|
||||
oRule = entity.rule_018()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'entity')
|
||||
self.assertEqual(oRule.identifier, '018')
|
||||
|
||||
dExpected = ['19-33']
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
|
|
|||
Loading…
Reference in New Issue