Skip to content

Commit c283820

Browse files
committed
Issue#1512: Added new rule to enforce alignment of assignment operators within variable declarations.
1 parent cb4eb92 commit c283820

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

vsg/rules/variable/rule_401.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from vsg import token
4+
from vsg.rules import (
5+
align_tokens_in_region_between_tokens_unless_between_tokens as Rule,
6+
)
7+
8+
lAlign = []
9+
lAlign.append(token.element_association.assignment)
10+
11+
lUnless = []
12+
13+
oStartToken = token.variable_declaration.assignment_operator
14+
oEndToken = token.variable_declaration.semicolon
15+
16+
17+
class rule_400(Rule):
18+
"""
19+
This rule checks the alignment of assignment keywords in variable declarations.
20+
21+
|configuring_keyword_alignment_rules_link|
22+
23+
**Violation**
24+
25+
.. code-block:: vhdl
26+
27+
variable v_default_values : t_address_en := (
28+
c_address_control => false,
29+
c_address_data => true,
30+
others => false
31+
);
32+
33+
**Fix**
34+
35+
.. code-block:: vhdl
36+
37+
variable v_default_values : t_address_en := (
38+
c_address_control => false,
39+
c_address_data => true,
40+
others => false
41+
);
42+
"""
43+
44+
def __init__(self):
45+
super().__init__(lAlign, oStartToken, oEndToken, lUnless)
46+
self.solution = "Align => ."
47+
self.configuration.remove("if_control_statements_ends_group")
48+
self.configuration.remove("case_control_statements_ends_group")
49+
self.configuration.remove("loop_control_statements_ends_group")
50+
self.configuration.remove("separate_generic_port_alignment")
51+
self.configuration.append("aggregate_parens_ends_group")
52+
self.configuration.append("ignore_single_line_aggregates")

0 commit comments

Comments
 (0)