melexis / warnings-plugin

Command-line tool for marking builds with too many warnings as failed. A command-line alternative for https://github.com/jenkinsci/warnings-plugin. Useable with plugin-less CI systems like Gitlab-CI and even Travis-CI
Apache License 2.0
7 stars 2 forks source link

Code quality report generation issue #131

Closed lit-af closed 5 months ago

lit-af commented 5 months ago

Hi,

I'm wondering if it's possible to generate a code quality json report for GitLab CI from a doxygen log file ex: DoxygenWarningLog.txt

I tried the following with out success:

mlx-warnings --config .\mlx-warnings-config.json .\build\DoxygenWarningLog.txt --code-quality doxygen_quality.json

with the following content in mlx-warnings-config.json

{
    "doxygen": {
        "enabled": true,
        "min": 0,
        "max": 0
    },
    "sphinx": {
        "enabled": false
    },
    "junit": {
        "enabled": false
    },
    "xmlrunner": {
        "enabled": false
    },
    "coverity": {
        "enabled": false
    },
    "robot": {
        "enabled": false
    }
}

The output of that command give me:

Config parsing for doxygen completed
8 doxygen warnings found
Number of warnings (8) is higher than the maximum limit (0). Returning error code 8.

but there's no code_quality.json file generated.

JasperCraeghs commented 5 months ago

TL;DR: mlx-warnings is a little special and expects all of its keyword arguments first, followed by the positional arguments: mlx-warnings --config .\mlx-warnings-config.json --code-quality doxygen_quality.json .\build\DoxygenWarningLog.txt

usage: mlx-warnings [-h] [--coverity] [-d] [-j] [-r] [-s] [-x] [--name NAME] [-m MAXWARNINGS]
                    [--minwarnings MINWARNINGS] [--exact-warnings EXACT_WARNINGS]
                    [--config CONFIGFILE] [--include-sphinx-deprecation] [-o OUTPUT]
                    [-C CODE_QUALITY] [-v] [--command] [--ignore-retval] [--version]
                    logfile [logfile ...] ...

The last ... is the result of parser.add_argument('flags', nargs=argparse.REMAINDER, help='Possible not-used flags from above are considered as command flags'). Your trailing --code-quality <<file>> is gobbled up by flags, which ends up not getting used because --command was not used. Instead of ignoring it, a warning should be logged when flags is not empty and unused.

Thanks for reporting the issue!

Letme commented 5 months ago

Maybe a side note, what if we would add the code-quality field in config json file as well - then there would not be a case where we would have to be careful about the code-quality flags placement (or ignore-retval, include-sphinx-deprecation, name, etc?). Probably this is then more of a feature request if we decide to go this way...

Letme commented 5 months ago

I have made a release with this bugfix 5.1.0. I hope it solved it.

lit-af commented 5 months ago

Thank you for the quick reply!