From 5a6c3e45ec6a43748979aff7893da96a0acd5a09 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 24 Aug 2025 19:22:59 +0100 Subject: [PATCH 1/7] #1492: Added whitespace rules for constrained and unconstrained array definitions. --- .../constrained_array_definition/__init__.py | 3 ++ .../constrained_array_definition/rule_100.py | 33 +++++++++++++++++++ .../constrained_array_definition/rule_101.py | 31 +++++++++++++++++ .../constrained_array_definition/rule_102.py | 31 +++++++++++++++++ .../unbounded_array_definition/__init__.py | 3 ++ .../unbounded_array_definition/rule_100.py | 33 +++++++++++++++++++ .../unbounded_array_definition/rule_101.py | 31 +++++++++++++++++ .../unbounded_array_definition/rule_102.py | 31 +++++++++++++++++ 8 files changed, 196 insertions(+) create mode 100644 vsg/rules/constrained_array_definition/rule_100.py create mode 100644 vsg/rules/constrained_array_definition/rule_101.py create mode 100644 vsg/rules/constrained_array_definition/rule_102.py create mode 100644 vsg/rules/unbounded_array_definition/rule_100.py create mode 100644 vsg/rules/unbounded_array_definition/rule_101.py create mode 100644 vsg/rules/unbounded_array_definition/rule_102.py diff --git a/vsg/rules/constrained_array_definition/__init__.py b/vsg/rules/constrained_array_definition/__init__.py index 3c6ea275b..09808f1e6 100644 --- a/vsg/rules/constrained_array_definition/__init__.py +++ b/vsg/rules/constrained_array_definition/__init__.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +from .rule_100 import rule_100 +from .rule_101 import rule_101 +from .rule_102 import rule_102 from .rule_500 import rule_500 from .rule_501 import rule_501 diff --git a/vsg/rules/constrained_array_definition/rule_100.py b/vsg/rules/constrained_array_definition/rule_100.py new file mode 100644 index 000000000..671ed1bff --- /dev/null +++ b/vsg/rules/constrained_array_definition/rule_100.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_after_token import Rule + +lTokens = [] +lTokens.append(token.constrained_array_definition.array_keyword) + + +class rule_100(Rule): + """ + This rule checks for whitespace after the **array** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array is array (1 downto 0) of unsigned; + type t_u_array is array (1 downto 0) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + type t_u_array is array(1 downto 0) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 0 diff --git a/vsg/rules/constrained_array_definition/rule_101.py b/vsg/rules/constrained_array_definition/rule_101.py new file mode 100644 index 000000000..dd6fc4b83 --- /dev/null +++ b/vsg/rules/constrained_array_definition/rule_101.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_before_token import Rule + +lTokens = [] +lTokens.append(token.constrained_array_definition.of_keyword) + + +class rule_101(Rule): + """ + This rule checks for a single space before the **of** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 1 diff --git a/vsg/rules/constrained_array_definition/rule_102.py b/vsg/rules/constrained_array_definition/rule_102.py new file mode 100644 index 000000000..2b69f13c4 --- /dev/null +++ b/vsg/rules/constrained_array_definition/rule_102.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_after_token import Rule + +lTokens = [] +lTokens.append(token.constrained_array_definition.of_keyword) + + +class rule_102(Rule): + """ + This rule checks for a single space after the **of** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 1 diff --git a/vsg/rules/unbounded_array_definition/__init__.py b/vsg/rules/unbounded_array_definition/__init__.py index 3c6ea275b..09808f1e6 100644 --- a/vsg/rules/unbounded_array_definition/__init__.py +++ b/vsg/rules/unbounded_array_definition/__init__.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +from .rule_100 import rule_100 +from .rule_101 import rule_101 +from .rule_102 import rule_102 from .rule_500 import rule_500 from .rule_501 import rule_501 diff --git a/vsg/rules/unbounded_array_definition/rule_100.py b/vsg/rules/unbounded_array_definition/rule_100.py new file mode 100644 index 000000000..13d154f13 --- /dev/null +++ b/vsg/rules/unbounded_array_definition/rule_100.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_after_token import Rule + +lTokens = [] +lTokens.append(token.unbounded_array_definition.array_keyword) + + +class rule_100(Rule): + """ + This rule checks for whitespace after the **array** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array (natural range <>) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 0 diff --git a/vsg/rules/unbounded_array_definition/rule_101.py b/vsg/rules/unbounded_array_definition/rule_101.py new file mode 100644 index 000000000..9099e7a58 --- /dev/null +++ b/vsg/rules/unbounded_array_definition/rule_101.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_before_token import Rule + +lTokens = [] +lTokens.append(token.unbounded_array_definition.of_keyword) + + +class rule_101(Rule): + """ + This rule checks for a single space before the **of** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 1 diff --git a/vsg/rules/unbounded_array_definition/rule_102.py b/vsg/rules/unbounded_array_definition/rule_102.py new file mode 100644 index 000000000..ad9f7d403 --- /dev/null +++ b/vsg/rules/unbounded_array_definition/rule_102.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from vsg import token +from vsg.rules.whitespace_after_token import Rule + +lTokens = [] +lTokens.append(token.unbounded_array_definition.of_keyword) + + +class rule_102(Rule): + """ + This rule checks for a single space after the **of** keyword. + + |configuring_whitespace_rules_link| + + **Violation** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + + **Fix** + + .. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + """ + + def __init__(self): + super().__init__(lTokens) + self.number_of_spaces = 1 From 2b5670a62b4d5c38803fe2c0c142936dc9c3ca4f Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 24 Aug 2025 19:35:10 +0100 Subject: [PATCH 2/7] #1492: Added tests for whitespace rules for constrained and unconstrained array definitions. --- .../rule_100_test_input.fixed.vhd | 14 ++++++ .../rule_100_test_input.vhd | 14 ++++++ .../rule_101_test_input.fixed.vhd | 12 +++++ .../rule_101_test_input.vhd | 12 +++++ .../rule_102_test_input.fixed.vhd | 12 +++++ .../rule_102_test_input.vhd | 12 +++++ .../test_rule_100.py | 48 +++++++++++++++++++ .../test_rule_101.py | 48 +++++++++++++++++++ .../test_rule_102.py | 48 +++++++++++++++++++ .../rule_100_test_input.fixed.vhd | 10 ++++ .../rule_100_test_input.vhd | 10 ++++ .../rule_101_test_input.fixed.vhd | 9 ++++ .../rule_101_test_input.vhd | 9 ++++ .../rule_102_test_input.fixed.vhd | 9 ++++ .../rule_102_test_input.vhd | 9 ++++ .../test_rule_100.py | 48 +++++++++++++++++++ .../test_rule_101.py | 48 +++++++++++++++++++ .../test_rule_102.py | 48 +++++++++++++++++++ 18 files changed, 420 insertions(+) create mode 100644 tests/constrained_array_definition/rule_100_test_input.fixed.vhd create mode 100644 tests/constrained_array_definition/rule_100_test_input.vhd create mode 100644 tests/constrained_array_definition/rule_101_test_input.fixed.vhd create mode 100644 tests/constrained_array_definition/rule_101_test_input.vhd create mode 100644 tests/constrained_array_definition/rule_102_test_input.fixed.vhd create mode 100644 tests/constrained_array_definition/rule_102_test_input.vhd create mode 100644 tests/constrained_array_definition/test_rule_100.py create mode 100644 tests/constrained_array_definition/test_rule_101.py create mode 100644 tests/constrained_array_definition/test_rule_102.py create mode 100644 tests/unbounded_array_definition/rule_100_test_input.fixed.vhd create mode 100644 tests/unbounded_array_definition/rule_100_test_input.vhd create mode 100644 tests/unbounded_array_definition/rule_101_test_input.fixed.vhd create mode 100644 tests/unbounded_array_definition/rule_101_test_input.vhd create mode 100644 tests/unbounded_array_definition/rule_102_test_input.fixed.vhd create mode 100644 tests/unbounded_array_definition/rule_102_test_input.vhd create mode 100644 tests/unbounded_array_definition/test_rule_100.py create mode 100644 tests/unbounded_array_definition/test_rule_101.py create mode 100644 tests/unbounded_array_definition/test_rule_102.py diff --git a/tests/constrained_array_definition/rule_100_test_input.fixed.vhd b/tests/constrained_array_definition/rule_100_test_input.fixed.vhd new file mode 100644 index 000000000..2eaef59e6 --- /dev/null +++ b/tests/constrained_array_definition/rule_100_test_input.fixed.vhd @@ -0,0 +1,14 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/rule_100_test_input.vhd b/tests/constrained_array_definition/rule_100_test_input.vhd new file mode 100644 index 000000000..433db16f1 --- /dev/null +++ b/tests/constrained_array_definition/rule_100_test_input.vhd @@ -0,0 +1,14 @@ + +architecture RTL of FIFO is + + type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array (0 to 7) of std_logic_vector(7 downto 0); + type my_array is array (0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/rule_101_test_input.fixed.vhd b/tests/constrained_array_definition/rule_101_test_input.fixed.vhd new file mode 100644 index 000000000..147a27348 --- /dev/null +++ b/tests/constrained_array_definition/rule_101_test_input.fixed.vhd @@ -0,0 +1,12 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/rule_101_test_input.vhd b/tests/constrained_array_definition/rule_101_test_input.vhd new file mode 100644 index 000000000..8e3174f40 --- /dev/null +++ b/tests/constrained_array_definition/rule_101_test_input.vhd @@ -0,0 +1,12 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/rule_102_test_input.fixed.vhd b/tests/constrained_array_definition/rule_102_test_input.fixed.vhd new file mode 100644 index 000000000..147a27348 --- /dev/null +++ b/tests/constrained_array_definition/rule_102_test_input.fixed.vhd @@ -0,0 +1,12 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/rule_102_test_input.vhd b/tests/constrained_array_definition/rule_102_test_input.vhd new file mode 100644 index 000000000..856a74551 --- /dev/null +++ b/tests/constrained_array_definition/rule_102_test_input.vhd @@ -0,0 +1,12 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/constrained_array_definition/test_rule_100.py b/tests/constrained_array_definition/test_rule_100.py new file mode 100644 index 000000000..01496f39d --- /dev/null +++ b/tests/constrained_array_definition/test_rule_100.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import constrained_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) + + +class test_constrained_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_100(self): + oRule = constrained_array_definition.rule_100() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "constrained_array_definition") + self.assertEqual(oRule.identifier, "100") + + lExpected = [4, 5, 8, 9] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_100(self): + oRule = constrained_array_definition.rule_100() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/constrained_array_definition/test_rule_101.py b/tests/constrained_array_definition/test_rule_101.py new file mode 100644 index 000000000..953e45937 --- /dev/null +++ b/tests/constrained_array_definition/test_rule_101.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import constrained_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_101_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected) + + +class test_constrained_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_101(self): + oRule = constrained_array_definition.rule_101() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "constrained_array_definition") + self.assertEqual(oRule.identifier, "101") + + lExpected = [4, 7] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_101(self): + oRule = constrained_array_definition.rule_101() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/constrained_array_definition/test_rule_102.py b/tests/constrained_array_definition/test_rule_102.py new file mode 100644 index 000000000..c8d90bfdd --- /dev/null +++ b/tests/constrained_array_definition/test_rule_102.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import constrained_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_102_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected) + + +class test_constrained_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_102(self): + oRule = constrained_array_definition.rule_102() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "constrained_array_definition") + self.assertEqual(oRule.identifier, "102") + + lExpected = [4, 7] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_102(self): + oRule = constrained_array_definition.rule_102() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/unbounded_array_definition/rule_100_test_input.fixed.vhd b/tests/unbounded_array_definition/rule_100_test_input.fixed.vhd new file mode 100644 index 000000000..f5298f35e --- /dev/null +++ b/tests/unbounded_array_definition/rule_100_test_input.fixed.vhd @@ -0,0 +1,10 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/rule_100_test_input.vhd b/tests/unbounded_array_definition/rule_100_test_input.vhd new file mode 100644 index 000000000..e038e034b --- /dev/null +++ b/tests/unbounded_array_definition/rule_100_test_input.vhd @@ -0,0 +1,10 @@ + +architecture RTL of FIFO is + + type my_array is array (natural range <>) of std_logic_vector(7 downto 0); + type my_array is array (natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/rule_101_test_input.fixed.vhd b/tests/unbounded_array_definition/rule_101_test_input.fixed.vhd new file mode 100644 index 000000000..332dc734b --- /dev/null +++ b/tests/unbounded_array_definition/rule_101_test_input.fixed.vhd @@ -0,0 +1,9 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/rule_101_test_input.vhd b/tests/unbounded_array_definition/rule_101_test_input.vhd new file mode 100644 index 000000000..86af5a7ed --- /dev/null +++ b/tests/unbounded_array_definition/rule_101_test_input.vhd @@ -0,0 +1,9 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/rule_102_test_input.fixed.vhd b/tests/unbounded_array_definition/rule_102_test_input.fixed.vhd new file mode 100644 index 000000000..332dc734b --- /dev/null +++ b/tests/unbounded_array_definition/rule_102_test_input.fixed.vhd @@ -0,0 +1,9 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/rule_102_test_input.vhd b/tests/unbounded_array_definition/rule_102_test_input.vhd new file mode 100644 index 000000000..ac1336304 --- /dev/null +++ b/tests/unbounded_array_definition/rule_102_test_input.vhd @@ -0,0 +1,9 @@ + +architecture RTL of FIFO is + + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + type my_array is array(natural range <>) of std_logic_vector(7 downto 0); + +begin + +end architecture RTL; diff --git a/tests/unbounded_array_definition/test_rule_100.py b/tests/unbounded_array_definition/test_rule_100.py new file mode 100644 index 000000000..07b6f549f --- /dev/null +++ b/tests/unbounded_array_definition/test_rule_100.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import unbounded_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_100_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) + + +class test_unbounded_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_100(self): + oRule = unbounded_array_definition.rule_100() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "unbounded_array_definition") + self.assertEqual(oRule.identifier, "100") + + lExpected = [4, 5] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_100(self): + oRule = unbounded_array_definition.rule_100() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/unbounded_array_definition/test_rule_101.py b/tests/unbounded_array_definition/test_rule_101.py new file mode 100644 index 000000000..e6a288330 --- /dev/null +++ b/tests/unbounded_array_definition/test_rule_101.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import unbounded_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_101_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected) + + +class test_unbounded_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_101(self): + oRule = unbounded_array_definition.rule_101() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "unbounded_array_definition") + self.assertEqual(oRule.identifier, "101") + + lExpected = [4] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_101(self): + oRule = unbounded_array_definition.rule_101() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/tests/unbounded_array_definition/test_rule_102.py b/tests/unbounded_array_definition/test_rule_102.py new file mode 100644 index 000000000..857d3b486 --- /dev/null +++ b/tests/unbounded_array_definition/test_rule_102.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import os +import unittest + +from tests import utils +from vsg import vhdlFile +from vsg.rules import unbounded_array_definition + +sTestDir = os.path.dirname(__file__) + +lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_102_test_input.vhd")) + +dIndentMap = utils.read_indent_file() + +lExpected = [] +lExpected.append("") +utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected) + + +class test_unbounded_array_definition_rule(unittest.TestCase): + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + self.assertIsNone(eError) + self.oFile.set_indent_map(dIndentMap) + + def test_rule_102(self): + oRule = unbounded_array_definition.rule_102() + self.assertTrue(oRule) + self.assertEqual(oRule.name, "unbounded_array_definition") + self.assertEqual(oRule.identifier, "102") + + lExpected = [4] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_102(self): + oRule = unbounded_array_definition.rule_102() + + oRule.fix(self.oFile) + + lActual = self.oFile.get_lines() + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) From ee67ef0a738f9c5ba5ade67479254634c444b73a Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 24 Aug 2025 19:44:44 +0100 Subject: [PATCH 3/7] #1492: Added tests for whitespace rules for constrained and unconstrained array definitions. --- docs/configuring_whitespace_rules.rst | 6 ++ docs/constrained_array_definition_rules.rst | 65 +++++++++++++++++++++ docs/rule_groups/whitespace_rule_group.rst | 6 ++ docs/unbounded_array_definition_rules.rst | 65 +++++++++++++++++++++ 4 files changed, 142 insertions(+) diff --git a/docs/configuring_whitespace_rules.rst b/docs/configuring_whitespace_rules.rst index b6dadfc98..6bfb5243a 100644 --- a/docs/configuring_whitespace_rules.rst +++ b/docs/configuring_whitespace_rules.rst @@ -160,6 +160,9 @@ Rules Enforcing Whitespace * `constant_010 `_ * `constant_100 `_ * `constant_101 `_ +* `constrained_array_definition_100 `_ +* `constrained_array_definition_101 `_ +* `constrained_array_definition_102 `_ * `context_002 `_ * `context_017 `_ * `context_018 `_ @@ -274,6 +277,9 @@ Rules Enforcing Whitespace * `type_006 `_ * `type_007 `_ * `type_100 `_ +* `unbounded_array_definition_100 `_ +* `unbounded_array_definition_101 `_ +* `unbounded_array_definition_102 `_ * `variable_005 `_ * `variable_006 `_ * `variable_100 `_ diff --git a/docs/constrained_array_definition_rules.rst b/docs/constrained_array_definition_rules.rst index 2d457be2d..2b7ad801b 100644 --- a/docs/constrained_array_definition_rules.rst +++ b/docs/constrained_array_definition_rules.rst @@ -3,6 +3,71 @@ Constrained Array Definition Rules ---------------------------------- +constrained_array_definition_100 +################################ + +|phase_2| |error| |whitespace| + +This rule checks for whitespace after the **array** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array is array (1 downto 0) of unsigned; + type t_u_array is array (1 downto 0) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + type t_u_array is array(1 downto 0) of unsigned; + +constrained_array_definition_101 +################################ + +|phase_2| |error| |whitespace| + +This rule checks for a single space before the **of** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + +constrained_array_definition_102 +################################ + +|phase_2| |error| |whitespace| + +This rule checks for a single space after the **of** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array is array(1 downto 0) of unsigned; + constrained_array_definition_500 ################################ diff --git a/docs/rule_groups/whitespace_rule_group.rst b/docs/rule_groups/whitespace_rule_group.rst index f96d54c14..55c9b5dc9 100644 --- a/docs/rule_groups/whitespace_rule_group.rst +++ b/docs/rule_groups/whitespace_rule_group.rst @@ -54,6 +54,9 @@ Rules Enforcing Whitespace Rule Group * `constant_010 <../constant_rules.html#constant-010>`_ * `constant_100 <../constant_rules.html#constant-100>`_ * `constant_101 <../constant_rules.html#constant-101>`_ +* `constrained_array_definition_100 <../constrained_array_definition_rules.html#constrained-array-definition-100>`_ +* `constrained_array_definition_101 <../constrained_array_definition_rules.html#constrained-array-definition-101>`_ +* `constrained_array_definition_102 <../constrained_array_definition_rules.html#constrained-array-definition-102>`_ * `context_002 <../context_rules.html#context-002>`_ * `context_017 <../context_rules.html#context-017>`_ * `context_018 <../context_rules.html#context-018>`_ @@ -171,6 +174,9 @@ Rules Enforcing Whitespace Rule Group * `type_006 <../type_rules.html#type-006>`_ * `type_007 <../type_rules.html#type-007>`_ * `type_100 <../type_rules.html#type-100>`_ +* `unbounded_array_definition_100 <../unbounded_array_definition_rules.html#unbounded-array-definition-100>`_ +* `unbounded_array_definition_101 <../unbounded_array_definition_rules.html#unbounded-array-definition-101>`_ +* `unbounded_array_definition_102 <../unbounded_array_definition_rules.html#unbounded-array-definition-102>`_ * `variable_005 <../variable_rules.html#variable-005>`_ * `variable_006 <../variable_rules.html#variable-006>`_ * `variable_100 <../variable_rules.html#variable-100>`_ diff --git a/docs/unbounded_array_definition_rules.rst b/docs/unbounded_array_definition_rules.rst index a9a75a0dd..fc4060421 100644 --- a/docs/unbounded_array_definition_rules.rst +++ b/docs/unbounded_array_definition_rules.rst @@ -3,6 +3,71 @@ Unbounded Array Definition Rules -------------------------------- +unbounded_array_definition_100 +############################## + +|phase_2| |error| |whitespace| + +This rule checks for whitespace after the **array** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array (natural range <>) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; + +unbounded_array_definition_101 +############################## + +|phase_2| |error| |whitespace| + +This rule checks for a single space before the **of** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + +unbounded_array_definition_102 +############################## + +|phase_2| |error| |whitespace| + +This rule checks for a single space after the **of** keyword. + +|configuring_whitespace_rules_link| + +**Violation** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array(natural range <>) of unsigned; + +**Fix** + +.. code-block:: vhdl + + type t_u_array_unconstrained is array (natural range <>) of unsigned; + unbounded_array_definition_500 ############################## From a6c264075d609c16b0f57b703a78970eb4d3b398 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 24 Aug 2025 19:47:18 +0100 Subject: [PATCH 4/7] #1492: Whitespace corrections. --- docs/unbounded_array_definition_rules.rst | 2 +- vsg/rules/unbounded_array_definition/rule_101.py | 2 +- vsg/rules/unbounded_array_definition/rule_102.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/unbounded_array_definition_rules.rst b/docs/unbounded_array_definition_rules.rst index fc4060421..fc6f43391 100644 --- a/docs/unbounded_array_definition_rules.rst +++ b/docs/unbounded_array_definition_rules.rst @@ -16,7 +16,7 @@ This rule checks for whitespace after the **array** keyword. .. code-block:: vhdl - type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; type t_u_array_unconstrained is array (natural range <>) of unsigned; **Fix** diff --git a/vsg/rules/unbounded_array_definition/rule_101.py b/vsg/rules/unbounded_array_definition/rule_101.py index 9099e7a58..e5b5c5a12 100644 --- a/vsg/rules/unbounded_array_definition/rule_101.py +++ b/vsg/rules/unbounded_array_definition/rule_101.py @@ -23,7 +23,7 @@ class rule_101(Rule): .. code-block:: vhdl - type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; """ def __init__(self): diff --git a/vsg/rules/unbounded_array_definition/rule_102.py b/vsg/rules/unbounded_array_definition/rule_102.py index ad9f7d403..5d75914db 100644 --- a/vsg/rules/unbounded_array_definition/rule_102.py +++ b/vsg/rules/unbounded_array_definition/rule_102.py @@ -23,7 +23,7 @@ class rule_102(Rule): .. code-block:: vhdl - type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; """ def __init__(self): From 81de9b06b05d5b476021070f9f3c31569a9b42fe Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sun, 24 Aug 2025 21:15:39 +0100 Subject: [PATCH 5/7] #1492: Updated code example tests. --- tests/styles/jcl/PIC.fixed.vhd | 2 +- tests/styles/jcl/graphicsaccelerator/FrameBuffer2.fixed.vhd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/styles/jcl/PIC.fixed.vhd b/tests/styles/jcl/PIC.fixed.vhd index bd000f4de..093a1121b 100644 --- a/tests/styles/jcl/PIC.fixed.vhd +++ b/tests/styles/jcl/PIC.fixed.vhd @@ -67,7 +67,7 @@ architecture BEHAVIORAL of PIC is signal int_type : unsigned(1 downto 0) := "01"; signal int_index, count_cmd : integer := 0; - type prior_table is array (0 to 7) of unsigned(2 downto 0); + type prior_table is array(0 to 7) of unsigned(2 downto 0); signal pt : prior_table := (others => (others => '0')); signal int_pt : unsigned(2 downto 0) := "000"; diff --git a/tests/styles/jcl/graphicsaccelerator/FrameBuffer2.fixed.vhd b/tests/styles/jcl/graphicsaccelerator/FrameBuffer2.fixed.vhd index cd574665c..6073ecddf 100644 --- a/tests/styles/jcl/graphicsaccelerator/FrameBuffer2.fixed.vhd +++ b/tests/styles/jcl/graphicsaccelerator/FrameBuffer2.fixed.vhd @@ -19,7 +19,7 @@ end entity FRAMEBUFFER; architecture BEHAVIORAL of FRAMEBUFFER is - type fbuffer is array (0 to 524288 / 16 - 1) of std_logic_vector(2 downto 0); + type fbuffer is array(0 to 524288 / 16 - 1) of std_logic_vector(2 downto 0); impure function initfb return fbuffer is From df74d355588e39267cc0ebf8c2d1379df3b0189b Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Mon, 25 Aug 2025 08:14:06 +0100 Subject: [PATCH 6/7] Issue#1492: Updated test class names. --- tests/constrained_array_definition/test_rule_100.py | 2 +- tests/constrained_array_definition/test_rule_101.py | 2 +- tests/constrained_array_definition/test_rule_102.py | 2 +- tests/unbounded_array_definition/test_rule_100.py | 2 +- tests/unbounded_array_definition/test_rule_101.py | 2 +- tests/unbounded_array_definition/test_rule_102.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/constrained_array_definition/test_rule_100.py b/tests/constrained_array_definition/test_rule_100.py index 01496f39d..5f167e031 100644 --- a/tests/constrained_array_definition/test_rule_100.py +++ b/tests/constrained_array_definition/test_rule_100.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) -class test_constrained_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) diff --git a/tests/constrained_array_definition/test_rule_101.py b/tests/constrained_array_definition/test_rule_101.py index 953e45937..d57ba2579 100644 --- a/tests/constrained_array_definition/test_rule_101.py +++ b/tests/constrained_array_definition/test_rule_101.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected) -class test_constrained_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) diff --git a/tests/constrained_array_definition/test_rule_102.py b/tests/constrained_array_definition/test_rule_102.py index c8d90bfdd..3679019ae 100644 --- a/tests/constrained_array_definition/test_rule_102.py +++ b/tests/constrained_array_definition/test_rule_102.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected) -class test_constrained_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) diff --git a/tests/unbounded_array_definition/test_rule_100.py b/tests/unbounded_array_definition/test_rule_100.py index 07b6f549f..005d2d01a 100644 --- a/tests/unbounded_array_definition/test_rule_100.py +++ b/tests/unbounded_array_definition/test_rule_100.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_100_test_input.fixed.vhd"), lExpected) -class test_unbounded_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) diff --git a/tests/unbounded_array_definition/test_rule_101.py b/tests/unbounded_array_definition/test_rule_101.py index e6a288330..a50a0a140 100644 --- a/tests/unbounded_array_definition/test_rule_101.py +++ b/tests/unbounded_array_definition/test_rule_101.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_101_test_input.fixed.vhd"), lExpected) -class test_unbounded_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) diff --git a/tests/unbounded_array_definition/test_rule_102.py b/tests/unbounded_array_definition/test_rule_102.py index 857d3b486..bcea6c602 100644 --- a/tests/unbounded_array_definition/test_rule_102.py +++ b/tests/unbounded_array_definition/test_rule_102.py @@ -18,7 +18,7 @@ utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected) -class test_unbounded_array_definition_rule(unittest.TestCase): +class test_rule(unittest.TestCase): def setUp(self): self.oFile = vhdlFile.vhdlFile(lFile) self.assertIsNone(eError) From 04cf277b54941b112c4b13219a45fcd39367f209 Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Thu, 11 Sep 2025 23:39:42 +0100 Subject: [PATCH 7/7] Issue#1492: Removed constrained_array_definition_100, shuffled other rules names down. --- docs/configuring_whitespace_rules.rst | 1 - docs/constrained_array_definition_rules.rst | 25 +--------- docs/rule_groups/whitespace_rule_group.rst | 1 - docs/unbounded_array_definition_rules.rst | 6 +-- .../rule_100_test_input.fixed.vhd | 2 - .../rule_100_test_input.vhd | 6 +-- .../rule_101_test_input.vhd | 4 +- .../rule_102_test_input.fixed.vhd | 12 ----- .../rule_102_test_input.vhd | 12 ----- .../test_rule_100.py | 2 +- .../test_rule_102.py | 48 ------------------- .../constrained_array_definition/__init__.py | 1 - .../constrained_array_definition/rule_100.py | 12 ++--- .../constrained_array_definition/rule_101.py | 6 +-- .../constrained_array_definition/rule_102.py | 31 ------------ 15 files changed, 17 insertions(+), 152 deletions(-) delete mode 100644 tests/constrained_array_definition/rule_102_test_input.fixed.vhd delete mode 100644 tests/constrained_array_definition/rule_102_test_input.vhd delete mode 100644 tests/constrained_array_definition/test_rule_102.py delete mode 100644 vsg/rules/constrained_array_definition/rule_102.py diff --git a/docs/configuring_whitespace_rules.rst b/docs/configuring_whitespace_rules.rst index 160e08161..5d6911d91 100644 --- a/docs/configuring_whitespace_rules.rst +++ b/docs/configuring_whitespace_rules.rst @@ -162,7 +162,6 @@ Rules Enforcing Whitespace * `constant_101 `_ * `constrained_array_definition_100 `_ * `constrained_array_definition_101 `_ -* `constrained_array_definition_102 `_ * `context_002 `_ * `context_017 `_ * `context_018 `_ diff --git a/docs/constrained_array_definition_rules.rst b/docs/constrained_array_definition_rules.rst index 2b7ad801b..7f78c05d8 100644 --- a/docs/constrained_array_definition_rules.rst +++ b/docs/constrained_array_definition_rules.rst @@ -8,29 +8,6 @@ constrained_array_definition_100 |phase_2| |error| |whitespace| -This rule checks for whitespace after the **array** keyword. - -|configuring_whitespace_rules_link| - -**Violation** - -.. code-block:: vhdl - - type t_u_array is array (1 downto 0) of unsigned; - type t_u_array is array (1 downto 0) of unsigned; - -**Fix** - -.. code-block:: vhdl - - type t_u_array is array(1 downto 0) of unsigned; - type t_u_array is array(1 downto 0) of unsigned; - -constrained_array_definition_101 -################################ - -|phase_2| |error| |whitespace| - This rule checks for a single space before the **of** keyword. |configuring_whitespace_rules_link| @@ -47,7 +24,7 @@ This rule checks for a single space before the **of** keyword. type t_u_array is array(1 downto 0) of unsigned; -constrained_array_definition_102 +constrained_array_definition_101 ################################ |phase_2| |error| |whitespace| diff --git a/docs/rule_groups/whitespace_rule_group.rst b/docs/rule_groups/whitespace_rule_group.rst index f9c1bdd20..32f43ee4b 100644 --- a/docs/rule_groups/whitespace_rule_group.rst +++ b/docs/rule_groups/whitespace_rule_group.rst @@ -56,7 +56,6 @@ Rules Enforcing Whitespace Rule Group * `constant_101 <../constant_rules.html#constant-101>`_ * `constrained_array_definition_100 <../constrained_array_definition_rules.html#constrained-array-definition-100>`_ * `constrained_array_definition_101 <../constrained_array_definition_rules.html#constrained-array-definition-101>`_ -* `constrained_array_definition_102 <../constrained_array_definition_rules.html#constrained-array-definition-102>`_ * `context_002 <../context_rules.html#context-002>`_ * `context_017 <../context_rules.html#context-017>`_ * `context_018 <../context_rules.html#context-018>`_ diff --git a/docs/unbounded_array_definition_rules.rst b/docs/unbounded_array_definition_rules.rst index fc6f43391..8b8c3da6c 100644 --- a/docs/unbounded_array_definition_rules.rst +++ b/docs/unbounded_array_definition_rules.rst @@ -16,7 +16,7 @@ This rule checks for whitespace after the **array** keyword. .. code-block:: vhdl - type t_u_array_unconstrained is array(natural range <>) of unsigned; + type t_u_array_unconstrained is array (natural range <>) of unsigned; type t_u_array_unconstrained is array (natural range <>) of unsigned; **Fix** @@ -45,7 +45,7 @@ This rule checks for a single space before the **of** keyword. .. code-block:: vhdl - type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; unbounded_array_definition_102 ############################## @@ -66,7 +66,7 @@ This rule checks for a single space after the **of** keyword. .. code-block:: vhdl - type t_u_array_unconstrained is array (natural range <>) of unsigned; + type t_u_array_unconstrained is array(natural range <>) of unsigned; unbounded_array_definition_500 ############################## diff --git a/tests/constrained_array_definition/rule_100_test_input.fixed.vhd b/tests/constrained_array_definition/rule_100_test_input.fixed.vhd index 2eaef59e6..147a27348 100644 --- a/tests/constrained_array_definition/rule_100_test_input.fixed.vhd +++ b/tests/constrained_array_definition/rule_100_test_input.fixed.vhd @@ -3,11 +3,9 @@ architecture RTL of FIFO is type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); type my_array is array(0 to 7) of std_logic_vector(7 downto 0); type my_array is array(0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); begin diff --git a/tests/constrained_array_definition/rule_100_test_input.vhd b/tests/constrained_array_definition/rule_100_test_input.vhd index 433db16f1..8e3174f40 100644 --- a/tests/constrained_array_definition/rule_100_test_input.vhd +++ b/tests/constrained_array_definition/rule_100_test_input.vhd @@ -1,12 +1,10 @@ architecture RTL of FIFO is - type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array (natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array (0 to 7) of std_logic_vector(7 downto 0); - type my_array is array (0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); type my_array is array(0 to 7) of std_logic_vector(7 downto 0); begin diff --git a/tests/constrained_array_definition/rule_101_test_input.vhd b/tests/constrained_array_definition/rule_101_test_input.vhd index 8e3174f40..856a74551 100644 --- a/tests/constrained_array_definition/rule_101_test_input.vhd +++ b/tests/constrained_array_definition/rule_101_test_input.vhd @@ -1,10 +1,10 @@ architecture RTL of FIFO is - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); + type my_array is array(0 to 7) of std_logic_vector(7 downto 0); type my_array is array(0 to 7) of std_logic_vector(7 downto 0); begin diff --git a/tests/constrained_array_definition/rule_102_test_input.fixed.vhd b/tests/constrained_array_definition/rule_102_test_input.fixed.vhd deleted file mode 100644 index 147a27348..000000000 --- a/tests/constrained_array_definition/rule_102_test_input.fixed.vhd +++ /dev/null @@ -1,12 +0,0 @@ - -architecture RTL of FIFO is - - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); - -begin - -end architecture RTL; diff --git a/tests/constrained_array_definition/rule_102_test_input.vhd b/tests/constrained_array_definition/rule_102_test_input.vhd deleted file mode 100644 index 856a74551..000000000 --- a/tests/constrained_array_definition/rule_102_test_input.vhd +++ /dev/null @@ -1,12 +0,0 @@ - -architecture RTL of FIFO is - - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(natural range 0 to 7) of std_logic_vector(7 downto 0); - - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); - type my_array is array(0 to 7) of std_logic_vector(7 downto 0); - -begin - -end architecture RTL; diff --git a/tests/constrained_array_definition/test_rule_100.py b/tests/constrained_array_definition/test_rule_100.py index 5f167e031..3d522bfe1 100644 --- a/tests/constrained_array_definition/test_rule_100.py +++ b/tests/constrained_array_definition/test_rule_100.py @@ -30,7 +30,7 @@ def test_rule_100(self): self.assertEqual(oRule.name, "constrained_array_definition") self.assertEqual(oRule.identifier, "100") - lExpected = [4, 5, 8, 9] + lExpected = [4, 7] oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) diff --git a/tests/constrained_array_definition/test_rule_102.py b/tests/constrained_array_definition/test_rule_102.py deleted file mode 100644 index 3679019ae..000000000 --- a/tests/constrained_array_definition/test_rule_102.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- - -import os -import unittest - -from tests import utils -from vsg import vhdlFile -from vsg.rules import constrained_array_definition - -sTestDir = os.path.dirname(__file__) - -lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_102_test_input.vhd")) - -dIndentMap = utils.read_indent_file() - -lExpected = [] -lExpected.append("") -utils.read_file(os.path.join(sTestDir, "rule_102_test_input.fixed.vhd"), lExpected) - - -class test_rule(unittest.TestCase): - def setUp(self): - self.oFile = vhdlFile.vhdlFile(lFile) - self.assertIsNone(eError) - self.oFile.set_indent_map(dIndentMap) - - def test_rule_102(self): - oRule = constrained_array_definition.rule_102() - self.assertTrue(oRule) - self.assertEqual(oRule.name, "constrained_array_definition") - self.assertEqual(oRule.identifier, "102") - - lExpected = [4, 7] - - oRule.analyze(self.oFile) - self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) - - def test_fix_rule_102(self): - oRule = constrained_array_definition.rule_102() - - oRule.fix(self.oFile) - - lActual = self.oFile.get_lines() - - self.assertEqual(lExpected, lActual) - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, []) diff --git a/vsg/rules/constrained_array_definition/__init__.py b/vsg/rules/constrained_array_definition/__init__.py index 09808f1e6..a1f7e96d1 100644 --- a/vsg/rules/constrained_array_definition/__init__.py +++ b/vsg/rules/constrained_array_definition/__init__.py @@ -2,6 +2,5 @@ from .rule_100 import rule_100 from .rule_101 import rule_101 -from .rule_102 import rule_102 from .rule_500 import rule_500 from .rule_501 import rule_501 diff --git a/vsg/rules/constrained_array_definition/rule_100.py b/vsg/rules/constrained_array_definition/rule_100.py index 671ed1bff..33d278c81 100644 --- a/vsg/rules/constrained_array_definition/rule_100.py +++ b/vsg/rules/constrained_array_definition/rule_100.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules.whitespace_after_token import Rule +from vsg.rules.whitespace_before_token import Rule lTokens = [] -lTokens.append(token.constrained_array_definition.array_keyword) +lTokens.append(token.constrained_array_definition.of_keyword) class rule_100(Rule): """ - This rule checks for whitespace after the **array** keyword. + This rule checks for a single space before the **of** keyword. |configuring_whitespace_rules_link| @@ -17,17 +17,15 @@ class rule_100(Rule): .. code-block:: vhdl - type t_u_array is array (1 downto 0) of unsigned; - type t_u_array is array (1 downto 0) of unsigned; + type t_u_array is array(1 downto 0) of unsigned; **Fix** .. code-block:: vhdl type t_u_array is array(1 downto 0) of unsigned; - type t_u_array is array(1 downto 0) of unsigned; """ def __init__(self): super().__init__(lTokens) - self.number_of_spaces = 0 + self.number_of_spaces = 1 diff --git a/vsg/rules/constrained_array_definition/rule_101.py b/vsg/rules/constrained_array_definition/rule_101.py index dd6fc4b83..26ae83613 100644 --- a/vsg/rules/constrained_array_definition/rule_101.py +++ b/vsg/rules/constrained_array_definition/rule_101.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from vsg import token -from vsg.rules.whitespace_before_token import Rule +from vsg.rules.whitespace_after_token import Rule lTokens = [] lTokens.append(token.constrained_array_definition.of_keyword) @@ -9,7 +9,7 @@ class rule_101(Rule): """ - This rule checks for a single space before the **of** keyword. + This rule checks for a single space after the **of** keyword. |configuring_whitespace_rules_link| @@ -17,7 +17,7 @@ class rule_101(Rule): .. code-block:: vhdl - type t_u_array is array(1 downto 0) of unsigned; + type t_u_array is array(1 downto 0) of unsigned; **Fix** diff --git a/vsg/rules/constrained_array_definition/rule_102.py b/vsg/rules/constrained_array_definition/rule_102.py deleted file mode 100644 index 2b69f13c4..000000000 --- a/vsg/rules/constrained_array_definition/rule_102.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- - -from vsg import token -from vsg.rules.whitespace_after_token import Rule - -lTokens = [] -lTokens.append(token.constrained_array_definition.of_keyword) - - -class rule_102(Rule): - """ - This rule checks for a single space after the **of** keyword. - - |configuring_whitespace_rules_link| - - **Violation** - - .. code-block:: vhdl - - type t_u_array is array(1 downto 0) of unsigned; - - **Fix** - - .. code-block:: vhdl - - type t_u_array is array(1 downto 0) of unsigned; - """ - - def __init__(self): - super().__init__(lTokens) - self.number_of_spaces = 1