diff --git a/vsg/rules/constant/rule_012.py b/vsg/rules/constant/rule_012.py index 57f12159..9dc624b8 100644 --- a/vsg/rules/constant/rule_012.py +++ b/vsg/rules/constant/rule_012.py @@ -55,7 +55,7 @@ class rule_012(rule.Rule): lColumn = [] lColumn.append(iStartColumn) bCheckAlignment = False - iFirstColumn, iNextColumn = _find_first_column(oFile, oToi, self.align_left, self.indentSize) + iFirstColumn, iNextColumn, iLastColumn = _find_first_column(oFile, oToi, self.align_left, self.indentSize, self.indent_step) iColumn = iFirstColumn iPreviousColumn = 0 iIndent = 0 @@ -76,7 +76,10 @@ class rule_012(rule.Rule): if isinstance(lTokens[iToken + 1], parser.whitespace): iIndent = len(lTokens[iToken + 1].get_value()) if isinstance(lTokens[iToken + 2], parser.close_parenthesis): - lColumn.pop() + if len(lColumn) > 1: + lColumn.pop() + else: + lColumn = [iLastColumn] # print(f'Close Paren = {lColumn}') bSkipPop = True @@ -160,13 +163,28 @@ def calculate_start_column(oFile, oToi): return iReturn -def _find_first_column(oFile, oToi, bAlignLeft, iIndentSize): +def _find_first_column(oFile, oToi, bAlignLeft, iIndentSize, iIndentStep): iStartIndex = oToi.get_start_index() if bAlignLeft: iFirstColumn = oFile.get_column_of_token_index(iStartIndex) iIndentLevel = oFile.get_indent_of_line_at_index(iStartIndex) - iNextColumn = iIndentSize * iIndentLevel + if is_token_before_carriage_return(parser.open_parenthesis, oToi.get_tokens()): + iNextColumn = iIndentSize * iIndentLevel + iIndentStep + iLastColumn = iIndentSize * iIndentLevel + else: + iNextColumn = iIndentSize * iIndentLevel + iLastColumn = iIndentSize * iIndentLevel else: iFirstColumn = oFile.get_column_of_token_index(iStartIndex) iNextColumn = iFirstColumn - return iFirstColumn, iNextColumn + iLastColumn = iFirstColumn + return iFirstColumn, iNextColumn, iLastColumn + + +def is_token_before_carriage_return(tToken, lTokens): + for oToken in lTokens: + if isinstance(oToken, tToken): + return True + if isinstance(oToken, parser.carriage_return): + return False + return False diff --git a/vsg/rules/constant/rule_016.py b/vsg/rules/constant/rule_016.py index 9490cc3e..ed1ed308 100644 --- a/vsg/rules/constant/rule_016.py +++ b/vsg/rules/constant/rule_016.py @@ -31,8 +31,7 @@ class rule_016(rule.Rule): def __init__(self): rule.Rule.__init__(self, 'constant', '016') self.solution = 'Align one space after assignment operator' - self.phase = 5 - self.subphase = 4 + self.phase = 1 self.lTokenPairs = lTokenPairs self.bExcludeLastToken = False self.first_paren_new_line = False diff --git a/vsg/tests/constant/rule_012_test_input.fixed_align_left_false.vhd b/vsg/tests/constant/rule_012_test_input.fixed_align_left_false.vhd index 38426899..09fa25e5 100644 --- a/vsg/tests/constant/rule_012_test_input.fixed_align_left_false.vhd +++ b/vsg/tests/constant/rule_012_test_input.fixed_align_left_false.vhd @@ -97,3 +97,14 @@ begin end architecture rtl; + +architecture rtl of fifo is + + constant avmm_master_null : avmm_master_t := ( + (others => '0'), + (others => '0'), + '0', + '0' + ); + +begin end architecture rtl; diff --git a/vsg/tests/constant/rule_012_test_input.fixed_align_left_true.vhd b/vsg/tests/constant/rule_012_test_input.fixed_align_left_true.vhd index f3209fe3..4c9c8618 100644 --- a/vsg/tests/constant/rule_012_test_input.fixed_align_left_true.vhd +++ b/vsg/tests/constant/rule_012_test_input.fixed_align_left_true.vhd @@ -8,7 +8,7 @@ architecture rtl of fifo is constant c_stimulus : t_stimulus_array := ((name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); constant c_stimulus : t_stimulus_array := ( - (name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); + (name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); constant c_stimulus : t_stimulus_array := ((name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); @@ -97,3 +97,14 @@ begin end architecture rtl; + +architecture rtl of fifo is + + constant avmm_master_null : avmm_master_t := ( + (others => '0'), + (others => '0'), + '0', + '0' + ); + +begin end architecture rtl; diff --git a/vsg/tests/constant/rule_012_test_input.fixed_align_left_true_indent_step_2.vhd b/vsg/tests/constant/rule_012_test_input.fixed_align_left_true_indent_step_2.vhd index 830c7ba8..bfae93e9 100644 --- a/vsg/tests/constant/rule_012_test_input.fixed_align_left_true_indent_step_2.vhd +++ b/vsg/tests/constant/rule_012_test_input.fixed_align_left_true_indent_step_2.vhd @@ -8,7 +8,7 @@ architecture rtl of fifo is constant c_stimulus : t_stimulus_array := ((name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); constant c_stimulus : t_stimulus_array := ( - (name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); + (name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); constant c_stimulus : t_stimulus_array := ((name => "Hold in reset", clk_in => "01", rst_in => "11", cnt_en_in => "00", cnt_out => "00"), (name => "Not enabled", clk_in => "01", rst_in => "00", cnt_en_in => "00", cnt_out => "00")); @@ -97,3 +97,14 @@ begin end architecture rtl; + +architecture rtl of fifo is + + constant avmm_master_null : avmm_master_t := ( + (others => '0'), + (others => '0'), + '0', + '0' + ); + +begin end architecture rtl; diff --git a/vsg/tests/constant/rule_012_test_input.vhd b/vsg/tests/constant/rule_012_test_input.vhd index 2f21fcb9..9af514bc 100644 --- a/vsg/tests/constant/rule_012_test_input.vhd +++ b/vsg/tests/constant/rule_012_test_input.vhd @@ -97,3 +97,14 @@ name => "Hold in reset", end architecture rtl; + +architecture rtl of fifo is + + constant avmm_master_null : avmm_master_t := ( + (others => '0'), + (others => '0'), + '0', + '0' + ); + +begin end architecture rtl; diff --git a/vsg/tests/constant/test_rule_012.py b/vsg/tests/constant/test_rule_012.py index ce170753..7f260f24 100644 --- a/vsg/tests/constant/test_rule_012.py +++ b/vsg/tests/constant/test_rule_012.py @@ -49,6 +49,7 @@ class test_constant_rule(unittest.TestCase): lExpected.extend(range(41, 55)) lExpected.extend(range(57, 73)) lExpected.extend(range(79, 95)) + lExpected.extend(range(104, 109)) oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) @@ -82,6 +83,7 @@ class test_constant_rule(unittest.TestCase): lExpected.extend(range(41, 55)) lExpected.extend(range(57, 73)) lExpected.extend(range(79, 95)) + lExpected.extend(range(104, 108)) oRule.analyze(self.oFile) self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))