Skip to content

Commit 4dfbf9a

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue-1488
2 parents 718e2e1 + f621642 commit 4dfbf9a

38 files changed

+894
-11
lines changed

docs/configuring_whitespace_rules.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ Rules Enforcing Whitespace
214214
* `if_005 <if_rules.html#if-005>`_
215215
* `if_015 <if_rules.html#if-015>`_
216216
* `index_constraint_100 <index_constraint_rules.html#index-constraint-100>`_
217+
* `index_subtype_definition_100 <index_subtype_definition_rules.html#index-subtype-definition-100>`_
218+
* `index_subtype_definition_101 <index_subtype_definition_rules.html#index-subtype-definition-101>`_
217219
* `instantiation_002 <instantiation_rules.html#instantiation-002>`_
218220
* `instantiation_003 <instantiation_rules.html#instantiation-003>`_
219221
* `instantiation_032 <instantiation_rules.html#instantiation-032>`_
@@ -251,6 +253,8 @@ Rules Enforcing Whitespace
251253
* `process_014 <process_rules.html#process-014>`_
252254
* `process_024 <process_rules.html#process-024>`_
253255
* `process_025 <process_rules.html#process-025>`_
256+
* `range_constraint_100 <range_constraint_rules.html#range-constraint-100>`_
257+
* `range_constraint_101 <range_constraint_rules.html#range-constraint-101>`_
254258
* `record_type_definition_100 <record_type_definition_rules.html#record-type-definition-100>`_
255259
* `record_type_definition_101 <record_type_definition_rules.html#record-type-definition-101>`_
256260
* `report_statement_100 <report_statement_rules.html#report-statement-100>`_
@@ -290,3 +294,5 @@ Rules Enforcing Whitespace
290294
* `variable_assignment_002 <variable_assignment_rules.html#variable-assignment-002>`_
291295
* `variable_assignment_003 <variable_assignment_rules.html#variable-assignment-003>`_
292296
* `whitespace_007 <whitespace_rules.html#whitespace-007>`_
297+
* `whitespace_102 <whitespace_rules.html#whitespace-102>`_
298+
* `whitespace_103 <whitespace_rules.html#whitespace-103>`_

docs/index_subtype_definition_rules.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,48 @@
33
Index Subtype Definition Rules
44
------------------------------
55

6+
index_subtype_definition_100
7+
############################
8+
9+
|phase_2| |error| |whitespace|
10+
11+
This rule checks for a single space before the **range** keyword.
12+
13+
|configuring_whitespace_rules_link|
14+
15+
**Violation**
16+
17+
.. code-block:: vhdl
18+
19+
type my_array is array (natural range <>) of integer;
20+
21+
**Fix**
22+
23+
.. code-block:: vhdl
24+
25+
type my_array is array (natural range <>) of integer;
26+
27+
index_subtype_definition_101
28+
############################
29+
30+
|phase_2| |error| |whitespace|
31+
32+
This rule checks for a single space after the **range** keyword.
33+
34+
|configuring_whitespace_rules_link|
35+
36+
**Violation**
37+
38+
.. code-block:: vhdl
39+
40+
type my_array is array (natural range <>) of integer;
41+
42+
**Fix**
43+
44+
.. code-block:: vhdl
45+
46+
type my_array is array (natural range <>) of integer;
47+
648
index_subtype_definition_500
749
############################
850

docs/range_constraint_rules.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,48 @@
33
Range Constraint Rules
44
----------------------
55

6+
range_constraint_100
7+
####################
8+
9+
|phase_2| |error| |whitespace|
10+
11+
This rule checks for a single space before the **range** keyword.
12+
13+
|configuring_whitespace_rules_link|
14+
15+
**Violation**
16+
17+
.. code-block:: vhdl
18+
19+
subtype my_range is natural range 0 to 7;
20+
21+
**Fix**
22+
23+
.. code-block:: vhdl
24+
25+
subtype my_range is natural range 0 to 7;
26+
27+
range_constraint_101
28+
####################
29+
30+
|phase_2| |error| |whitespace|
31+
32+
This rule checks for a single space after the **range** keyword.
33+
34+
|configuring_whitespace_rules_link|
35+
36+
**Violation**
37+
38+
.. code-block:: vhdl
39+
40+
subtype my_range is natural range 0 to 7;
41+
42+
**Fix**
43+
44+
.. code-block:: vhdl
45+
46+
subtype my_range is natural range 0 to 7;
47+
648
range_constraint_500
749
####################
850

docs/rule_groups/whitespace_rule_group.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Rules Enforcing Whitespace Rule Group
108108
* `if_005 <../if_rules.html#if-005>`_
109109
* `if_015 <../if_rules.html#if-015>`_
110110
* `index_constraint_100 <../index_constraint_rules.html#index-constraint-100>`_
111+
* `index_subtype_definition_100 <../index_subtype_definition_rules.html#index-subtype-definition-100>`_
112+
* `index_subtype_definition_101 <../index_subtype_definition_rules.html#index-subtype-definition-101>`_
111113
* `instantiation_002 <../instantiation_rules.html#instantiation-002>`_
112114
* `instantiation_003 <../instantiation_rules.html#instantiation-003>`_
113115
* `instantiation_032 <../instantiation_rules.html#instantiation-032>`_
@@ -148,6 +150,8 @@ Rules Enforcing Whitespace Rule Group
148150
* `process_014 <../process_rules.html#process-014>`_
149151
* `process_024 <../process_rules.html#process-024>`_
150152
* `process_025 <../process_rules.html#process-025>`_
153+
* `range_constraint_100 <../range_constraint_rules.html#range-constraint-100>`_
154+
* `range_constraint_101 <../range_constraint_rules.html#range-constraint-101>`_
151155
* `record_type_definition_100 <../record_type_definition_rules.html#record-type-definition-100>`_
152156
* `record_type_definition_101 <../record_type_definition_rules.html#record-type-definition-101>`_
153157
* `report_statement_100 <../report_statement_rules.html#report-statement-100>`_
@@ -198,3 +202,5 @@ Rules Enforcing Whitespace Rule Group
198202
* `whitespace_013 <../whitespace_rules.html#whitespace-013>`_
199203
* `whitespace_100 <../whitespace_rules.html#whitespace-100>`_
200204
* `whitespace_101 <../whitespace_rules.html#whitespace-101>`_
205+
* `whitespace_102 <../whitespace_rules.html#whitespace-102>`_
206+
* `whitespace_103 <../whitespace_rules.html#whitespace-103>`_

docs/whitespace_rules.rst

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ whitespace_005
9191
This rule checks for spaces after an open parenthesis.
9292

9393
.. NOTE::
94-
Spaces before numbers are allowed.
94+
Spaces before numbers are ignored.
95+
This can be disabled by setting the *'ignore_spaces_before_numbers'* attribute to *'False'*.
9596

9697
**Violation**
9798

@@ -274,6 +275,52 @@ This rule checks for at least a single space before and after logical operators.
274275
if (a = '1') sll (b = '0')
275276
if (a = '0') rol (b = '1')
276277
278+
whitespace_102
279+
##############
280+
281+
|phase_2| |error| |whitespace|
282+
283+
This rule checks for a single space before direction keywords.
284+
285+
|configuring_whitespace_rules_link|
286+
287+
**Violation**
288+
289+
.. code-block:: vhdl
290+
291+
x <= y(7 downto 0);
292+
x <= y(0 to 7);
293+
294+
**Fix**
295+
296+
.. code-block:: vhdl
297+
298+
x <= y(7 downto 0);
299+
x <= y(0 to 7);
300+
301+
whitespace_103
302+
##############
303+
304+
|phase_2| |error| |whitespace|
305+
306+
This rule checks for a single space after direction keywords.
307+
308+
|configuring_whitespace_rules_link|
309+
310+
**Violation**
311+
312+
.. code-block:: vhdl
313+
314+
x <= y(7 downto 0);
315+
x <= y(0 to 7);
316+
317+
**Fix**
318+
319+
.. code-block:: vhdl
320+
321+
x <= y(7 downto 0);
322+
x <= y(0 to 7);
323+
277324
whitespace_200
278325
##############
279326

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
architecture RTL of FIFO is
3+
4+
-- Passing
5+
6+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
7+
8+
-- Violation below
9+
10+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
11+
12+
begin
13+
14+
end architecture RTL;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
architecture RTL of FIFO is
3+
4+
-- Passing
5+
6+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
7+
8+
-- Violation below
9+
10+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
11+
12+
begin
13+
14+
end architecture RTL;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
architecture RTL of FIFO is
3+
4+
-- Passing
5+
6+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
7+
8+
-- Violation below
9+
10+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
11+
12+
begin
13+
14+
end architecture RTL;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
architecture RTL of FIFO is
3+
4+
-- Passing
5+
6+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
7+
8+
-- Violation below
9+
10+
type my_array is array (natural range <>) of std_logic_vector(7 downto 0);
11+
12+
begin
13+
14+
end architecture RTL;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 index_subtype_definition
9+
10+
sTestDir = os.path.dirname(__file__)
11+
12+
lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd"))
13+
14+
lExpected = []
15+
lExpected.append("")
16+
utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected)
17+
18+
19+
class test_rule(unittest.TestCase):
20+
def setUp(self):
21+
self.oFile = vhdlFile.vhdlFile(lFile)
22+
self.assertIsNone(eError)
23+
24+
def test_rule_100(self):
25+
oRule = index_subtype_definition.rule_100()
26+
self.assertTrue(oRule)
27+
self.assertEqual(oRule.name, "index_subtype_definition")
28+
self.assertEqual(oRule.identifier, "100")
29+
30+
lExpected = [10]
31+
32+
oRule.analyze(self.oFile)
33+
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
34+
35+
def test_fix_rule_100(self):
36+
oRule = index_subtype_definition.rule_100()
37+
38+
oRule.fix(self.oFile)
39+
40+
lActual = self.oFile.get_lines()
41+
42+
self.assertEqual(lExpected, lActual)
43+
44+
oRule.analyze(self.oFile)
45+
self.assertEqual(oRule.violations, [])

0 commit comments

Comments
 (0)