Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Add PHP linting with mediawiki-codesniffer | mediawiki/extensions/GWToolset | master | +280 -240 |
Details
Related Objects
- Mentioned Here
- rMWa49a8e7f0969: phpcs: Disable failing sniffs in phpcs.xml
Event Timeline
First pass:
A TOTAL OF 113 ERRORS AND 118 WARNINGS WERE FOUND IN 33 FILES
PHPCBF CAN FIX 180 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
Way to go... :)
\o/
I would suggest doing something like rMWa49a8e7f0969: phpcs: Disable failing sniffs in phpcs.xml, so you can begin enforcing the ones that do pass, and slowly re-enable rules after fixing them, which will prevent accidental regressions in other patches. :)
The Math extension's composer.json has an example of how you can set up phpcbf to automatically fix errors, which saves a lot of time.
Thanks for chiming in :)
A pass of egrep '\s+\|\s+\|\s+\((.*)\)' old-report.txt | cut -d'(' -f2 | sort | uniq (could not quickly get phpcs to output report per error-type :þ) gives 19 distinct errors:
Generic.Files.EndFileNewline.NotFound) Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace) Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed) MediaWiki.Usage.DirUsage.FunctionFound) MediaWiki.WhiteSpace.SpaceAfterControlStructure.Incorrect) MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment) MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceAfterOpenParenthesis) MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis) MediaWiki.WhiteSpace.SpaceyParenthesis.SpaceBeforeOpeningParenthesis) PSR2.Classes.PropertyDeclaration.Underscore) PSR2.ControlStructures.ElseIfDeclaration.NotAllowed) PSR2.Methods.MethodDeclaration.AbstractAfterVisibility) PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter) PSR2.Namespaces.UseDeclaration.MultipleDeclarations) PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse) PSR2.Namespaces.UseDeclaration.SpaceAfterUse) Squiz.WhiteSpace.LanguageConstructSpacing.Incorrect) Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore) Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines)
After auto-fixing using --report=diff & patch, I end up with the following 6:
Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace) Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed) MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment) MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceAfterOpenParenthesis) MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis) PSR2.Classes.PropertyDeclaration.Underscore)
I’ll shove the rest in exclude as you suggest. :)
Patch-For-Review at https://gerrit.wikimedia.org/r/#/c/270095/ (Gerrit-bot in holiday or I’m doing something wrong? o_O)
Change 270095 had a related patch set uploaded (by Jean-Frédéric):
Add PHP linting with mediawiki-codesniffer
Since CodeSniffer is executed via Composer, no need to further configure Jenkins. Closing.