diff --git a/bin/vsg b/bin/vsg index 4cd6f842..4521dbb0 100755 --- a/bin/vsg +++ b/bin/vsg @@ -28,6 +28,7 @@ def parse_command_line_arguments(): parser.add_argument('--local_rules', help='Path to local rules') parser.add_argument('--configuration', help='JSON configuration file') parser.add_argument('--fix', default=False, action='store_true', help='Fix issues found') + parser.add_argument('--fix_phase', default=10, action='store', help='Fix issues up to and including this phase') parser.add_argument('--junit', action='store', help='Extract Junit file') if len(sys.argv) == 1: @@ -95,7 +96,7 @@ def main(): oRules.configure(configuration) if commandLineArguments.fix: - oRules.fix() + oRules.fix(commandLineArguments.fix_phase) write_vhdl_file(oVhdlFile) oRules.check_rules() diff --git a/vsg/rule_list.py b/vsg/rule_list.py index d07da781..a3428f69 100644 --- a/vsg/rule_list.py +++ b/vsg/rule_list.py @@ -82,11 +82,11 @@ class rule_list(): self.oVhdlFile = oVhdlFile self.maximumPhase = maximum_phase(self.rules) - def fix(self): + def fix(self, iPhase): ''' Applies fixes to all violations found. ''' - for phase in range(1, 10): + for phase in range(1, int(iPhase) + 1): for oRule in self.rules: if oRule.phase == phase and not oRule.disable: oRule.fix(self.oVhdlFile) diff --git a/vsg/tests/code_examples/c16/test_code_examples.py b/vsg/tests/code_examples/c16/test_code_examples.py index 59ac019f..16a9cceb 100644 --- a/vsg/tests/code_examples/c16/test_code_examples.py +++ b/vsg/tests/code_examples/c16/test_code_examples.py @@ -15,7 +15,7 @@ class testCodeExample(unittest.TestCase): def test_baudgen(self): oRuleList = rule_list.rule_list(oBaudGen) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'BaudGen.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -23,7 +23,7 @@ class testCodeExample(unittest.TestCase): def test_board_cpu(self): oRuleList = rule_list.rule_list(oBoardCpu) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'Board_cpu.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -31,7 +31,7 @@ class testCodeExample(unittest.TestCase): def test_data_core(self): oRuleList = rule_list.rule_list(oDataCore) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'data_core.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): diff --git a/vsg/tests/code_examples/graphicsaccelerator/test_code_examples.py b/vsg/tests/code_examples/graphicsaccelerator/test_code_examples.py index e249fa71..c133e253 100644 --- a/vsg/tests/code_examples/graphicsaccelerator/test_code_examples.py +++ b/vsg/tests/code_examples/graphicsaccelerator/test_code_examples.py @@ -18,7 +18,7 @@ class testCodeExample(unittest.TestCase): def test_bresenhamer(self): oRuleList = rule_list.rule_list(oBresenhamer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'Bresenhamer.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -26,7 +26,7 @@ class testCodeExample(unittest.TestCase): def test_debouncer(self): oRuleList = rule_list.rule_list(oDebouncer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'Debouncer.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -34,7 +34,7 @@ class testCodeExample(unittest.TestCase): def test_vga_top(self): oRuleList = rule_list.rule_list(oVgatop) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'VGA_Top.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -42,7 +42,7 @@ class testCodeExample(unittest.TestCase): def test_pointer(self): oRuleList = rule_list.rule_list(oPointer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'Pointer.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -50,7 +50,7 @@ class testCodeExample(unittest.TestCase): def test_freqdiv(self): oRuleList = rule_list.rule_list(oFreqDiv) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'FreqDiv.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -58,7 +58,7 @@ class testCodeExample(unittest.TestCase): def test_synchronizer(self): oRuleList = rule_list.rule_list(oSynchronizer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'Synchronizer.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -66,7 +66,7 @@ class testCodeExample(unittest.TestCase): def test_framebuffer(self): oRuleList = rule_list.rule_list(oFrameBuffer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'FrameBuffer2.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): diff --git a/vsg/tests/code_examples/test_code_examples.py b/vsg/tests/code_examples/test_code_examples.py index ba7826d8..af9c006e 100644 --- a/vsg/tests/code_examples/test_code_examples.py +++ b/vsg/tests/code_examples/test_code_examples.py @@ -16,7 +16,7 @@ class testVhdlFileMethods(unittest.TestCase): def test_timestamp_vhdl(self): oRuleList = rule_list.rule_list(oTimestamp) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'timestamp.fixed.vhdl'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -24,7 +24,7 @@ class testVhdlFileMethods(unittest.TestCase): def test_spi_slave(self): oRuleList = rule_list.rule_list(oSpiSlave) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'spi_slave.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -32,7 +32,7 @@ class testVhdlFileMethods(unittest.TestCase): def test_spi_master(self): oRuleList = rule_list.rule_list(oSpiMaster) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'spi_master.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -40,7 +40,7 @@ class testVhdlFileMethods(unittest.TestCase): def test_grp_debouncer(self): oRuleList = rule_list.rule_list(oGrpDebouncer) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'grp_debouncer.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): @@ -48,7 +48,7 @@ class testVhdlFileMethods(unittest.TestCase): def test_pic(self): oRuleList = rule_list.rule_list(oPIC) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'PIC.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): diff --git a/vsg/tests/code_examples/turbocodes/test_code_examples.py b/vsg/tests/code_examples/turbocodes/test_code_examples.py index 20a2db08..c10d5dc8 100644 --- a/vsg/tests/code_examples/turbocodes/test_code_examples.py +++ b/vsg/tests/code_examples/turbocodes/test_code_examples.py @@ -13,7 +13,7 @@ class testCodeExample(unittest.TestCase): def test_iteration_synth(self): oRuleList = rule_list.rule_list(oIteration) - oRuleList.fix() + oRuleList.fix(7) lExpected = [''] utils.read_file(os.path.join(os.path.dirname(__file__),'iteration_synth.fixed.vhd'), lExpected) for iLineNumber, sLine in enumerate(lExpected): diff --git a/vsg/tests/comment/test_fix_rule_comment.py b/vsg/tests/comment/test_fix_rule_comment.py index 72f932cc..286740cf 100644 --- a/vsg/tests/comment/test_fix_rule_comment.py +++ b/vsg/tests/comment/test_fix_rule_comment.py @@ -62,7 +62,7 @@ class testFixRuleCommentMethods(unittest.TestCase): def test_rule_001(self): oRuleList = rule_list.rule_list(oFileLibrary) dExpected = [] - oRuleList.fix() + oRuleList.fix(7) oRuleList.check_rules() self.assertEqual(oFileLibrary.lines[4].indentLevel, 1) diff --git a/vsg/tests/if_statement/test_fix_rule_if.py b/vsg/tests/if_statement/test_fix_rule_if.py index fd9b6c56..e7c21a41 100644 --- a/vsg/tests/if_statement/test_fix_rule_if.py +++ b/vsg/tests/if_statement/test_fix_rule_if.py @@ -214,7 +214,7 @@ class testFixRuleIfMethods(unittest.TestCase): def test_fix_compressed_line(self): oRuleList = rule_list.rule_list(oFileCompress) - oRuleList.fix() + oRuleList.fix(7) # utils.debug_lines(oFileCompress, 9, 10) self.assertEqual(oFileCompress.lines[10].line, ' if (A = \'1\' and B = \'1\') then') self.assertEqual(oFileCompress.lines[11].line, ' X <= \'1\';')