[JIRA] (JENKINS-56214) PHP CodeSniffer errors treated as warnings

2 views
Skip to first unread message

catalin.nicolescu@gmail.com (JIRA)

unread,
Feb 20, 2019, 5:28:02 AM2/20/19
to jenkinsc...@googlegroups.com
Cătălin Nicolescu created an issue
 
Jenkins / Bug JENKINS-56214
PHP CodeSniffer errors treated as warnings
Issue Type: Bug Bug
Assignee: Ulli Hafner
Attachments: phpcs.log.xml
Components: analysis-model, analysis-model-api-plugin, warnings-ng-plugin
Created: 2019-02-20 10:27
Environment: Jenkins ver. 2.150.3
Warnings Next Generation Plugin ver. 3.0.3
Priority: Major Major
Reporter: Cătălin Nicolescu

Given the following stage definition and the attached CodeSniffer output
I was expecting to have errors reported.
Instead I get warnings with severity HIGH

Changing the tool from phpCodeSniffer() to checkStyle() makes no difference

stage('CodeSniffer') {
  steps {
    sh '''
       vendor/bin/phpcs \\
       --ignore=*/vendor/*,*/node_modules/* \\
       --extensions=php \\
       --standard=phpcs.xml \\
       --bootstrap=vendor/autoload.php \\
       --report=checkstyle \\
       --report-file=phpcs.log.xml \\
       Modules/
    '''
  }

  post {
    always {
      recordIssues enabledForFailure: true,
      aggregatingResults: true,
      tools: [phpCodeSniffer(pattern: 'phpcs.log.xml', reportEncoding: 'UTF-8')]
    }
  }
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ullrich.hafner@gmail.com (JIRA)

unread,
Feb 20, 2019, 2:44:02 PM2/20/19
to jenkinsc...@googlegroups.com
Ulli Hafner assigned an issue to Unassigned
 

Yes, the parser has been contributed before I added errors to the API. Interested in providing a PR?

Change By: Ulli Hafner
Component/s: analysis-model-api-plugin
Component/s: warnings-ng-plugin
Priority: Major Minor
Labels: help-wanted newbie-friendly
Assignee: Ulli Hafner

catalin.nicolescu@gmail.com (JIRA)

unread,
Feb 21, 2019, 2:51:01 AM2/21/19
to jenkinsc...@googlegroups.com
Cătălin Nicolescu commented on Bug JENKINS-56214
 
Re: PHP CodeSniffer errors treated as warnings

Yes, if you could point me to where the culprit code is

ullrich.hafner@gmail.com (JIRA)

unread,
Feb 21, 2019, 9:33:01 AM2/21/19
to jenkinsc...@googlegroups.com

The class CheckStyleParser is responsible. Currently it maps errors to severity high.

You can check if the Severity class already provides the correct mapping.

roithmeier.tanja@gmail.com (JIRA)

unread,
Mar 28, 2019, 2:19:02 PM3/28/19
to jenkinsc...@googlegroups.com

roithmeier.tanja@gmail.com (JIRA)

unread,
Mar 31, 2019, 11:07:02 AM3/31/19
to jenkinsc...@googlegroups.com
Tanja Roithmeier started work on Bug JENKINS-56214
 
Change By: Tanja Roithmeier
Status: Open In Progress

roithmeier.tanja@gmail.com (JIRA)

unread,
Mar 31, 2019, 12:53:03 PM3/31/19
to jenkinsc...@googlegroups.com
Tanja Roithmeier commented on Bug JENKINS-56214
 
Re: PHP CodeSniffer errors treated as warnings

I've already investigated the source code and as Ulli Hafner said, changing the mapping at the class  CheckStyleParser 
would solve the problem. 

But are these changes not a mismatch with the specification of the plugin?

According to the plugin documentation the severity is defined as following:

  • Error: Indicates an error that typically fails the build
  • Warning (High, Normal, Low): Indicates a warning of the given priority. Mapping to the priorities is up to the individual parsers.

(cf.: https://github.com/jenkinsci/warnings-ng-plugin/blob/master/doc/Documentation.md)

None of the errors in the file phpcs.log.xml leads to a failed build. Probably no error provided by a plugin for static code analysis will fail the build, so maybe the severity warning-high is more suitable than an error. 

ullrich.hafner@gmail.com (JIRA)

unread,
Mar 31, 2019, 3:09:03 PM3/31/19
to jenkinsc...@googlegroups.com
Ulli Hafner edited a comment on Bug JENKINS-56214
Maybe I need to improve the documentation. The plugin now creates issues of severity
* *Error*
* *Warning* (High, Normal, Low)
*
Previous versions of the plugin only used *Warning* (High, Normal, Low). An additional severity *Error* was requested by several users. How these severities actually change the status of the build is not predefined in the plugin, this needs to be done by setting quality gates. A recommendation is to fail the build on errors and set the build to unstable on warnings. But this is totally up to the project.  

So I think it is ok, to map errors in the Checkstyle file to *Error* severity. You can use method `Severity.guessFromString` to map the severity.

ullrich.hafner@gmail.com (JIRA)

unread,
Mar 31, 2019, 3:09:03 PM3/31/19
to jenkinsc...@googlegroups.com

ullrich.hafner@gmail.com (JIRA)

unread,
Mar 31, 2019, 3:09:03 PM3/31/19
to jenkinsc...@googlegroups.com

Maybe I need to improve the documentation. The plugin now creates issues of severity

  • Error
  • Warning (High, Normal, Low)
    Previous versions of the plugin only used Warning (High, Normal, Low). An additional severity Error was requested by several users. How these severities actually change the status of the build is not predefined in the plugin, this needs to be done by setting quality gates. A recommendation is to fail the build on errors and set the build to unstable on warnings. But this is totally up to the project.

So I think it is ok, to map errors in the Checkstyle file to Error severity. You can use method `Severity.guessFromString` to map the severity.

roithmeier.tanja@gmail.com (JIRA)

unread,
Apr 2, 2019, 11:58:03 AM4/2/19
to jenkinsc...@googlegroups.com

ullrich.hafner@gmail.com (JIRA)

unread,
Apr 2, 2019, 3:15:02 PM4/2/19
to jenkinsc...@googlegroups.com
Change By: Ulli Hafner
Status: In Review Fixed but Unreleased
Resolution: Fixed

ullrich.hafner@gmail.com (JIRA)

unread,
Apr 2, 2019, 3:17:02 PM4/2/19
to jenkinsc...@googlegroups.com

ullrich.hafner@gmail.com (JIRA)

unread,
May 8, 2019, 6:20:12 PM5/8/19
to jenkinsc...@googlegroups.com
Change By: Ulli Hafner
Status: Fixed but Unreleased Resolved
Released As: 5.0.0 (analysis-model and warnings-ng)
Reply all
Reply to author
Forward
0 new messages