Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30427

Jenkins checkstyle plugin command line and phpcs command line don't return the same number of issues

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: checkstyle-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 1.628
      Checkstyle plugin 3.43
    • Similar Issues:

      Description

      Hello guys,
      i'm using since few days checkstyle plugin (last version : 3.43).
      The checkstyle's reports works great for my projects but when i launch phpcs with exactly the same command line w/o jenkins, i don't find the same number of issue and the severity are not the same at all.

      Here an exemple :

      Build.xml

      <target name="phpcs-ci"
                  unless="phpcs.done"
                  depends="prepare"
                  description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
              <exec executable="phpcs" taskname="phpcs">
                  <arg value="--report=checkstyle" />
                  <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
                  <arg value="--standard=${basedir}/build/phpcs.xml" />
                  <arg value="--extensions=php" />
                  <arg value="--severity=5" />
                  <arg path="${basedir}/php/application" />
                  <arg path="${basedir}/php/models" />
              </exec>
      

      I try also this way to be sure :

      <target name="phpcs-ci"
                  unless="phpcs.done"
                  depends="prepare"
                  description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
              <exec executable="phpcs" taskname="phpcs">
                  <arg line="${basedir}/php/application ${basedir}/php/models --report=checkstyle --report-checkstyle=${basedir}/build/logs/checkstyle.xml --standard=${basedir}/build/phpcs.xml -extensions=php --severity=5 />
              </exec>
      

      But under jenkins i have : 886 errors reporting (88 high, 798 normal, 0 low)
      and with directly the command line without jenkins, i have : A TOTAL OF 440 ERRORS AND 798 WARNINGS WERE FOUND IN 417 FILES

      I don't understand why there are such differences.
      Could you help me please ?

      Thank you.
      Best regards

        Attachments

          Activity

          Hide
          drulli Ulli Hafner added a comment -

          What does checkstyle report in the console log of your build? There should be a line with [CHECKSTYLE] Parsed x files with a total of y warnings.

          Show
          drulli Ulli Hafner added a comment - What does checkstyle report in the console log of your build? There should be a line with [CHECKSTYLE] Parsed x files with a total of y warnings.
          Hide
          phenix Em Phenix added a comment -

          Hello Ulli,
          I have only this in console log of my build :

          [CHECKSTYLE] Collecting checkstyle analysis files...
          [CHECKSTYLE] Finding all files that match the pattern build/logs/checkstyle.xml
          [CHECKSTYLE] Parsing 1 file in /var/lib/jenkins/jobs/library/workspace
          [CHECKSTYLE] Successfully parsed file /var/lib/jenkins/jobs/library/workspace/build/logs/checkstyle.xml with 886 unique warnings and 0 duplicates.
          
          Show
          phenix Em Phenix added a comment - Hello Ulli, I have only this in console log of my build : [CHECKSTYLE] Collecting checkstyle analysis files... [CHECKSTYLE] Finding all files that match the pattern build/logs/checkstyle.xml [CHECKSTYLE] Parsing 1 file in / var /lib/jenkins/jobs/library/workspace [CHECKSTYLE] Successfully parsed file / var /lib/jenkins/jobs/library/workspace/build/logs/checkstyle.xml with 886 unique warnings and 0 duplicates.
          Hide
          drulli Ulli Hafner added a comment - - edited

          You can check if the plugin misses some warnings by counting the number of <error> tags in your checkstyle.xml file:

          cat checkstyle.xml | grep error | wc
          

          If that number is 886 then the checkstyle.xml file is correctly parsed by my plug-in. Then the content is different when you invoke it on the command line. Or the command does not write the same warnings to disk as it reports in the message.

          Show
          drulli Ulli Hafner added a comment - - edited You can check if the plugin misses some warnings by counting the number of <error> tags in your checkstyle.xml file: cat checkstyle.xml | grep error | wc If that number is 886 then the checkstyle.xml file is correctly parsed by my plug-in. Then the content is different when you invoke it on the command line. Or the command does not write the same warnings to disk as it reports in the message.
          Hide
          phenix Em Phenix added a comment - - edited

          Thank you.

          cat /var/lib/jenkins/jobs/library/workspace/build/logs/checkstyle.xml | grep error | wc
          

          return right 886 10964 141483

          and
          the other xml generated by phpcs in command line :

          cat checkstyle-phpcs.xml | grep error | wc
          

          1238 16596 209067

          After verification, you're right, my bad, my source wasn't the same in both case.
          Now I have 886 errors in both cases.

          Thank you for your help ! Do you know, how i can change the severity classification of the plugin ? I would be able to change some issue to low priority.
          I try to use this in my standard xml file :

          <severity>3<severity>
          

          or

          <severity>0<severity>
          

          or

          <severity>info<severity>
          

          as @see here : http://checkstyle.sourceforge.net/property_types.html#severity

          but it doesn't work.

          Maybe do you prefer that i create a new request for that ?

          Thank a lot again !
          Have a great day !

          Show
          phenix Em Phenix added a comment - - edited Thank you. cat / var /lib/jenkins/jobs/library/workspace/build/logs/checkstyle.xml | grep error | wc return right 886 10964 141483 and the other xml generated by phpcs in command line : cat checkstyle-phpcs.xml | grep error | wc 1238 16596 209067 After verification, you're right, my bad, my source wasn't the same in both case. Now I have 886 errors in both cases. Thank you for your help ! Do you know, how i can change the severity classification of the plugin ? I would be able to change some issue to low priority. I try to use this in my standard xml file : <severity>3<severity> or <severity>0<severity> or <severity>info<severity> as @see here : http://checkstyle.sourceforge.net/property_types.html#severity but it doesn't work. Maybe do you prefer that i create a new request for that ? Thank a lot again ! Have a great day !
          Hide
          drulli Ulli Hafner added a comment -

          The plug-in mapping is fixed: https://github.com/jenkinsci/checkstyle-plugin/blob/master/src/main/java/hudson/plugins/checkstyle/parser/CheckStyleParser.java#L99

          You need to map the warnings before the result is parsed by the Jenkins plug-in.

          Show
          drulli Ulli Hafner added a comment - The plug-in mapping is fixed: https://github.com/jenkinsci/checkstyle-plugin/blob/master/src/main/java/hudson/plugins/checkstyle/parser/CheckStyleParser.java#L99 You need to map the warnings before the result is parsed by the Jenkins plug-in.

            People

            • Assignee:
              drulli Ulli Hafner
              Reporter:
              phenix Em Phenix
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: