Skip to content

Commit 0c47558

Browse files
Adding rule interface_incomplete_type_declaration_501.
1 parent 863b9d4 commit 0c47558

File tree

10 files changed

+243
-0
lines changed

10 files changed

+243
-0
lines changed

docs/configuring_uppercase_and_lowercase_rules.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ Rules Enforcing Case
417417
* `instantiation_500 <instantiation_rules.html#instantiation-500>`_
418418

419419
* `interface_incomplete_type_declaration_500 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-500>`_
420+
* `interface_incomplete_type_declaration_501 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-501>`_
420421

421422
* `iteration_scheme_500 <iteration_scheme_rules.html#iteration-scheme-500>`_
422423
* `iteration_scheme_501 <iteration_scheme_rules.html#iteration-scheme-501>`_

docs/interface_incomplete_type_declaration_rules.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,26 @@ This rule checks the **type** keyword has proper case.
2525
2626
generic (
2727
type generic_data_type
28+
29+
interface_incomplete_type_declaration_501
30+
#########################################
31+
32+
|phase_6| |error| |case| |case_name|
33+
34+
This rule checks the type name has proper case.
35+
36+
|configuring_uppercase_and_lowercase_rules_link|
37+
38+
**Violation**
39+
40+
.. code-block:: vhdl
41+
42+
generic (
43+
type GENERIC_DATA_TYPE
44+
45+
**Fix**
46+
47+
.. code-block:: vhdl
48+
49+
generic (
50+
type generic_data_type

docs/rule_groups/case_name_rule_group.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Rules Enforcing Case::Name Rule Group
3232
* `instantiation_009 <../instantiation_rules.html#instantiation-009>`_
3333
* `instantiation_028 <../instantiation_rules.html#instantiation-028>`_
3434
* `instantiation_500 <../instantiation_rules.html#instantiation-500>`_
35+
36+
* `interface_incomplete_type_declaration_501 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-501>`_
37+
3538
* `library_500 <../library_rules.html#library-500>`_
3639
* `package_008 <../package_rules.html#package-008>`_
3740
* `package_010 <../package_rules.html#package-010>`_

docs/rule_groups/case_rule_group.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ Rules Enforcing Case Rule Group
145145
* `instantiation_028 <../instantiation_rules.html#instantiation-028>`_
146146
* `instantiation_031 <../instantiation_rules.html#instantiation-031>`_
147147
* `instantiation_500 <../instantiation_rules.html#instantiation-500>`_
148+
148149
* `interface_incomplete_type_declaration_500 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-500>`_
150+
* `interface_incomplete_type_declaration_501 <../interface_incomplete_type_declaration_rules.html#interface-incomplete-type-declaration-501>`_
151+
149152
* `iteration_scheme_500 <../iteration_scheme_rules.html#iteration-scheme-500>`_
150153
* `iteration_scheme_501 <../iteration_scheme_rules.html#iteration-scheme-501>`_
151154
* `library_004 <../library_rules.html#library-004>`_
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 generic_data_type;
5+
type generic_data_type;
6+
type 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 generic_data_type;
18+
type generic_data_type;
19+
type 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: 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 GENERIC_DATA_TYPE;
5+
type GENERIC_DATA_TYPE;
6+
type 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 GENERIC_DATA_TYPE;
18+
type GENERIC_DATA_TYPE;
19+
type 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: 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 generic_data_type;
5+
type Generic_Data_Type;
6+
type 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 generic_data_type;
18+
type Generic_Data_Type;
19+
type 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: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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_501_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_501_lower(self):
21+
oRule = interface_incomplete_type_declaration.rule_501()
22+
self.assertTrue(oRule)
23+
self.assertEqual(oRule.name, "interface_incomplete_type_declaration")
24+
self.assertEqual(oRule.identifier, "501")
25+
26+
lExpected = [5, 6, 18, 19]
27+
28+
oRule.analyze(self.oFile)
29+
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
30+
31+
def test_fix_rule_501_lower(self):
32+
oRule = interface_incomplete_type_declaration.rule_501()
33+
34+
oRule.fix(self.oFile)
35+
36+
lExpected = []
37+
lExpected.append("")
38+
utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_lower.vhd"), lExpected)
39+
40+
lActual = self.oFile.get_lines()
41+
42+
self.assertEqual(lExpected, lActual)
43+
44+
oRule.analyze(self.oFile)
45+
self.assertEqual(oRule.violations, [])
46+
47+
def test_rule_501_upper(self):
48+
oRule = interface_incomplete_type_declaration.rule_501()
49+
oRule.case = "upper"
50+
51+
lExpected = [4, 5, 17, 18]
52+
53+
oRule.analyze(self.oFile)
54+
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)
55+
56+
def test_fix_rule_501_upper(self):
57+
oRule = interface_incomplete_type_declaration.rule_501()
58+
oRule.case = "upper"
59+
60+
oRule.fix(self.oFile)
61+
62+
lExpected = []
63+
lExpected.append("")
64+
utils.read_file(os.path.join(sTestDir, "rule_501_test_input.fixed_upper.vhd"), lExpected)
65+
66+
lActual = self.oFile.get_lines()
67+
68+
self.assertEqual(lExpected, lActual)
69+
70+
oRule.analyze(self.oFile)
71+
self.assertEqual(oRule.violations, [])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# -*- coding: utf-8 -*-
22

33
from .rule_500 import rule_500
4+
from .rule_501 import rule_501
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from vsg import token
4+
from vsg.rules import token_case_with_prefix_suffix
5+
6+
lTokens = []
7+
lTokens.append(token.interface_incomplete_type_declaration.identifier)
8+
9+
10+
class rule_501(token_case_with_prefix_suffix):
11+
"""
12+
This rule checks the type name has proper case.
13+
14+
|configuring_uppercase_and_lowercase_rules_link|
15+
16+
**Violation**
17+
18+
.. code-block:: vhdl
19+
20+
generic (
21+
type GENERIC_DATA_TYPE
22+
23+
**Fix**
24+
25+
.. code-block:: vhdl
26+
27+
generic (
28+
type generic_data_type
29+
"""
30+
31+
def __init__(self):
32+
super().__init__(lTokens)
33+
self.groups.append("case::name")

0 commit comments

Comments
 (0)