Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
enh(build): improve coding style checks for master (#7827)
Browse files Browse the repository at this point in the history
* enh(build): reporting codingstyle violations on github

* fix(build): update syntax of ViolationsToGitHub in Jenkinsfile.

* enh(build): modifying build file

* enh(build): modifying ruleset file
  • Loading branch information
sc979 authored and kduret committed Sep 6, 2019
1 parent a6d0263 commit 16a1954
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
20 changes: 20 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,33 @@ try {
cloverReportDir: '.',
cloverReportFileName: 'coverage.xml'
])

if (env.CHANGE_ID) { // pull request to comment with coding style issues
ViolationsToGitHub([
repositoryName: 'centreon',
pullRequestId: env.CHANGE_ID,

createSingleFileComments: true,
commentOnlyChangedContent: true,
commentOnlyChangedFiles: true,
keepOldComments: false,

commentTemplate: "**{{violation.severity}}**: {{violation.message}}",

violationConfigs: [
[parser: 'CHECKSTYLE', pattern: '.*/codestyle.xml$', reporter: 'Checkstyle']
]
])
}

step([
$class: 'hudson.plugins.checkstyle.CheckStylePublisher',
pattern: 'codestyle.xml',
usePreviousBuildAsReference: true,
useDeltaValues: true,
failedNewAll: '0'
])

if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
withSonarQubeEnv('SonarQube') {
sh "./centreon-build/jobs/web/${serie}/mon-web-analysis.sh"
Expand Down
24 changes: 7 additions & 17 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<include name="**/**/**/*Test.php" />
</fileset>
<fileset dir="src">
<include name="**/*.php"/>
<include name="**/Tests/*Test.php" />
<include name="**/Tests/**/*Test.php" />
</fileset>
Expand All @@ -34,23 +35,12 @@
</target>

<target name="codestyle" depends="prepare">
<phpcodesniffer standard="codingstyle.xml">
<formatter type="checkstyle" outfile="${builddir}/checkstyle.xml"/>
<fileset dir="features">
<include name="**/*.php"/>
</fileset>
<fileset dir="tests">
<include name="**/*.php"/>
</fileset>
<fileset dir="www">
<include name="**/*.php"/>
<exclude name="lib/HTML/QuickForm.php"/>
<exclude name="lib/HTML/QuickForm/**/*.php"/>
</fileset>
<fileset dir="src">
<include name="**/*.php"/>
</fileset>
</phpcodesniffer>
<exec executable="./vendor/bin/phpcs" dir="./">
<arg value="--standard=ruleset.xml" />
<arg value="--report=checkstyle" />
<arg value="--report-file=${builddir}/checkstyle.xml" />
<arg value="./" />
</exec>
</target>

<target name="main"></target>
Expand Down
23 changes: 23 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<ruleset name="Centreon Standard">
<description>Custom rules defined by Centreon</description>

<exclude-pattern>*/centreon-build/*</exclude-pattern>
<exclude-pattern>*/doc/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/lib/HTML/QuickForm.php</exclude-pattern>
<exclude-pattern>*/lib/HTML/QuickForm/**/*.php</exclude-pattern>
<exclude-pattern>*\.(?!(php$))</exclude-pattern>

<rule ref="PSR2"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>www</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>features</exclude-pattern>
<exclude-pattern>tests</exclude-pattern>
<exclude-pattern>www</exclude-pattern>
</rule>
</ruleset>

0 comments on commit 16a1954

Please sign in to comment.