Page MenuHomePhabricator

Have mediawiki-codesniffer linting on GWToolset
Closed, ResolvedPublic

Event Timeline

JeanFred raised the priority of this task from to Low.
JeanFred updated the task description. (Show Details)
JeanFred added subscribers: Aklapper, Steinsplitter, JeanFred.

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. :)

Change 270095 had a related patch set uploaded (by Jean-Frédéric):
Add PHP linting with mediawiki-codesniffer

https://gerrit.wikimedia.org/r/270095

Change 270095 merged by jenkins-bot:
Add PHP linting with mediawiki-codesniffer

https://gerrit.wikimedia.org/r/270095

JeanFred claimed this task.

Since CodeSniffer is executed via Composer, no need to further configure Jenkins. Closing.