User:Lethexie/GSoC2016 Final Evaluation Report

Finally, the project "Improving static analysis tools for MediaWiki" is approaching its end. I feel happy to work with Mediawiki and really enjoy coding this summer. Let's begin with accounting goals and achievements in the project. All of my contributions to the project could be found here.

Jobs Done

edit
Forbidding illegal format of inline comments like /*** fail ***/
edit

In this sniff, it forbids illegal inline comments that use multiple asterisks (amount >= 2) and give a warning, with auto fix capability. The commit information is provided here: https://gerrit.wikimedia.org/r/292313

Unexpected empty line shows up after fixing the open brace of a function
edit

This sniff fix a bug that cause a empty line added to the start of a function when phpcbf try to automatically change the brace-opening style. The commit information is provided here: https://gerrit.wikimedia.org/r/293966

A newline expected before a single line comment
edit

To conform to the coding standards that states "an inline comment should start with a new line", this sniff automatically detect codes that against the specification, and give out warnings. This sniff provide capability of automatic fixing through phpcbf. The commit information is provided here: https://gerrit.wikimedia.org/r/295901

Brace should be placed on the same line as the start of class
edit

This sniff unify the open brace location of a class. According to Mediawiki's coding standards, the open brace should be placed in the same line with the class declaration. It provides capability of automatic fixing through phpcbf. The commit information is provided here: https://gerrit.wikimedia.org/r/297355

Using globals ($wgUser, $wgRequest) when their context equivalents could be used instead ($this->getUser(), $this->getRequest())
edit

This sniff enforce all subclasses that derived from ContextSource to use the context equivalents like $this->getUser() than the global functions like $wgUser (except the static member functions). The commit information is provided here: https://gerrit.wikimedia.org/r/301335

Using wfMessage() when $this->msg() is usable
edit

This sniff perform the same kind of check on the codebase as the 5. The commit information is provided here: https://gerrit.wikimedia.org/r/301335

Add function comments
edit

This sniff enforce every functions to have a document comment. The commit information is provided here: https://gerrit.wikimedia.org/r/291489

In Review

edit
Check if the code use PHP superglobals (like $_GET, $_POST, etc)
edit

This sniff warn codes that use PHP superglobals like $_GET and $_POST, etc. According to Mediawiki's coding standards, accessing PHP superglobals is illegal. The commit information is provided here: https://gerrit.wikimedia.org/r/296395

Job That Are Abandoned

edit
Avoid to use PHP deprecated classes, functions and variables
edit

The major reason for abandoning this task is PHP is providing deprecation warnings itself even if the code is analyzing by PHPCodesniffer. So we agree that this task is no longer needed thus abandon it.

What To Do Next

edit

After the GSoC, I will continue working with Mediawiki developers to:

  1. work on the passed commits
  2. solve problems feedback from other developers

Also, there's a task was not accomplished in a perfect way: Usage of $dbr->query() directly instead of the $dbr->select() wrapper.

This sniff warn the codes that access database through calling $dbr->query() instead of $dbr->select(). However, some special cases revealed when we test on it. Some code use $dbr->query() to fetch database status data may have to use $dbr->query(), as the case https://github.com/wikimedia/mediawiki/blob/master/includes/search/SearchMySQL.php#L438-L441 shown. We need working on these exceptions later. The commit information is provided here: https://gerrit.wikimedia.org/r/301364

Conclusion

edit

During the project development process, my mentor @EBernardson and @Legoktm has helped me a lot. Very appreciated! I will keep working with Mediawiki, and contribute to open source.