Refactoring indent rules.
This commit is contained in:
parent
a0033246c7
commit
52c9037263
|
|
@ -1,27 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_001(rule.rule):
|
||||
class rule_001(indent_rule):
|
||||
'''
|
||||
Case rule 001 checks for the proper alignment of comments.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self)
|
||||
self.name = 'comment'
|
||||
self.identifier = '001'
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
self.correctCommentColumn = []
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isComment:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'comment', '001', 'isComment')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_001(rule.rule):
|
||||
class rule_001(indent_rule):
|
||||
'''
|
||||
Component rule 001 checks for spaces before the "component" keyword.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self)
|
||||
self.name = 'component'
|
||||
self.identifier = '001'
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isComponentDeclaration:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'component', '001', 'isComponentDeclaration')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_001(rule.rule):
|
||||
class rule_001(indent_rule):
|
||||
'''
|
||||
Entity rule 001 checks for spaces before the entity keyword.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self)
|
||||
self.name = 'entity'
|
||||
self.identifier = '001'
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEntityDeclaration:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'entity', '001', 'isEntityDeclaration')
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_008(rule.rule):
|
||||
class rule_008(indent_rule):
|
||||
'''
|
||||
Function rule 008 checks the indent of function parameters when they are on multiple lines.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'function', '008')
|
||||
self.solution = 'Invalid indent'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isFunctionParameter and not oLine.isFunctionKeyword:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'function', '008', 'isFunctionParameter', 'isFunctionKeyword')
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_004(rule.rule):
|
||||
class rule_004(indent_rule):
|
||||
'''
|
||||
Generic rule 004 checks indentation of generics.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'generic', '004')
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isGenericDeclaration and not oLine.isEndGenericMap:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'generic', '004', 'isGenericDeclaration', 'isEndGenericMap')
|
||||
|
|
|
|||
|
|
@ -1,24 +1,11 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_008(rule.rule):
|
||||
class rule_008(indent_rule):
|
||||
'''
|
||||
Generic rule 008 checks the indentation of closing parenthesis for generic maps.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'generic', '008')
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEndGenericMap and not oLine.isGenericDeclaration:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
indent_rule.__init__(self, 'generic', '008', 'isEndGenericMap', 'isGenericDeclaration')
|
||||
|
|
|
|||
|
|
@ -9,12 +9,3 @@ class rule_001(indent_rule):
|
|||
|
||||
def __init__(self):
|
||||
indent_rule.__init__(self, 'package', '001', 'isPackageKeyword')
|
||||
|
||||
# def analyze(self, oFile):
|
||||
# for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
# if oLine.isPackageKeyword or oLine.isPackageEnd:
|
||||
# check.indent(self, oLine, iLineNumber)
|
||||
#
|
||||
# def _fix_violations(self, oFile):
|
||||
# for iLineNumber in self.violations:
|
||||
# fix.indent(self, oFile.lines[iLineNumber])
|
||||
|
|
|
|||
|
|
@ -1,24 +1,12 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_004(rule.rule):
|
||||
class rule_004(indent_rule):
|
||||
'''
|
||||
Port rule 004 checks indentation of ports.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'port', '004')
|
||||
indent_rule.__init__(self, 'port', '004', 'isPortDeclaration', 'isEndPortMap')
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isPortDeclaration and not oLine.isEndPortMap:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
|
|
|
|||
|
|
@ -1,24 +1,12 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_015(rule.rule):
|
||||
class rule_015(indent_rule):
|
||||
'''
|
||||
Port rule 015 checks the indentation of closing parenthesis for port maps.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'port', '015')
|
||||
indent_rule.__init__(self, 'port', '015', 'isEndPortMap', 'isPortDeclaration')
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEndPortMap and not oLine.isPortDeclaration:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
|
|
|
|||
|
|
@ -1,24 +1,12 @@
|
|||
|
||||
from vsg import rule
|
||||
from vsg import check
|
||||
from vsg import fix
|
||||
from vsg.rules import indent_rule
|
||||
|
||||
|
||||
class rule_005(rule.rule):
|
||||
class rule_005(indent_rule):
|
||||
'''
|
||||
Type rule 005 checks for the proper indentation of multiline types.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
rule.rule.__init__(self, 'type', '005')
|
||||
indent_rule.__init__(self, 'type', '005', 'insideTypeEnumerated', 'isTypeEnumeratedKeyword')
|
||||
self.solution = 'Ensure proper indentation.'
|
||||
self.phase = 4
|
||||
|
||||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.insideTypeEnumerated and not oLine.isTypeEnumeratedKeyword and not oLine.isBlank:
|
||||
check.indent(self, oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
fix.indent(self, oFile.lines[iLineNumber])
|
||||
|
|
|
|||
Loading…
Reference in New Issue