-
Improvement
-
Resolution: Fixed
-
Minor
-
ver 2.46.2
-
Powered by SuggestiMate
In the PyLint Warnings report, the Categories tab provides only the pylint msg_id (e.g. "E0012"), but not the summary string (or symbolic name in pylint speak, e.g. "bad-option-value"). If this summary string was included, it would be much easier to interpret.
[JENKINS-44915] Pylint Warnings: Details table could provide summary string with category
Apologies, I hadn't realized I wasn't getting the default output format. I see now that we run pylint during the build stage from a bash shell using the '--output-format=parseable' option. Consequently, in the output the msg_id is immediately followed by the symbolic name (in parenthesis) as shown below:
plotting_root.py:596: [R0913(too-many-arguments), PlotScatter2DLive.update] Too many arguments (6/5)
plotting_root.py:614: [E0602(undefined-variable), PlotScatter2DLive.update] Undefined variable 'title'
plotting_root.py:637: [C0103(invalid-name), PlotScatter2DLive.update] Invalid variable name "xa"
See also:
https://pylint.readthedocs.io/en/latest/user_guide/output.html
and the MSGS dictionaries in these files:
https://github.com/PyCQA/pylint/tree/2e820672609c489458dc2cf39d811e8c10255fe4/pylint/checkers
I see. Seems that the category actually is the type of the warning.
Is there an easy way to get an ID to "human readable name" mapping into a file? I never programmed python, maybe one of the pylint contributors can help here?
What I also see: there is some additional information available for each warning type. This information can be shown as tooltip in the various warning dialogs. Again, it would be helpful if I can get a file with a mapping ID to description.
'W0301': ('Unnecessary semicolon', # was W0106 'unnecessary-semicolon', 'Used when a statement is ended by a semi-colon (";"), which \ isn\'t necessary (that\'s python, not C ;).'),
Interested in helping to get these two mapping files, then I can add these information to the warnings plugin?
We actually need something like
W0301= Unnecessary semicolon
W0301=Used when a statement is ended by a semi-colon (";"), which \ isn\'t necessary (that\'s python, not C ;).
(Or something similar in JSON or YAML, etc.)
Hi,
I would also like to have more readable warnings summaries from Pylint in our Jenkins setup.
There are two ways to get the message code details from pylint itself:
pylint --list-msgs will list all defined Pylint messages with codes, symbolic names and full-text descriptions in a format that looks like this:
:blacklisted-name (C0102): *Black listed name "%s"* Used when the name is listed in the black list (unauthorized names). :invalid-name (C0103): *Invalid %s name "%s"%s* Used when the name doesn't match the regular expression associated to its type (constant, variable, class...). ...
Another way is to query a specific message code, like so:
$ pylint --help-msg E1101 No config file found, using default configuration :no-member (E1101): *%s %r has no %r member%s* Used when a variable is accessed for an unexistent member. This message belongs to the typecheck checker.
As the original reporter notes, though, the symbolic names are already present in the output that the Warnings plugins parses. Just using the symbolic name nomember is a big readability improvement over using E1101.
This information could be easily shown in the warnings plugin (at least as part of the new refactoring for pipelines). Interested in helping with a pull request? Basically there needs to be implemented something as this is done for CheckStyle, PMD or FindBugs:
drulli, mbrekkevold, generatz If I'm not mistaken, this is now solved with the warnings-ng plugin. Using the right --msg-template, we can now properly make the warnings plugin use the message name for each issue:
Here I used the latest version of warnings-ng (3.0.3) and the --msg-template value given to the pylint command is: "{path}:{line}: [\{msg_id}(\{symbol}), \{obj}] {msg}" ( without the slashes. I just can't remove them in Jira...)
Though, the output format documented in the UI should be updated to better align with what format the plugin really support.
That means the text in https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/java/io/jenkins/plugins/analysis/warnings/PyLint.java#L50 is wrong?
I have the latest warnings-ng (3.0.3), and I cannot confirm this at all. The suggested msg-template:
{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
is what we already had in our reports, and we are still only seeing opaque codes in the report:
We always had something that looked like this in the report file fed to warnings-ng:
python/nav/tableformat.py:22: [C0111(missing-docstring), SimpleTableFormatter] Missing class docstring
python/nav/tableformat.py:35: [C0111(missing-docstring), SimpleTableFormatter.get_formatted_table] Missing method docstring
python/nav/tableformat.py:44: [R0201(no-self-use), SimpleTableFormatter._format_row] Method could be a function
Seems that this issue actually is about two different things:
- Replace number in category with text (resolved now)
- Provide descriptions of category (still open) - (btw: actually category is the wrong property, it should be type).
So I suggest: if your are still interested in 2, we should create a new issue that describes that part. If someone of you (i.e. a pylint user) can provide me with a file that contains a mapping type -> description I will add the code to the plugin The file could be a properties file or JSON.
drulli I'm not too sure what you mean by description/type... Do you have an example for let's say Java or PMD or other tools that integrates properly the type, category, message, severity, description, etc? I might be able to help you to see if pylint in analysis-model uses the right properties.
Or actually, I could simply look at the unit tests in the repo.
Which version of analysis-model-api do you have installed?
Hi drulli, I have version 2.1.2 of that plugin.
- Replace number in category with text (resolved now)
- Provide descriptions of category (still open) - (btw: actually category is the wrong property, it should be type).
On my end, I cannot confirm that #1 is resolved (which is what I was most hoping for). #2 is not that important to me, as there is a detailed message attached to each reported code line anyway. However, the output of pylint --list-msgs is easily converted to JSON. See attached file.
I'm not sure I understand your distinction between "type" and "category", with regards to warnings-ng, but pylint establishes 5 different message types:
- (C) convention, for programming standard violation
- (R) refactor, for bad code smell
- (W) warning, for python specific problems
- (E) error, for much probably bugs in the code
- (F) fatal, if an error occurred which prevented pylint from doing
Each message emitted has one of these types and a four digit integer code to identify it.
Forgot to actually attach the file, here it is: pylint-messages.json
category and type are typically a 1:n relationship. The type contains the name (or ID) of the rule that has been executed. The category groups a set of n rules. Examples from Java:
- https://github.com/pmd/pmd/wiki/Rule-Categories
- http://checkstyle.sourceforge.net/checks.html (Navigation menu shows categories, Rules are types)
mbrekkevold, jeanchristophemorinperso: Is the result format the same if your projects if you compare it line by line?
I think I will put your result in a test to see what is different...
category and type are typically a 1:n relationship. The type contains the name (or ID) of the rule that has been executed. The category groups a set of n rules.
So the current categories (C0111, R0201, etc) need to be switched to types, and the real categories needs to be categories. (C, R, W, E, F).
So we still need to open a new issue for this one, and I'm willing to work on it.
is what we already had in our reports, and we are still only seeing opaque codes in the report:
mbrekkevold umm, interesting. I'll triple check on a clean jenkins instance as soon as I can. To create the screenshot I did, I used the exact same msg-template as you. On your side, do you think you can spin-up a fresh new instance (let's say with docker or whatever the way you prefer) and see if it changes something? (Here I'm implying you are looking at a production instance, but I might me wrong and maybe you already did it).
Is the result format the same if your projects if you compare it line by line?
drulli I guess you mean our pylint output result? If so yes it's the same I have. And when I use the regex to parse mbrekkevold pylint output, I get the proper groups (see https://regex101.com/r/tsspv2/1)
So the current categories (C0111, R0201, etc) need to be switched to types, and the real categories needs to be categories. (C, R, W, E, F).
So we still need to open a new issue for this one, and I'm willing to work on it.
I think it would be sufficient to use setType rather than setCategory in the current implementation. The categories C, R, W, E, F do not provide any additional information: they are already used as severity. I think a PR is sufficient, no need to create a new issue...
mbrekkevold Thanks for adding the messages, they are now part of the plugin: https://github.com/jenkinsci/warnings-ng-plugin/commit/e0915fbe87e032ce031be474650314a1ec37cdda
We need to update these messages from time to time.
drulli I also solved my issue: Unbeknownst to me, there was a new way of invoking warnings-ng from pipeline script. I was using a step with a WarningsPublisher. However, when I switched to using recordIssues with the pyLint tool, suddenly my warnings report was completely reinvigorated with a new look, with proper symbolic violation names and graphs, and lots of bells and whistles It looks nothing like the screenshot I provided previously.
Ah, seems I missed the screenshot. Those results are from the old warnings plugin! Good to see that now everything is working...
Do you have a link to a file that contains this mapping? Or where can I get this information from?