Skip to content

Commit

Permalink
Merge pull request #1386 from JHertz5/issue-1385
Browse files Browse the repository at this point in the history
Issue#1385: Replace rules iteration_scheme_502 and for_generate_statement_502 with a parameter_specification rule
  • Loading branch information
jeremiah-c-leary authored Jan 5, 2025
2 parents d3f6e80 + 1772081 commit 267e02b
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 302 deletions.
3 changes: 1 addition & 2 deletions docs/configuring_uppercase_and_lowercase_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ Rules Enforcing Case

* `for_generate_statement_500 <for_generate_statement_rules.html#for-generate-statement-500>`_
* `for_generate_statement_501 <for_generate_statement_rules.html#for-generate-statement-501>`_
* `for_generate_statement_502 <for_generate_statement_rules.html#for-generate-statement-502>`_

* `function_004 <function_rules.html#function-004>`_
* `function_005 <function_rules.html#function-005>`_
Expand Down Expand Up @@ -390,7 +389,6 @@ Rules Enforcing Case

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

* `library_004 <library_rules.html#library-004>`_
* `library_005 <library_rules.html#library-005>`_
Expand Down Expand Up @@ -432,6 +430,7 @@ Rules Enforcing Case
* `package_instantiation_504 <package_instantiation_rules.html#package-instantiation-504>`_

* `parameter_specification_500 <parameter_specification_rules.html#parameter-specification-500>`_
* `parameter_specification_501 <parameter_specification_rules.html#parameter-specification-501>`_

* `port_010 <port_rules.html#port-010>`_
* `port_017 <port_rules.html#port-017>`_
Expand Down
18 changes: 1 addition & 17 deletions docs/for_generate_statement_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,4 @@ This rule checks the **generate** keyword has proper case.
for_generate_statement_502
##########################

|phase_6| |error| |case| |case_keyword|

This rule checks the **in** keyword has proper case.

|configuring_uppercase_and_lowercase_rules_link|

**Violation**

.. code-block:: vhdl
gen_label : for lv_thing IN t_thing generate
**Fix**

.. code-block:: vhdl
gen_label : for lv_thing in t_thing generate
This rule has been deprecated and replaced with rule `parameter_specification_501 <parameter_specification_rules.html#parameter-specification-501>`_.
18 changes: 1 addition & 17 deletions docs/iteration_scheme_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,4 @@ This rule checks the **for** keyword has proper case.
iteration_scheme_502
####################

|phase_6| |error| |case| |case_keyword|

This rule checks the **in** keyword has proper case.

|configuring_uppercase_and_lowercase_rules_link|

**Violation**

.. code-block:: vhdl
for lv_thing IN t_thing loop
**Fix**

.. code-block:: vhdl
for lv_thing in t_thing loop
This rule has been deprecated and replaced with rule `parameter_specification_501 <parameter_specification_rules.html#parameter-specification-501>`_.
21 changes: 21 additions & 0 deletions docs/parameter_specification_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@ This rule checks the parameter identifier has proper case.
.. code-block:: vhdl
for lv_thing in t_thing loop
parameter_specification_501
###########################

|phase_6| |error| |case| |case_keyword|

This rule checks the **in** keyword has proper case.

|configuring_uppercase_and_lowercase_rules_link|

**Violation**

.. code-block:: vhdl
for lv_thing IN t_thing loop
**Fix**

.. code-block:: vhdl
for lv_thing in t_thing loop
3 changes: 1 addition & 2 deletions docs/rule_groups/case_keyword_rule_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Rules Enforcing Case::Keyword Rule Group
* `file_002 <../file_rules.html#file-002>`_
* `for_generate_statement_500 <../for_generate_statement_rules.html#for-generate-statement-500>`_
* `for_generate_statement_501 <../for_generate_statement_rules.html#for-generate-statement-501>`_
* `for_generate_statement_502 <../for_generate_statement_rules.html#for-generate-statement-502>`_
* `function_004 <../function_rules.html#function-004>`_
* `function_005 <../function_rules.html#function-005>`_
* `function_013 <../function_rules.html#function-013>`_
Expand Down Expand Up @@ -103,7 +102,6 @@ Rules Enforcing Case::Keyword Rule Group
* `instantiation_031 <../instantiation_rules.html#instantiation-031>`_
* `iteration_scheme_500 <../iteration_scheme_rules.html#iteration-scheme-500>`_
* `iteration_scheme_501 <../iteration_scheme_rules.html#iteration-scheme-501>`_
* `iteration_scheme_502 <../iteration_scheme_rules.html#iteration-scheme-502>`_
* `library_004 <../library_rules.html#library-004>`_
* `library_005 <../library_rules.html#library-005>`_
* `logical_operator_500 <../logical_operator_rules.html#logical-operator-500>`_
Expand All @@ -126,6 +124,7 @@ Rules Enforcing Case::Keyword Rule Group
* `package_instantiation_500 <../package_instantiation_rules.html#package-instantiation-500>`_
* `package_instantiation_502 <../package_instantiation_rules.html#package-instantiation-502>`_
* `package_instantiation_503 <../package_instantiation_rules.html#package-instantiation-503>`_
* `parameter_specification_501 <../parameter_specification_rules.html#parameter-specification-501>`_
* `port_017 <../port_rules.html#port-017>`_
* `port_019 <../port_rules.html#port-019>`_
* `port_map_001 <../port_map_rules.html#port-map-001>`_
Expand Down
3 changes: 1 addition & 2 deletions docs/rule_groups/case_rule_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ Rules Enforcing Case Rule Group
* `file_002 <../file_rules.html#file-002>`_
* `for_generate_statement_500 <../for_generate_statement_rules.html#for-generate-statement-500>`_
* `for_generate_statement_501 <../for_generate_statement_rules.html#for-generate-statement-501>`_
* `for_generate_statement_502 <../for_generate_statement_rules.html#for-generate-statement-502>`_
* `function_004 <../function_rules.html#function-004>`_
* `function_005 <../function_rules.html#function-005>`_
* `function_010 <../function_rules.html#function-010>`_
Expand Down Expand Up @@ -142,7 +141,6 @@ Rules Enforcing Case Rule Group
* `instantiation_500 <../instantiation_rules.html#instantiation-500>`_
* `iteration_scheme_500 <../iteration_scheme_rules.html#iteration-scheme-500>`_
* `iteration_scheme_501 <../iteration_scheme_rules.html#iteration-scheme-501>`_
* `iteration_scheme_502 <../iteration_scheme_rules.html#iteration-scheme-502>`_
* `library_004 <../library_rules.html#library-004>`_
* `library_005 <../library_rules.html#library-005>`_
* `library_500 <../library_rules.html#library-500>`_
Expand Down Expand Up @@ -175,6 +173,7 @@ Rules Enforcing Case Rule Group
* `package_instantiation_503 <../package_instantiation_rules.html#package-instantiation-503>`_
* `package_instantiation_504 <../package_instantiation_rules.html#package-instantiation-504>`_
* `parameter_specification_500 <../parameter_specification_rules.html#parameter-specification-500>`_
* `parameter_specification_501 <../parameter_specification_rules.html#parameter-specification-501>`_
* `port_010 <../port_rules.html#port-010>`_
* `port_017 <../port_rules.html#port-017>`_
* `port_019 <../port_rules.html#port-019>`_
Expand Down
14 changes: 0 additions & 14 deletions tests/for_generate_statement/rule_502_test_input.fixed_lower.vhd

This file was deleted.

14 changes: 0 additions & 14 deletions tests/for_generate_statement/rule_502_test_input.fixed_upper.vhd

This file was deleted.

14 changes: 0 additions & 14 deletions tests/for_generate_statement/rule_502_test_input.vhd

This file was deleted.

66 changes: 3 additions & 63 deletions tests/for_generate_statement/test_rule_502.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,14 @@
# -*- coding: utf-8 -*-

import os
import unittest

from tests import utils
from vsg import vhdlFile
from vsg.rules import for_generate_statement

sTestDir = os.path.dirname(__file__)

lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_502_test_input.vhd"))

lExpected_lower = []
lExpected_lower.append("")
utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_lower.vhd"), lExpected_lower)

lExpected_upper = []
lExpected_upper.append("")
utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_upper.vhd"), lExpected_upper)


class test_for_generate_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)

def test_rule_502_lower(self):
class test_rule(unittest.TestCase):
def test_rule_502(self):
oRule = for_generate_statement.rule_502()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "for_generate_statement")
self.assertEqual(oRule.identifier, "502")
self.assertEqual(oRule.groups, ["case", "case::keyword"])

lExpected = [10]

oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)

def test_rule_502_upper(self):
oRule = for_generate_statement.rule_502()
oRule.case = "upper"
self.assertTrue(oRule)
self.assertEqual(oRule.name, "for_generate_statement")
self.assertEqual(oRule.identifier, "502")

lExpected = [6]
oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)

def test_fix_rule_502_lower(self):
oRule = for_generate_statement.rule_502()

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected_lower, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

def test_fix_rule_502_upper(self):
oRule = for_generate_statement.rule_502()
oRule.case = "upper"

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected_upper, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
self.assertTrue(oRule.deprecated)
14 changes: 0 additions & 14 deletions tests/iteration_scheme/rule_502_test_input.fixed_lower.vhd

This file was deleted.

14 changes: 0 additions & 14 deletions tests/iteration_scheme/rule_502_test_input.fixed_upper.vhd

This file was deleted.

14 changes: 0 additions & 14 deletions tests/iteration_scheme/rule_502_test_input.vhd

This file was deleted.

66 changes: 3 additions & 63 deletions tests/iteration_scheme/test_rule_502.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,14 @@
# -*- coding: utf-8 -*-

import os
import unittest

from tests import utils
from vsg import vhdlFile
from vsg.rules import iteration_scheme

sTestDir = os.path.dirname(__file__)

lFile, eError = vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir, "rule_502_test_input.vhd"))

lExpected_lower = []
lExpected_lower.append("")
utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_lower.vhd"), lExpected_lower)

lExpected_upper = []
lExpected_upper.append("")
utils.read_file(os.path.join(sTestDir, "rule_502_test_input.fixed_upper.vhd"), lExpected_upper)


class test_iteration_scheme_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)

def test_rule_502_lower(self):
class test_rule(unittest.TestCase):
def test_rule_502(self):
oRule = iteration_scheme.rule_502()
self.assertTrue(oRule)
self.assertEqual(oRule.name, "iteration_scheme")
self.assertEqual(oRule.identifier, "502")
self.assertEqual(oRule.groups, ["case", "case::keyword"])

lExpected = [10]

oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)

def test_rule_502_upper(self):
oRule = iteration_scheme.rule_502()
oRule.case = "upper"
self.assertTrue(oRule)
self.assertEqual(oRule.name, "iteration_scheme")
self.assertEqual(oRule.identifier, "502")

lExpected = [8]
oRule.analyze(self.oFile)
self.assertEqual(utils.extract_violation_lines_from_violation_object(oRule.violations), lExpected)

def test_fix_rule_502_lower(self):
oRule = iteration_scheme.rule_502()

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected_lower, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])

def test_fix_rule_502_upper(self):
oRule = iteration_scheme.rule_502()
oRule.case = "upper"

oRule.fix(self.oFile)

lActual = self.oFile.get_lines()

self.assertEqual(lExpected_upper, lActual)

oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
self.assertTrue(oRule.deprecated)
Loading

0 comments on commit 267e02b

Please sign in to comment.