The Warnings PyLint parser is not properly parsing errors. This project is run on a linux slave.

      The project ran with the console output stating there were 0 warnings:

      [python-lint3] $ /bin/bash /tmp/hudson5642505433447392932.sh
      ~> Starting lint3 test - 08/22/14 17:25:26
      ~> Lint3 test complete - 08/22/14 17:27:42
      [WARNINGS] Parsing warnings in files '**/lint3.out' with parser PyLint
      [WARNINGS] Finding all files that match the pattern **/lint3.out
      [WARNINGS] Parsing 1 files in /home/jenkins/workspace/python-lint3
      [WARNINGS] Successfully parsed file /home/jenkins/workspace/python-lint3/lint3.out of module  with 0 warnings.
      Archiving artifacts
      Recording fingerprints
      Finished: SUCCESS
      

      The actual output generated by the pylint command contained in lint3.out shows there are multiple errors:

      lint3 create: /home/jenkins/workspace/python-lint3/.tox/lint3
      lint3 installdeps: -r/home/jenkins/workspace/python-lint3/requirements/requirements.txt, -r/home/jenkins/workspace/python-lint3/tests/test-requirements.txt, pylint
      lint3 develop-inst: /home/jenkins/workspace/python-lint3
      lint3 runtests: commands[0] | pylint ./phoenix
      lint3 runtests: commands[1] | pylint ./tests
      ************* Module tests.api.utils.config
      E: 26,20: Instance of 'PhoenixConfig' has no 'get' member (no-member)
      E: 36,20: Instance of 'authConfig' has no 'get' member (no-member)
      E: 41,20: Instance of 'authConfig' has no 'get' member (no-member)
      E: 46,20: Instance of 'authConfig' has no 'get_raw' member (no-member)
      E: 51,20: Instance of 'authConfig' has no 'get' member (no-member)
      ************* Module tests.api.utils.base
      E: 53,17: Instance of 'TestBase' has no 'assertFalse' member (no-member)
      ************* Module tests.api.utils.client
      E: 35,13: Instance of 'AuthClient' has no 'default_headers' member (no-member)
      E: 36,13: Instance of 'AuthClient' has no 'default_headers' member (no-member)
      E: 64,20: Instance of 'AuthClient' has no 'request' member (no-member)
      E: 81,13: Instance of 'BasePhoenixClient' has no 'default_headers' member (no-member)
      E: 82,13: Instance of 'BasePhoenixClient' has no 'default_headers' member (no-member)
      E: 83,13: Instance of 'BasePhoenixClient' has no 'default_headers' member (no-member)
      E: 84,53: Instance of 'BasePhoenixClient' has no 'serialize_format' member (no-member)
      E: 85,13: Instance of 'BasePhoenixClient' has no 'default_headers' member (no-member)
      E: 86,47: Instance of 'BasePhoenixClient' has no 'deserialize_format' member (no-member)
      E:109,24: Instance of 'BasePhoenixClient' has no 'request' member (no-member)
      E:112,24: Instance of 'BasePhoenixClient' has no 'request' member (no-member)
      ************* Module tests.api.backup.test_backups
      E: 48,13: Instance of 'TestBackups' has no 'assertEqual' member (no-member)
      E: 66,13: Instance of 'TestBackups' has no 'assertEqual' member (no-member)
      E: 84,13: Instance of 'TestBackups' has no 'assertEqual' member (no-member)
      ERROR: InvocationError: '/home/jenkins/workspace/python-lint3/.tox/lint3/bin/pylint ./tests'
      ___________________________________ summary ____________________________________
      ERROR:   lint3: commands failed
      

          [JENKINS-24463] PyLint parse missing errors

          Ulli Hafner added a comment - - edited

          I see. One problem with the new format: the path is missing in the parsed line. If the section header should be scanned (e.g., ************* Module tests.api.utils.client) then the single line parser cannot be used anymore

          I think there are two options:

          1. Create a new parser for the new file format (interested in providing a pull request?)
          2. Don't change the parser and add a note so that users will pick the correct command line option. And ask the maintainer of pylint why this option has been deprecated.

          What do you think?

          Ulli Hafner added a comment - - edited I see. One problem with the new format: the path is missing in the parsed line. If the section header should be scanned (e.g., ************* Module tests.api.utils.client) then the single line parser cannot be used anymore I think there are two options: Create a new parser for the new file format (interested in providing a pull request?) Don't change the parser and add a note so that users will pick the correct command line option. And ask the maintainer of pylint why this option has been deprecated. What do you think?

          I just hit this same problem with one of my projects. Something else I discovered that is worth considering is that it appears that when you call pylint code directly from other scripts, the --msg-template parameter seems to be ignored. I'm not sure if this is a defect in the library itself or maybe my use of the library atm. If it is a defect with the pylint code I'll report a bug with them, but in the meantime if you choose to document the expected output format as part of your parser plugin rather than create a new parser (which does seem preferable), you may want to mention this tidbit.

          Kevin Phillips added a comment - I just hit this same problem with one of my projects. Something else I discovered that is worth considering is that it appears that when you call pylint code directly from other scripts, the --msg-template parameter seems to be ignored. I'm not sure if this is a defect in the library itself or maybe my use of the library atm. If it is a defect with the pylint code I'll report a bug with them, but in the meantime if you choose to document the expected output format as part of your parser plugin rather than create a new parser (which does seem preferable), you may want to mention this tidbit.

          Chris Powell added a comment -

          I just ended up requiring my various projects to include the following snippet in there pylintrc. It seems to be working well.

          [REPORTS]
          output-format=text
          reports=no
          msg-template=

          {path}

          :

          {line}

          : [

          {msg_id}

          (

          {symbol}

          ),

          {obj}

          ]

          {msg}

          Chris Powell added a comment - I just ended up requiring my various projects to include the following snippet in there pylintrc. It seems to be working well. [REPORTS] output-format=text reports=no msg-template= {path} : {line} : [ {msg_id} ( {symbol} ), {obj} ] {msg}

          Another possible improvement here might be to do some basic content validation within your parser, and if it seems like the content of the log file being parsed doesn't meet the format specification you expect you could provide some kind of helpful feedback to the user, something to the effect of "pylint output not in the expected format. See online documentation for details of the expected format."

          I know this would have been greatly helpful to me since I just spent the last several hours messing with my Python code and Jenkins plugins trying to get this to work and at no point did any of these tools indicate a potential configuration problem.

          Kevin Phillips added a comment - Another possible improvement here might be to do some basic content validation within your parser, and if it seems like the content of the log file being parsed doesn't meet the format specification you expect you could provide some kind of helpful feedback to the user, something to the effect of "pylint output not in the expected format. See online documentation for details of the expected format." I know this would have been greatly helpful to me since I just spent the last several hours messing with my Python code and Jenkins plugins trying to get this to work and at no point did any of these tools indicate a potential configuration problem.

          For reference, just in case anyone comes across this defect who may be trying to integrate output with this plugin from "epylint", called from within another python script, here's a trick I found to get it working.

          As mentioned on the pylint website, you would typically make such a call using some code that looks something like this:

          from pylint import epylint as lint
          lint.py_run("MyFile.py")
          

          However, for some reason this method will ignore some of the settings found in the pylintrc file as well as command line parameters provided to the py_run() method. This includes the 'msg-template' property mentioned above. After looking into the implementation of the py_run() method I noticed that the script essentially offloads it's work to an external console tool which defaults to "epylint" (epylint.bat on Windows). It seems that this command line tool is what is to blame for this odd behavior... but I won't get into the details of that here.

          Suffice it to say, typically users will use the "pylint" (pylint.bat on Windows) on the shell rather than this epylint tool. Information on the differences between these two tools is sparse at best, but I've discovered that if you use the same parameters when calling the more conventional 'pylint' tool everything works as expected. Luckily, the run_py() method allows you to overload the command line tool used when offloading the work, so we can easily redirect it to this more conventional script using code something like this:

          from pylint import epylint as lint
          lint.py_run("MyFile.py", script="pylint")
          

          Making this minor adjustment, and ensuring your associated pylintrc file has the 'msg-template' declaration Chris mentions above, should result in a workable solution for this plugin.

          Kevin Phillips added a comment - For reference, just in case anyone comes across this defect who may be trying to integrate output with this plugin from "epylint", called from within another python script, here's a trick I found to get it working. As mentioned on the pylint website , you would typically make such a call using some code that looks something like this: from pylint import epylint as lint lint.py_run( "MyFile.py" ) However, for some reason this method will ignore some of the settings found in the pylintrc file as well as command line parameters provided to the py_run() method. This includes the 'msg-template' property mentioned above. After looking into the implementation of the py_run() method I noticed that the script essentially offloads it's work to an external console tool which defaults to "epylint" (epylint.bat on Windows). It seems that this command line tool is what is to blame for this odd behavior... but I won't get into the details of that here. Suffice it to say, typically users will use the "pylint" (pylint.bat on Windows) on the shell rather than this epylint tool. Information on the differences between these two tools is sparse at best, but I've discovered that if you use the same parameters when calling the more conventional 'pylint' tool everything works as expected. Luckily, the run_py() method allows you to overload the command line tool used when offloading the work, so we can easily redirect it to this more conventional script using code something like this: from pylint import epylint as lint lint.py_run( "MyFile.py" , script= "pylint" ) Making this minor adjustment, and ensuring your associated pylintrc file has the 'msg-template' declaration Chris mentions above, should result in a workable solution for this plugin.

          Ulli Hafner added a comment -

          Thanks for the detailed feedback. Currently there is no possibility to pre-validate an input file. I think this could be added as optional step for each parser and if the validation fails then a corresponding warning could be shown.

          Ulli Hafner added a comment - Thanks for the detailed feedback. Currently there is no possibility to pre-validate an input file. I think this could be added as optional step for each parser and if the validation fails then a corresponding warning could be shown.

          Łukasz Dudek added a comment - - edited

          Hello!

          I've also stumbled across the same issue. I've tried using the configuration proposed by powellchristoph, but to no avail.

          I'm using Jenkins 2.91 and Warnings Plugin 4.64 and PyLint 1.7.4.

          My .pylintrc (or at least its interesting part) looks as follows:

          msg-template={path}: {line}: [{msg_id} ({symbol}), {obj}] {msg}
          output-format=text
          reports=no
          score=yes
          

          The SCA-related pipeline fragment:

          withPythonEnv("python3") {
              pysh(script: "python -m pip install -r requirements.txt")
              pysh(script: "python -m pylint ${env.WORKSPACE} > pylint_status.log", returnStatus: true)
          }
          warnings(canResolveRelativePaths: false, canRunOnFailed: true, failedNewAll: '5', failedTotalAll: '500',
              failedTotalHigh: '5', failedTotalLow: '300', failedTotalNormal: '200', healthy: '0',
              parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint_status.log']], unHealthy: '500',
              unstableNewAll: '0', unstableTotalAll: '100', unstableTotalHigh: '0', unstableTotalLow: '80',
              unstableTotalNormal: '20', usePreviousBuildAsReference: true)
          

          And while I get a lot of warnings & errors from PyLint, Warnings still says that there're no errors and no duplicates (MY_WORKSPACE_PATH is, of course, my edit):

          [WARNINGS] Parsing warnings in files 'pylint_status.log' with parser PyLint
          [WARNINGS] Searching for all files in *MY_WORKSPACE_PATH* that match the pattern pylint_status.log
          [WARNINGS] Parsing 1 file in *MY_WORKSPACE_PATH*
          [WARNINGS] Successfully parsed file *MY_WORKSPACE_PATH*/pylint_status.log with 0 unique warnings and 0 duplicates.
          Skipping warnings blame since pipelines do not have an SCM link.%n
          [WARNINGS] Computing warning deltas based on reference build #1 Score: 6.94/10.0
          [WARNINGS] Plug-in Result: Success - no threshold has been exceeded
          

          The warnings graph shows a steady 0 warnings.

          My questions are:

          1. What is the proper message format for PyLint to work with Warnings?
          2. Can it be documented somewhere?
          3. Do I have to disable PyLint's report for it to work?

          Łukasz Dudek added a comment - - edited Hello! I've also stumbled across the same issue. I've tried using the configuration proposed by powellchristoph , but to no avail. I'm using Jenkins 2.91 and Warnings Plugin 4.64 and PyLint 1.7.4. My .pylintrc (or at least its interesting part) looks as follows: msg-template={path}: {line}: [{msg_id} ({symbol}), {obj}] {msg} output-format=text reports=no score=yes The SCA-related pipeline fragment: withPythonEnv( "python3" ) { pysh(script: "python -m pip install -r requirements.txt" ) pysh(script: "python -m pylint ${env.WORKSPACE} > pylint_status.log" , returnStatus: true ) } warnings(canResolveRelativePaths: false , canRunOnFailed: true , failedNewAll: '5' , failedTotalAll: '500' , failedTotalHigh: '5' , failedTotalLow: '300' , failedTotalNormal: '200' , healthy: '0' , parserConfigurations: [[parserName: 'PyLint' , pattern: 'pylint_status.log' ]], unHealthy: '500' , unstableNewAll: '0' , unstableTotalAll: '100' , unstableTotalHigh: '0' , unstableTotalLow: '80' , unstableTotalNormal: '20' , usePreviousBuildAsReference: true ) And while I get a lot of warnings & errors from PyLint, Warnings still says that there're no errors and no duplicates ( MY_WORKSPACE_PATH is, of course, my edit): [WARNINGS] Parsing warnings in files 'pylint_status.log' with parser PyLint [WARNINGS] Searching for all files in *MY_WORKSPACE_PATH* that match the pattern pylint_status.log [WARNINGS] Parsing 1 file in *MY_WORKSPACE_PATH* [WARNINGS] Successfully parsed file *MY_WORKSPACE_PATH*/pylint_status.log with 0 unique warnings and 0 duplicates. Skipping warnings blame since pipelines do not have an SCM link.%n [WARNINGS] Computing warning deltas based on reference build #1 Score: 6.94/10.0 [WARNINGS] Plug-in Result: Success - no threshold has been exceeded The warnings graph shows a steady 0 warnings. My questions are: What is the proper message format for PyLint to work with Warnings? Can it be documented somewhere? Do I have to disable PyLint's report for it to work?

          Ulli Hafner added a comment -

          ljbd: This is the supported format (from the test case): https://github.com/jenkinsci/analysis-model/blob/master/src/test/resources/edu/hm/hafner/analysis/parser/pyLint.txt

          This issue here is about errors not detected, warnings seem to get parsed quite well. 

          Ulli Hafner added a comment - ljbd : This is the supported format (from the test case): https://github.com/jenkinsci/analysis-model/blob/master/src/test/resources/edu/hm/hafner/analysis/parser/pyLint.txt This issue here is about errors not detected, warnings seem to get parsed quite well. 

          based on drulli's reference of ljbd above, here is the message format, pylint command, Pipeline step and console output that worked for Jenkins to report pylint messages through the Warnings plugin:

          ./pylintrc contains:

           msg-template={path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})

          Command:

          pylint --rcfile=./pylintrc CODE > pylint.log

          Pipeline:

          step([$class: 'WarningsPublisher',
            parserConfigurations: [[
              parserName: 'PyLint', pattern: '**/pylint*.log'
            ]],
            unstableTotalAll: '0', 
            usePreviousBuildAsReference: true
          ])

          Console:

          [WARNINGS] Parsing warnings in files '**/pylint-*.log' with parser PyLint
          [WARNINGS] Searching for all files in WORKSPACE that match the pattern **/pylint-*.log
          [WARNINGS] Parsing 1 file in WORKSPACE
          [WARNINGS] Successfully parsed file WORKSPACE/pylint-py36.log with 2 unique warnings and 0 duplicates.
          

          Scott Schreckengaust added a comment - based on drulli 's reference of ljbd  above, here is the message format, pylint command, Pipeline step and console output that worked for Jenkins to report pylint messages through the Warnings plugin: ./pylintrc contains:  msg-template={path}:{line}: [{msg_id}, {obj}] {msg} ({symbol}) Command: pylint --rcfile=./pylintrc CODE > pylint.log Pipeline: step([$class: 'WarningsPublisher', parserConfigurations: [[ parserName: 'PyLint', pattern: '**/pylint*.log' ]], unstableTotalAll: '0', usePreviousBuildAsReference: true ]) Console: [WARNINGS] Parsing warnings in files '**/pylint-*.log' with parser PyLint [WARNINGS] Searching for all files in WORKSPACE that match the pattern **/pylint-*.log [WARNINGS] Parsing 1 file in WORKSPACE [WARNINGS] Successfully parsed file WORKSPACE/pylint-py36.log with 2 unique warnings and 0 duplicates.

          Ulli Hafner added a comment -

          I updated the help in the PyLint tool description.

          Ulli Hafner added a comment - I updated the help in the PyLint tool description .

            Unassigned Unassigned
            powellchristoph Chris Powell
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: