From a124535519deff2ec536691fa7b79a1e190cf247 Mon Sep 17 00:00:00 2001 From: jce Date: Wed, 16 Oct 2024 19:06:45 +0200 Subject: [PATCH 1/5] Clarify documentation about Coverity checker --- README.rst | 61 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/README.rst b/README.rst index 49608a05..6a708235 100644 --- a/README.rst +++ b/README.rst @@ -184,7 +184,7 @@ command: Parse for Coverity Defects -------------------------- -Coverity is a static analysis tool which has option to run desktop analysis +Coverity is a static analysis tool that includes a CLI tool to run desktop analysis on your local changes and report the results back directly in the console. You only need to list affected files and below example lists changed files between your branch and master, which it then forwards to ``cov-run-desktop``: @@ -193,8 +193,8 @@ between your branch and master, which it then forwards to ``cov-run-desktop``: cov-run-desktop --text-output-style=oneline `git diff --name-only --ignore-submodules master` -You can pipe the results to logfile, which you pass to warnings-plugin, or you use -the ``--command`` argument and execute the ``cov-run-desktop`` through +You can either pipe the results to a log file and pass it to the warnings-plugin, or you can use +the ``--command`` argument to let the plugin invoke ``cov-run-desktop``. .. code-block:: bash @@ -211,48 +211,49 @@ the ``--command`` argument and execute the ``cov-run-desktop`` through python -m mlx.warnings --coverity --command -We utilize `cov-run-desktop` in the following manner, where the output is saved in `coverity.log`: +The command below demonstrates how we utilize `cov-run-desktop`: .. code-block:: bash - cov-run-desktop --text-output-style=oneline --exit1-if-defects false --triage-attribute-regex "classification" ".*" | tee coverity.log + cov-run-desktop --text-output-style=oneline --exit1-if-defects false --triage-attribute-regex "classification" ".*" | tee raw_defects.log -Subsequently, we process the `coverity.log` file with the mlx-warnings plugin. -The plugin uses a configuration file (`warnings_coverity.yml`) and produces two outputs: -a text file (`warnings_coverity.txt`) and a code quality JSON file (`coverity_code_quality.json`). +Then, the mlx-warnings plugin processes the output log file, `raw_defects.log`, based on the configuration file +`warnings_coverity.yml` to produces three outputs: + +- A text file called `warnings_coverity.txt`, which contains all Coverity defe. +- A code quality JSON file `coverity_code_quality.json`. +- A return code equal to the amount of violations, i.e. the amount of Coverity defects that exceeds the configured + limit(s). The value is 0 if the amount of Coverity defects is within limits. We use this return code to determine + whether our CI job passes or fails. .. code-block:: bash - mlx-warnings --config warnings_coverity.yml -o warnings_coverity.txt -C coverity_code_quality.json coverity.log + mlx-warnings --config config.yml --output counted_defects.txt --code-quality report.json raw_defects.log -This is an example of the configuration file: +Below is an example configuration for the Coverity checker: .. code-block:: yaml - sphinx: - enabled: false - doxygen: - enabled: false - junit: - enabled: false - xmlrunner: - enabled: false coverity: enabled: true - intentional: - max: -1 - bug: - max: 0 + unclassified: + max: 0 pending: - max: 0 + max: 0 false_positive: - max: -1 - robot: - enabled: false - polyspace: - enabled: false - -For each classification, a minimum and maximum can be given. + max: -1 + intentional: + max: -1 + bug: + min: 2 + max: 2 + +As you can see, we have configured limits for 5 out of 5 Coverity Classifications. You can configure a minimum and a +maximum limit for the number of allowed Coverity defects the belong the the Classification. +The default value for both limits is 0. +A value of `-1` for `max` corresponds to effectively no limit (an infinite amount). +If one or more Classifications are not present in your configuration, the corresponding defects will be ignored +completely. .. note:: The warnings-plugin counts only one warning if there are multiple warnings for the same CID. From 7a80fbcac5488cc285138bebd30317a095403141 Mon Sep 17 00:00:00 2001 From: jce Date: Thu, 17 Oct 2024 12:42:45 +0200 Subject: [PATCH 2/5] More tweaks and fixes --- README.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index 6a708235..d3b186fb 100644 --- a/README.rst +++ b/README.rst @@ -187,11 +187,11 @@ Parse for Coverity Defects Coverity is a static analysis tool that includes a CLI tool to run desktop analysis on your local changes and report the results back directly in the console. You only need to list affected files and below example lists changed files -between your branch and master, which it then forwards to ``cov-run-desktop``: +between your source and target branch, e.g. 'main', which it then forwards to ``cov-run-desktop``: .. code-block:: bash - cov-run-desktop --text-output-style=oneline `git diff --name-only --ignore-submodules master` + cov-run-desktop --text-output-style=oneline `git diff --name-only --ignore-submodules main` You can either pipe the results to a log file and pass it to the warnings-plugin, or you can use the ``--command`` argument to let the plugin invoke ``cov-run-desktop``. @@ -217,14 +217,13 @@ The command below demonstrates how we utilize `cov-run-desktop`: cov-run-desktop --text-output-style=oneline --exit1-if-defects false --triage-attribute-regex "classification" ".*" | tee raw_defects.log -Then, the mlx-warnings plugin processes the output log file, `raw_defects.log`, based on the configuration file -`warnings_coverity.yml` to produces three outputs: +Then, the mlx-warnings plugin processes the output log file, `raw_defects.log`, based on the optional configuration file +`config.yml` to produces three outputs: -- A text file called `warnings_coverity.txt`, which contains all Coverity defe. -- A code quality JSON file `coverity_code_quality.json`. -- A return code equal to the amount of violations, i.e. the amount of Coverity defects that exceeds the configured - limit(s). The value is 0 if the amount of Coverity defects is within limits. We use this return code to determine - whether our CI job passes or fails. +- A text file that contains all counted Coverity defects. +- `A Code Quality report`_ `report.json` that contains all counted Coverity defects. +- A return code equal to the amount of counted Coverity defects. The value is 0 if the amount of Coverity defects is + within limits. We use this return code to determine whether our CI job passes or fails. .. code-block:: bash @@ -240,20 +239,21 @@ Below is an example configuration for the Coverity checker: max: 0 pending: max: 0 + bug: + min: 2 + max: 2 false_positive: max: -1 intentional: max: -1 - bug: - min: 2 - max: 2 As you can see, we have configured limits for 5 out of 5 Coverity Classifications. You can configure a minimum and a -maximum limit for the number of allowed Coverity defects the belong the the Classification. +maximum limit for the number of allowed Coverity defects that belong to the Classification. The default value for both limits is 0. A value of `-1` for `max` corresponds to effectively no limit (an infinite amount). -If one or more Classifications are not present in your configuration, the corresponding defects will be ignored -completely. +If one or more Classifications are missing from your configuration, the Coverity defects are counted and 0 are +allowed. To ignore certain classifications, modify the value for +`cov-run-desktop --triage-attribute-regex "classification"`. .. note:: The warnings-plugin counts only one warning if there are multiple warnings for the same CID. From 2876581a3861fedc825a3be38dc991a1e18da996 Mon Sep 17 00:00:00 2001 From: jce Date: Thu, 17 Oct 2024 12:43:25 +0200 Subject: [PATCH 3/5] Improve readability --- README.rst | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index d3b186fb..f01699fe 100644 --- a/README.rst +++ b/README.rst @@ -150,14 +150,14 @@ command: # command line log file mlx-warnings doc_log.txt --sphinx # command line command execution - mlx-warnings --sphinx --command + mlx-warnings --sphinx --command # explicitly as python module for log file python3 -m mlx.warnings --sphinx doc_log.txt python -m mlx.warnings --sphinx doc_log.txt # explicitly as python module - python3 -m mlx.warnings --sphinx --command - python -m mlx.warnings --sphinx --command + python3 -m mlx.warnings --sphinx --command + python -m mlx.warnings --sphinx --command Parse for Doxygen Warnings @@ -171,14 +171,14 @@ command: # command line log file mlx-warnings doc_log.txt --doxygen # command line command execution - mlx-warnings --doxygen --command + mlx-warnings --doxygen --command # explicitly as python module for log file python3 -m mlx.warnings --doxygen doc_log.txt python -m mlx.warnings --doxygen doc_log.txt # explicitly as python module - python3 -m mlx.warnings --doxygen --command - python -m mlx.warnings --doxygen --command + python3 -m mlx.warnings --doxygen --command + python -m mlx.warnings --doxygen --command Parse for Coverity Defects @@ -201,14 +201,14 @@ the ``--command`` argument to let the plugin invoke ``cov-run-desktop``. # command line log file mlx-warnings --coverity cov-run-desktop-output.txt # command line command execution - mlx-warnings --coverity --command + mlx-warnings --coverity --command # explicitly as python module for log file python3 -m mlx.warnings --coverity cov-run-desktop-output.txt python -m mlx.warnings --coverity cov-run-desktop-output.txt # explicitly as python module - python3 -m mlx.warnings --coverity --command - python -m mlx.warnings --coverity --command + python3 -m mlx.warnings --coverity --command + python -m mlx.warnings --coverity --command The command below demonstrates how we utilize `cov-run-desktop`: @@ -269,14 +269,14 @@ command: # command line log file mlx-warnings junit_output.xml --junit # command line command execution - mlx-warnings --junit --command + mlx-warnings --junit --command # explicitly as python module for log file python3 -m mlx.warnings --junit junit_output.xml python -m mlx.warnings --junit junit_output.xml # explicitly as python module - python3 -m mlx.warnings --junit --command - python -m mlx.warnings --junit --command + python3 -m mlx.warnings --junit --command + python -m mlx.warnings --junit --command Parse for XMLRunner Errors @@ -293,14 +293,14 @@ with command: # command line log file mlx-warnings xmlrunner_log.txt --xmlrunner # command line command execution - mlx-warnings --xmlrunner --command + mlx-warnings --xmlrunner --command # explicitly as python module for log file python3 -m mlx.warnings --xmlrunner xmlrunner_log.txt python -m mlx.warnings --xmlrunner xmlrunner_log.txt # explicitly as python module - python3 -m mlx.warnings --xmlrunner --command - python -m mlx.warnings --xmlrunner --command + python3 -m mlx.warnings --xmlrunner --command + python -m mlx.warnings --xmlrunner --command .. _XMLRunner: https://github.com/xmlrunner/unittest-xml-reporting @@ -492,7 +492,7 @@ path to configuration file # command line log file mlx-warnings --config path/to/config.json junit_output.xml # command line command execution - mlx-warnings --config path/to/config.json --command + mlx-warnings --config path/to/config.json --command ------------- From 0e9d174fb7494b7a81aeaca0313ebe2c0f48ae3d Mon Sep 17 00:00:00 2001 From: JWM Date: Mon, 21 Oct 2024 14:55:04 +0200 Subject: [PATCH 4/5] Add `Coverity` to sentence of cq report --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f01699fe..53d648c6 100644 --- a/README.rst +++ b/README.rst @@ -570,7 +570,7 @@ Code Quality Report ------------------- Use ``-C, --code-quality`` to let the plugin generate `a Code Quality report`_ for GitLab CI. All counted -Sphinx, Doxygen, XMLRunner and Polyspace warnings/errors/failures will be included. Other checker types are not yet supported by this feature. The report is +Sphinx, Doxygen, XMLRunner, Coverity and Polyspace warnings/errors/failures will be included. Other checker types are not yet supported by this feature. The report is a JSON file that implements `a subset of the Code Climate spec`_. Define this file `as a codequality report artifact`_ of the CI job. From b8db8a396857bc6bf986ddaaec3a82070da64ecd Mon Sep 17 00:00:00 2001 From: Jasper Craeghs <28319872+JasperCraeghs@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:22:58 +0200 Subject: [PATCH 5/5] Fix typo Co-authored-by: JWM <62558419+JokeWaumans@users.noreply.github.com> --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 53d648c6..a4add18c 100644 --- a/README.rst +++ b/README.rst @@ -218,7 +218,7 @@ The command below demonstrates how we utilize `cov-run-desktop`: cov-run-desktop --text-output-style=oneline --exit1-if-defects false --triage-attribute-regex "classification" ".*" | tee raw_defects.log Then, the mlx-warnings plugin processes the output log file, `raw_defects.log`, based on the optional configuration file -`config.yml` to produces three outputs: +`config.yml` to produce three outputs: - A text file that contains all counted Coverity defects. - `A Code Quality report`_ `report.json` that contains all counted Coverity defects.