Merge pull request #436 from marph91/prefix-generate-process
Added rules for generate and process label prefixes
This commit is contained in:
commit
c778fc8a75
|
|
@ -312,3 +312,23 @@ This rule checks the alignment of the **when** keyword in generic case statement
|
|||
when 0 =>
|
||||
when 1 =>
|
||||
when 2 =>
|
||||
|
||||
generate_017
|
||||
############
|
||||
|
||||
This rule checks for valid prefixes on generic statement labels.
|
||||
The default prefix is *gen\_*.
|
||||
|
||||
Refer to the section `Configuring Prefix and Suffix Rules <configuring_prefix_suffix.html>`_ for information on changing the allowed prefixes.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
label : case condition generate
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
gen_label : case condition generate
|
||||
|
|
|
|||
|
|
@ -890,3 +890,22 @@ Refer to the section `Configuring Keyword Alignment Rules <configuring_keyword_a
|
|||
|
||||
end process proc_1;
|
||||
|
||||
process_036
|
||||
############
|
||||
|
||||
This rule checks for valid prefixes on process labels.
|
||||
The default prefix is *proc\_*.
|
||||
|
||||
Refer to the section `Configuring Prefix and Suffix Rules <configuring_prefix_suffix.html>`_ for information on changing the allowed prefixes.
|
||||
|
||||
**Violation**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
main: process () is
|
||||
|
||||
**Fix**
|
||||
|
||||
.. code-block:: vhdl
|
||||
|
||||
proc_main: process () is
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class rule_015(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'constant', '015', 'isConstant')
|
||||
self.prefixes = ['c_']
|
||||
self.solution = 'Constant'
|
||||
self.solution = 'Constant identifiers'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_class_identifier_list(oLine)
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ from .rule_013 import rule_013
|
|||
from .rule_014 import rule_014
|
||||
from .rule_015 import rule_015
|
||||
from .rule_016 import rule_016
|
||||
from .rule_017 import rule_017
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
from vsg.rules import prefix_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_017(prefix_rule):
|
||||
'''
|
||||
Generate rule 017 checks for prefixes in generate statement labels.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'generate', '017', 'isGenerateLabel')
|
||||
self.prefixes = ['gen_']
|
||||
self.solution = 'Generate label'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_label(oLine)
|
||||
|
|
@ -11,7 +11,7 @@ class rule_020(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'generic', '020', 'isGenericDeclaration')
|
||||
self.prefixes = ['g_']
|
||||
self.solution = 'Generic'
|
||||
self.solution = 'Generic names'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_generics(oLine)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class rule_017(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'package', '017', 'isPackageKeyword')
|
||||
self.prefixes = ['pkg_']
|
||||
self.solution = 'Package'
|
||||
self.solution = 'Package identifier'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return [oLine.line.split()[1]]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class rule_011(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'port', '011', 'isPortDeclaration')
|
||||
self.prefixes = ['i_', 'o_', 'io_']
|
||||
self.solution = 'Port'
|
||||
self.solution = 'Port names'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_port_name(oLine)
|
||||
|
|
|
|||
|
|
@ -51,4 +51,4 @@ class prefix_rule(rule.rule):
|
|||
check.has_prefix(self, self.prefixes, words, iLineNumber)
|
||||
|
||||
def _get_solution(self, iLineNumber):
|
||||
return self.solution + ' identifiers should start with one of ' + str(self.prefixes) + ' prefixes.'
|
||||
return self.solution + ' should start with one of ' + str(self.prefixes) + ' prefixes.'
|
||||
|
|
|
|||
|
|
@ -34,3 +34,4 @@ from .rule_032 import rule_032
|
|||
from .rule_033 import rule_033
|
||||
from .rule_034 import rule_034
|
||||
from .rule_035 import rule_035
|
||||
from .rule_036 import rule_036
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
from vsg.rules import prefix_rule
|
||||
from vsg import utils
|
||||
|
||||
|
||||
class rule_036(prefix_rule):
|
||||
'''
|
||||
Process rule 036 checks for prefixes in process labels.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'process', '036', 'isProcessLabel')
|
||||
self.prefixes = ['proc_']
|
||||
self.solution = 'Process labels'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_label(oLine)
|
||||
|
|
@ -11,7 +11,7 @@ class rule_008(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'signal', '008', 'isSignal')
|
||||
self.prefixes = ['s_']
|
||||
self.solution = 'Signal'
|
||||
self.solution = 'Signal identifiers'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_class_identifier_list(oLine)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class rule_004(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'subtype', '004', 'isSubtypeKeyword')
|
||||
self.prefixes = ['st_']
|
||||
self.solution = 'Subtype'
|
||||
self.solution = 'Subtype identifiers'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_type_identifier(oLine)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class rule_015(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'type', '015', 'isTypeKeyword')
|
||||
self.prefixes = ['t_']
|
||||
self.solution = 'Type'
|
||||
self.solution = 'Type identifiers'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_type_identifier(oLine)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class rule_012(prefix_rule):
|
|||
def __init__(self):
|
||||
prefix_rule.__init__(self, 'variable', '012', 'isVariable')
|
||||
self.prefixes = ['v_']
|
||||
self.solution = 'Variable'
|
||||
self.solution = 'Variable identifiers'
|
||||
|
||||
def _extract(self, oLine):
|
||||
return utils.extract_class_identifier_list(oLine)
|
||||
|
|
|
|||
|
|
@ -239,3 +239,20 @@ class testRuleGenerateMethods(unittest.TestCase):
|
|||
dExpected = [utils.add_violation(104)]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_017_with_default(self):
|
||||
oRule = generate.rule_017()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'generate')
|
||||
self.assertEqual(oRule.identifier, '017')
|
||||
lExpected = utils.add_violation_list([6,11,16,21,26,31,36,41,46,51,56,
|
||||
60,65,68,71,77,83,88,90,94,104])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
||||
def test_rule_017_with_override(self):
|
||||
oRule = generate.rule_017()
|
||||
oRule.prefixes = ['generate_', 'g_']
|
||||
lExpected = utils.add_violation_list([])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
|
|
|||
|
|
@ -373,3 +373,19 @@ class testRuleProcessMethods(unittest.TestCase):
|
|||
dExpected = utils.add_violation_list([26,34])
|
||||
oRule.analyze(oFileSensitivity)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_036_with_default(self):
|
||||
oRule = process.rule_036()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'process')
|
||||
self.assertEqual(oRule.identifier, '036')
|
||||
lExpected = utils.add_violation_list([63, 116, 140, 152, 157])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
||||
def test_rule_036_with_override(self):
|
||||
oRule = process.rule_036()
|
||||
oRule.prefixes = ['test_', 'p']
|
||||
lExpected = utils.add_violation_list([63, 116, 152])
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, lExpected)
|
||||
|
|
|
|||
Loading…
Reference in New Issue