Wikimedia

Re-enable some codesniffer sniffs disabled in MediaWiki's MobileFrontend extension

PHPCodeSniffer helps us stick to same coding standards across MediaWiki and its extensions. Currently the phpcs config in MediaWiki's MobileFrontend extension differs from the MediaWiki one - the following sniffs are disabled:

  MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
  MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
  MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage
  MediaWiki.Commenting.FunctionComment

To get setup install https://github.com/squizlabs/PHP_CodeSniffer globally and then run the following inside the MobileFrontend repo

phpcs -p -s

They should all pass as we are excluding certain rules inside .phpcs.xml

Runing phpcs without all those exclusions currently gives 334 errors and 51 warnings.

Work on re-enabling one sniff at a time:

  • Remove a single sniff from the .phpcs.xml file (an exclude tag), run composer phpcs or phpcs -p -s, get a list of violations,
  • provide patches in Wikimedia Gerrit to fix the violations. If you fix all violations for one sniff, also commit the removal of the exclusion from .phpcs.xml too.
  • Commit the change when everything passes
  • Repeat until you have spent more than 3 hours on this task. You may be able to fix them all in this timebox, but you should not feel bad if you don't!

If a sniff can't be made to pass for some reason, then document it as close as possible to the line disabling the sniff.

Task tags

  • code quality
  • php

Students who completed this task

Albert Wolszon

Task type

  • code Code
  • done_all Quality Assurance
close

2017