Merge pull request #313 from m-kru/master

Fix case rules for process rules.
This commit is contained in:
Jeremiah Leary 2020-01-01 17:35:41 -06:00 committed by GitHub
commit 0d42e6ff48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 89 deletions

View File

@ -74,7 +74,9 @@ This rule checks the indent of the **begin** keyword.
process_004
###########
This rule checks the begin keyword is lowercase.
This rule checks the **begin** keyword has proper case.
.. NOTE:: The default is lowercase.
**Violation**
@ -97,7 +99,9 @@ This rule checks the begin keyword is lowercase.
process_005
###########
This rule checks the process keyword is lowercase.
This rule checks the **process** keyword has proper case.
.. NOTE:: The default is lowercase.
**Violation**
@ -160,7 +164,7 @@ process_008
This rule checks the **end** keyword has proper case.
.. NOTE:: The default is lowercase.
.. NOTE:: The default is lowercase.
Refer to the section `Configuring Uppercase and Lowercase Rules <configuring_case.html>`_ for information on changing the default case.
@ -179,7 +183,9 @@ This rule checks the **end** keyword has proper case.
process_009
###########
This rule checks the **process** keyword is lowercase in the **end process** line.
This rule checks the **process** keyword has proper case in the **end process** line.
.. NOTE:: The default is lowercase.
**Violation**
@ -271,7 +277,9 @@ This rule checks for the existence of the **is** keyword on the same line as the
process_013
###########
This rule checks the **is** keyword is lowercase.
This rule checks the **is** keyword has proper case.
.. NOTE:: The default is lowercase.
**Violation**
@ -366,7 +374,9 @@ This rule checks the process has a label.
process_017
###########
This rule checks the process label is uppercase.
This rule checks the process label has proper case.
.. NOTE:: The default is uppercase.
**Violation**

View File

@ -1,26 +1,16 @@
from vsg import rule
from vsg.rules import case_rule
from vsg import utils
from vsg import fix
from vsg import check
class rule_004(rule.rule):
class rule_004(case_rule):
'''
Process rule 004 checks the "begin" keyword is lower case.
Process rule 004 checks the "begin" keyword has proper case.
'''
def __init__(self):
rule.rule.__init__(self)
self.name = 'process'
self.identifier = '004'
self.solution = 'Lowercase the "begin" keyword.'
self.phase = 6
case_rule.__init__(self, 'process', '004', 'isProcessBegin')
self.solution = 'Change "begin" keyword to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isProcessBegin:
check.is_lowercase(self, utils.get_first_word(oLine), 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_words(oLine, ['begin'])

View File

@ -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_005(rule.rule):
class rule_005(case_rule):
'''
Process rule 004 checks the "process" keyword is lower case.
Process rule 004 checks the "process" keyword has proper case.
'''
def __init__(self):
rule.rule.__init__(self, 'process', '005')
self.solution = 'Lowercase the "process" keyword.'
self.phase = 6
case_rule.__init__(self, 'process', '005', 'isProcessKeyword')
self.solution = 'Change "process" keyword to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isProcessKeyword and not re.match('^\s*.*process', oLine.line):
self.add_violation(iLineNumber)
def _fix_violations(self, oFile):
for iLineNumber in self.violations:
fix.lower_case(oFile.lines[iLineNumber], 'process')
def _extract(self, oLine):
return utils.extract_words(oLine, ['process'])

View File

@ -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_009(rule.rule):
class rule_009(case_rule):
'''
Process rule 009 checks the "process" keyword is lowercase on the closing of a process.
Process rule 009 checks the "process" keyword has proper case on the closing of a process.
'''
def __init__(self):
rule.rule.__init__(self, 'process', '009')
self.solution = 'Lowercase the "process" keyword.'
self.phase = 6
case_rule.__init__(self, 'process', '009', 'isEndProcess')
self.solution = 'Change "process" keyword to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isEndProcess and not re.match('^\s*\w+\s+process', oLine.line):
self.add_violation(iLineNumber)
def _fix_violations(self, oFile):
for iLineNumber in self.violations:
fix.lower_case(oFile.lines[iLineNumber], 'process')
def _extract(self, oLine):
return utils.extract_words(oLine, ['process'])

View File

@ -1,25 +1,16 @@
from vsg import rule
from vsg import fix
import re
from vsg.rules import case_rule
from vsg import utils
class rule_013(rule.rule):
class rule_013(case_rule):
'''
Process rule 013 checks the "is" keyword is lowercase.
Process rule 013 checks the "is" keyword has proper case.
'''
def __init__(self):
rule.rule.__init__(self, 'process', '013')
self.solution = 'Lowercase "is" keyword.'
self.phase = 6
case_rule.__init__(self, 'process', '013', 'isSensitivityListEnd')
self.solution = 'Change "is" keyword to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isSensitivityListEnd and re.match('^.*\)\s*is', oLine.lineLower):
if not re.match('^.*\)\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_words(oLine, ['is'])

View File

@ -1,25 +1,17 @@
from vsg import rule
from vsg import check
from vsg import fix
from vsg.rules import case_rule
from vsg import utils
class rule_017(rule.rule):
class rule_017(case_rule):
'''
Process rule 017 checks the process label is uppercase.
Process rule 017 checks the process label has proper case.
'''
def __init__(self):
rule.rule.__init__(self, 'process', '017')
self.solution = 'Uppercase process label.'
self.phase = 6
case_rule.__init__(self, 'process', '017', 'isProcessLabel')
self.case = 'upper'
self.solution = 'Change label name to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isProcessLabel:
lLine = oLine.line.split(':')
check.is_uppercase(self, lLine[0], iLineNumber)
def _fix_violations(self, oFile):
for iLineNumber in self.violations:
lLine = oFile.lines[iLineNumber].line.split(':')
fix.upper_case(oFile.lines[iLineNumber], lLine[0].rstrip().lstrip())
def _extract(self, oLine):
return utils.extract_label(oLine)