Skip to content

Commit 5f20f07

Browse files
Adding rule interface_incomplete_type_declaration_600.
1 parent 0c47558 commit 5f20f07

File tree

9 files changed

+178
-39
lines changed

9 files changed

+178
-39
lines changed

docs/configuring_disabled_rules.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Rules Disabled by Default
5959
* `generic_map_601 <generic_map_rules.html#generic-map-601>`_
6060
* `instantiation_600 <instantiation_rules.html#instantiation-600>`_
6161
* `instantiation_601 <instantiation_rules.html#instantiation-601>`_
62+
63+
* `interface_incomplete_type_declaration_600 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-600>`_
64+
6265
* `loop_statement_006 <loop_statement_rules.html#loop-statement-006>`_
6366
* `loop_statement_007 <loop_statement_rules.html#loop-statement-007>`_
6467
* `loop_statement_600 <loop_statement_rules.html#loop-statement-600>`_

docs/configuring_prefix_and_suffix_rules.rst

Lines changed: 41 additions & 39 deletions
Large diffs are not rendered by default.

docs/interface_incomplete_type_declaration_rules.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,28 @@ This rule checks the type name has proper case.
4848
4949
generic (
5050
type generic_data_type
51+
52+
interface_incomplete_type_declaration_600
53+
#########################################
54+
55+
|phase_7| |disabled| |error| |unfixable| |naming|
56+
57+
This rule checks for valid prefixes of type names.
58+
59+
.. NOTE:: The default prefix is *gt_*.
60+
61+
|configuring_prefix_and_suffix_rules_link|
62+
63+
**Violation**
64+
65+
.. code-block:: vhdl
66+
67+
generic (
68+
type generic_data_type
69+
70+
**Fix**
71+
72+
.. code-block:: vhdl
73+
74+
generic (
75+
type gt_generic_data_type

docs/rule_groups/naming_rule_group.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Rules Enforcing Naming Rule Group
2424
* `generic_map_601 <../generic_map_rules.html#generic-map-601>`_
2525
* `instantiation_600 <../instantiation_rules.html#instantiation-600>`_
2626
* `instantiation_601 <../instantiation_rules.html#instantiation-601>`_
27+
28+
* `interface_incomplete_type_declaration_600 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-600>`_
29+
2730
* `loop_statement_600 <../loop_statement_rules.html#loop-statement-600>`_
2831
* `loop_statement_601 <../loop_statement_rules.html#loop-statement-601>`_
2932
* `loop_statement_602 <../loop_statement_rules.html#loop-statement-602>`_

docs/unfixable_rules.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ With multiple options available, the user is required to make the decision.
103103
* `generic_map_601 <generic_map_rules.html#generic-map-601>`_
104104
* `instantiation_600 <instantiation_rules.html#instantiation-600>`_
105105
* `instantiation_601 <instantiation_rules.html#instantiation-601>`_
106+
107+
* `interface_incomplete_type_declaration_600 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-600>`_
108+
106109
* `loop_statement_600 <loop_statement_rules.html#loop-statement-600>`_
107110
* `loop_statement_601 <loop_statement_rules.html#loop-statement-601>`_
108111
* `loop_statement_602 <loop_statement_rules.html#loop-statement-602>`_
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
entity fifo is
3+
generic (
4+
type gt_generic_data_type;
5+
type generic_data_type;
6+
type t_generic_data_type
7+
);
8+
port (
9+
data_in : generic_data_type
10+
);
11+
end entity fifo;
12+
13+
architecture rtl of fifo is
14+
15+
component buffer is
16+
generic (
17+
type gt_generic_data_type;
18+
type generic_data_type;
19+
type t_generic_data_type
20+
);
21+
port (
22+
data_in : generic_data_type
23+
);
24+
end component buffer;
25+
26+
begin
27+
28+
buf1 : buffer
29+
generic map (
30+
generic_data_type => std_logic
31+
)
32+
port map (
33+
data_in => '0'
34+
);
35+
36+
end architecture rtl;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
import unittest
5+
6+
from tests import utils
7+
from vsg import vhdlFile
8+
from vsg.rules import interface_incomplete_type_declaration
9+
10+
sTestDir = os.path.dirname(__file__)
11+
12+
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_600_test_input.vhd"))
13+
14+
15+
class test_rule(unittest.TestCase):
16+
def setUp(self):
17+
self.oFile = vhdlFile.vhdlFile(lFile)
18+
self.assertIsNone(eError)
19+
20+
def test_rule_600(self):
21+
oRule = interface_incomplete_type_declaration.rule_600()
22+
self.assertTrue(oRule)
23+
self.assertEqual(oRule.name, "interface_incomplete_type_declaration")
24+
self.assertEqual(oRule.identifier, "600")
25+
26+
lExpected = [5, 6, 18, 19]
27+
28+
oRule.analyze(self.oFile)
29+
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

vsg/rules/interface_incomplete_type_declaration/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
from .rule_500 import rule_500
44
from .rule_501 import rule_501
5+
6+
from .rule_600 import rule_600
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from vsg import token
4+
from vsg.rules import token_prefix
5+
6+
lTokens = []
7+
lTokens.append(token.interface_incomplete_type_declaration.identifier)
8+
9+
10+
class rule_600(token_prefix):
11+
"""
12+
This rule checks for valid prefixes of type names.
13+
14+
.. NOTE:: The default prefix is *gt_*.
15+
16+
|configuring_prefix_and_suffix_rules_link|
17+
18+
**Violation**
19+
20+
.. code-block:: vhdl
21+
22+
generic (
23+
type generic_data_type
24+
25+
**Fix**
26+
27+
.. code-block:: vhdl
28+
29+
generic (
30+
type gt_generic_data_type
31+
"""
32+
33+
def __init__(self):
34+
super().__init__(lTokens)
35+
self.prefixes = ["gt_"]
36+
self.solution = "Type identifiers"

0 commit comments

Comments
 (0)