From f23cd2ac2145c745da84ad7d233301b81acd9fe4 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 14 Sep 2025 15:30:21 +0100 Subject: [PATCH] Issue#1511: Added new rule to enforce position of assignment operator in variable declarations. --- vsg/rules/variable/__init__.py | 1 + vsg/rules/variable/rule_018.py | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 vsg/rules/variable/rule_018.py diff --git a/vsg/rules/variable/__init__.py b/vsg/rules/variable/__init__.py index 351baaeb..080c5f48 100644 --- a/vsg/rules/variable/__init__.py +++ b/vsg/rules/variable/__init__.py @@ -12,6 +12,7 @@ from .rule_011 import rule_011 from .rule_012 import rule_012 from .rule_015 import rule_015 from .rule_017 import rule_017 +from .rule_018 import rule_018 from .rule_100 import rule_100 from .rule_101 import rule_101 from .rule_102 import rule_102 diff --git a/vsg/rules/variable/rule_018.py b/vsg/rules/variable/rule_018.py new file mode 100644 index 00000000..f60c8429 --- /dev/null +++ b/vsg/rules/variable/rule_018.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules import move_token_left_to_next_non_whitespace_token as Rule + +lTokens = [] +lTokens.append(token.variable_declaration.assignment_operator) + + +class rule_018(Rule): + """ + This rule checks the **:=** is on the same line at the **variable** keyword. + + **Violation** + + .. code-block:: vhdl + + variable size : integer + := 1; + variable width : integer + := 32; + + **Fix** + + .. code-block:: vhdl + + variable size : integer := + 1; + variable width : integer := + 32 + """ + + def __init__(self): + super().__init__(lTokens) + self.bRemoveTrailingWhitespace = False + self.solution = "Move := operator"