Fix case rules for variable rules.

This commit is contained in:
Michał Kruszewski 2019-12-06 10:44:30 +01:00
parent e38a13c1f2
commit ca1eeae7e4
10 changed files with 19 additions and 37 deletions

View File

@ -172,7 +172,9 @@ This rule checks the alignment of colons over multiple lines in the architecture
variable_010
############
This rule checks the variable type is lowercase.
This rule checks the variable type has proper case.
.. NOTE:: The default is lowercase.
**Violation**

View File

@ -4,7 +4,7 @@ from vsg.rules import indent_rule
class rule_001(indent_rule):
'''
Signal rule 001 checks for the proper indentation at the beginning of the line.
Variable rule 001 checks for the proper indentation at the beginning of the line.
'''
def __init__(self):

View File

@ -5,7 +5,7 @@ from vsg import utils
class rule_002(case_rule):
'''
Signal rule 002 checks the "variable" keyword has proper case.
Variable rule 002 checks the "variable" keyword has proper case.
'''
def __init__(self):

View File

@ -4,7 +4,7 @@ from vsg.rules import single_space_after_rule
class rule_003(single_space_after_rule):
'''
Signal rule 003 checks there is a single space after the "variable" keyword.
Variable rule 003 checks there is a single space after the "variable" keyword.
'''
def __init__(self):

View File

@ -4,7 +4,7 @@ from vsg.rules import single_space_after_character_rule
class rule_005(single_space_after_character_rule):
'''
Signal rule 005 checks there is a single space after the colon.
Variable rule 005 checks there is a single space after the colon.
'''
def __init__(self):

View File

@ -4,7 +4,7 @@ from vsg.rules import single_space_before_character_rule
class rule_006(single_space_before_character_rule):
'''
Signal rule 006 checks there is at least a single space before the colon.
Variable rule 006 checks there is at least a single space before the colon.
'''
def __init__(self):

View File

@ -4,7 +4,7 @@ from vsg import rule
class rule_007(rule.rule):
'''
Signal rule 007 checks for default assignments in variable declarations.
Variable rule 007 checks for default assignments in variable declarations.
'''
def __init__(self):

View File

@ -4,7 +4,7 @@ from vsg.rules import keyword_alignment_rule
class rule_009(keyword_alignment_rule):
'''
Signal rule 009 checks the colons are in the same column for all variables.
Variable rule 009 checks the colons are in the same column for all variables.
'''
def __init__(self):

View File

@ -1,36 +1,16 @@
from vsg import rule
from vsg import fix
from vsg import check
import re
from vsg.rules import case_rule
from vsg import utils
class rule_010(rule.rule):
class rule_010(case_rule):
'''
Signal rule 010 checks the variable type is lowercase.
Variable rule 010 checks the variable type has proper case.
'''
def __init__(self):
rule.rule.__init__(self, 'variable', '010')
self.solution = 'Change variable type to lowercase.'
self.phase = 6
case_rule.__init__(self, 'variable', '010', 'isVariable')
self.solution = 'Change variable type name to '
def _analyze(self, oFile, oLine, iLineNumber):
if oLine.isVariable:
if re.match('^\s*variable\s+.*:\s*\w', oLine.lineLower):
sLine = oLine.line.split(':')[1].lstrip().rstrip().replace(';', '')
sLine = re.sub('range\s+.*$', ' ', sLine)
if '(' in sLine:
check.is_lowercase(self, sLine.split('(')[0], iLineNumber)
else:
check.is_lowercase(self, sLine, iLineNumber)
def _fix_violations(self, oFile):
for iLineNumber in self.violations:
oLine = oFile.lines[iLineNumber]
sLine = oLine.line.split(':')[1].lstrip().rstrip().replace(';', '')
if '(' in sLine:
fix.lower_case(oFile.lines[iLineNumber], sLine.split('(')[0])
else:
fix.lower_case(oFile.lines[iLineNumber], sLine)
def _extract(self, oLine):
return utils.extract_type_name(oLine)

View File

@ -5,7 +5,7 @@ from vsg import utils
class rule_011(rule.rule):
'''
General rule 011 checks capitalization consistency of variable names.
Variable rule 011 checks capitalization consistency of variable names.
'''
def __init__(self):