From a3c5beedbd67d96f62bce77166326c9b0dec7641 Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Sun, 6 Dec 2020 10:43:30 -0600 Subject: [PATCH] Updates for issue #401 and #416: Added command line option --all_phases to allow VSG to not stop when a violation was found while analyzing a file. (cherry picked from commit 43d4498815be9ed3187a34409ea06834d7b6dfce) --- docs/index.rst | 1 + docs/tool_integration.rst | 21 +++++++++++++++++++++ docs/usage.rst | 7 ++++++- vsg/__main__.py | 3 ++- vsg/rule_list.py | 7 ++++--- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 docs/tool_integration.rst diff --git a/docs/index.rst b/docs/index.rst index aaab256a..989addd0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,6 +18,7 @@ Welcome to vhdl-style-guide's documentation! configuring code_tags editor_integration + tool_integration localizing phases rule_severity diff --git a/docs/tool_integration.rst b/docs/tool_integration.rst new file mode 100644 index 00000000..b6f500fc --- /dev/null +++ b/docs/tool_integration.rst @@ -0,0 +1,21 @@ +Tool Integration +---------------- + +VSG supports integration with other tools via several command line options. + ++-------------------------------+-------------------------------------------------+ +| --all-phases | Executes all phases without stopping if a | +| | violation is found. | ++-------------------------------+-------------------------------------------------+ + +--all-phases +############ + +VSG has a concept of phases, where violations in one phase should be addressed before moving to the next phase. +The **--all-phases** option will run an analysis over all the phases. +It will not stop if a violation has occured. + +This option can be useful when integrating VSG into an editor that supports linters. +It is important to note there are dependencies between some rules. +If violations for a later phase are fixed before violations on an earlier phase, it could lead to reoccurances of violations until the correct order is followed. + diff --git a/docs/usage.rst b/docs/usage.rst index b04f3145..cfd5e015 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -9,7 +9,7 @@ The command line tool can be invoked with: $ vsg usage: VHDL Style Guide (VSG) [-h] [-f FILENAME [FILENAME ...]] [-lr LOCAL_RULES] [-c CONFIGURATION [CONFIGURATION ...]] [--fix] [-fp FIX_PHASE] [-j JUNIT] [-of {vsg,syntastic}] [-b] [-oc OUTPUT_CONFIGURATION] - [-rc RULE_CONFIGURATION] [--style {indent_only,jcl}] [-v] [--debug] + [-rc RULE_CONFIGURATION] [--style {indent_only,jcl}] [-v] [-ap] [--debug] Analyzes VHDL files for style guide violations. Reference documentation is located at: http://vhdl-style- guide.readthedocs.io/en/latest/index.html @@ -37,6 +37,7 @@ The command line tool can be invoked with: --style {indent_only,jcl} Use predefined style -v, --version Displays version information + -ap, --all_phases Do not stop when a violation is detected. --debug Displays verbose debug information **Command Line Options** @@ -72,6 +73,7 @@ The command line tool can be invoked with: | | vsg -- standard VSG output | | | syntastic -- format compatible with the | | | syntastic VIM module | +| | json -- violations in a JSON format | +-------------------------------+-------------------------------------------------+ | --backup | Creates a copy of the input file before | | | applying any fixes. This can be used to | @@ -88,6 +90,9 @@ The command line tool can be invoked with: +-------------------------------+-------------------------------------------------+ | --version | Displays the version of VSG. | +-------------------------------+-------------------------------------------------+ +| --all-phases | Executes all phases without stopping if a | +| | violation is found. | ++-------------------------------+-------------------------------------------------+ Here is an example output running against a test file: diff --git a/vsg/__main__.py b/vsg/__main__.py index bdde7150..bcada26b 100644 --- a/vsg/__main__.py +++ b/vsg/__main__.py @@ -36,6 +36,7 @@ def parse_command_line_arguments(): parser.add_argument('-rc', '--rule_configuration', default=None, action='store', help='Display configuration of a rule') parser.add_argument('--style', action='store', default=None, choices=get_predefined_styles(), help='Use predefined style') parser.add_argument('-v', '--version', default=False, action='store_true', help='Displays version information') + parser.add_argument('-ap', '--all_phases', default=False, action='store_true', help='Do not stop when a violation is detected.') parser.add_argument('--debug', default=False, action='store_true', help='Displays verbose debug information') if len(sys.argv) == 1: @@ -380,7 +381,7 @@ def main(): oRules.oSeverityList.clear_severity_counts() oRules.clear_violations() - oRules.check_rules(commandLineArguments.skip_phase) + oRules.check_rules(bAllPhases=commandLineArguments.all_phases, lSkipPhase=commandLineArguments.skip_phase) oRules.report_violations(commandLineArguments.output_format) fExitStatus = update_exit_status(fExitStatus, oRules) diff --git a/vsg/rule_list.py b/vsg/rule_list.py index 813a4c48..755c46ad 100644 --- a/vsg/rule_list.py +++ b/vsg/rule_list.py @@ -189,14 +189,15 @@ class rule_list(): lReturn.append(oRule) return lReturn - def check_rules(self, lSkipPhase=[]): + def check_rules(self, bAllPhases=False, lSkipPhase=[]): ''' Analyzes all rules in increasing phase order. If there is a violation in a phase, analysis is halted. Parameters: - lSkipPhase : (list of integers) + bAllPhases : (boolean) + lSkipPhase : (list of integers) ''' self.iNumberRulesRan = 0 iFailures = 0 @@ -214,7 +215,7 @@ class rule_list(): iFailures += len(oRule.violations) self.iNumberRulesRan += 1 self.lastPhaseRan = phase - if iFailures > 0: + if iFailures > 0 and not bAllPhases: self.violations = True break