User:TasneemLo/Outreachy11-CodeSniffer

Improving Static Analysis Tools for MediaWiki
Public URL - http://www.mediawiki.org/wiki/User:TasneemLo/Outreachy11-CodeSniffer

Related phabricator tasks - T89682 is the master task.

Project Outline
The most popular issues that come up in review are based on coding conventions - especially when a new user wants to contribute to the community. This can be addressed by a static code analysis tool which is able to identify these problems (without human intervention) and can let the contributor know the issues - or better yet solve it autonomously. PHP-CodeSniffer is one such tool which allows this.

PHPCS has already been added to the composer file in mediawiki-core (patch) and the core nearly passed the test using the custom standard for mediawiki is being worked on. This projects aims to improve on the custom standard and make it even better. This reduces the repetitive tasks that every reviewer has to do to check coding standards and also gives the contributor a quick way to correct it !

There are many avenues where the codesniffer can be improved: Of these, the first is the most important and the other two are smaller and easy to do (and already has patches). The first point is where I will be focusing on in my project. If time permits, I'll also work on the others.
 * Making mediawiki specific sniffs which are able to identify reasons why the patch-set should not be accepted.
 * Testing infrastructure for the codesniffer itself. (T92751, T108458)
 * Set-up CI on the core and all other extensions. Also enable phpcs in the composer files.

Mentors: User:Addshore, User:Ebernhardson

Communication
I will always try to stay logged into IRC (Channels #mediawiki, #mediawiki-dev, #wikimedia-tech and #wikimedia-releng during my working hours and will try to contribute back to the community as much as I can. I am extremely regular in replying to emails and also to comments on phabricator and gerrit (as they send notifications to my mail). I plan to prepare a weekly report of things done (as recommended in lessons learned) and send it over to my mentors and update it on this page in the Timeline section. All source code written by me will be regularly pushed to gerrit so that my mentors can review it when they're free. I will keep my mentors updated about the progress through what ever form of communication they prefer (Email or weekly IRC meetings). All discussions regarding design and implementation will be public :)

Initial homework (Nov 17 - Dec 7)
This section encompasses work that will be done before the official coding period begins. Here, the major priority is to identify the sniffs to make during the project. Possible methods include: This would give a list of sniffs or at least a good idea on what sort of things can be done during the next phase of the project.
 * Design and make a survey where people can describe what basic checks they do before accepting a patch. Also, float this survey on wikitech-I.
 * Go through recent patch sets and identify issues mentioned in the comments that can be checked using codesniffer (Maybe this could be automated ... but it seems troublesome with too many false positives/false negatives)
 * Find sources like mediawiki-tools-code-utils or PHP_CodeSniffer itself - which do similar static code analysis - and identify whether they can be implemented/modified for our case.
 * Figure out sniffs that can be made using the CHANGELOG between mediawiki versions.
 * Read through Manual:Coding conventions/PHP and identify any points that need more looking into. (I've already read this to a large extent.)

Week 1 (Dec 7 - Dec 13)
Here, I'd like to work on a secondary task where a patch has already been submitted by me - The testing infrastructure. Currently the testing infrastructure is not up to the mark, and I'd like to be able to fix this issue. Currently, integration tests are being done - and it is only checked whether a file passes the phpcs test or not. This is okay, but doesn't really test what is needed.

Things needed to be addressed:
 * The file may fail due to another sniff finding a fault - so, only the sniff being tested should be enabled.
 * It is not checked whether all the fail cases are actually failing - it is only seen whether the whole file is failing. Need to check which lines the failure is happening in.
 * Fix-its are not being tested at all, and currently it simply tests if issues have been found. An infrastructure for fix-it testing needs to be made.

Week 2 (Dec 14 - Dec 20)
During this week, I hope to complete the testing infrastructure mentioned above, move all existing tests to the new infrastructure, add new tests to test fix-its and push it to master.

Other than that the list found during the Initial work needs to be compiled from the survey and other sources and a priority order needs to be given.

Week 3 (Dec 21 - Dec 27) to Week 13 (Feb 29 - Mar 6)
This week, I plan to create phabricator tasks for the items found. Also, I will post all the data I found in a common space so that it can be used later also. The phabricator tasks will be refined form of the data so that even if I am unable to complete all of the things found, it can be taken up by others or myself after the Outreachy project.

Here, I begin making sniffs for each phabricator issue and test them on mediawiki-core or other mediawiki related code. Iterations to improve and fix any issues that come up will be needed.

This will be repeated for the rest of the project. I'll keep a deadline every two weeks to ensure all my sniffs until then have been merged.

Personal Information
Name - Tasneem Lohani

Email - tasneem.lo.31 [at] gmail.com

IRC Nick - TasneemLo

User Profile - https://www.mediawiki.org/wiki/User:TasneemLo

Timezone - UTC + 5:30 (IST - India)

Location - India

Typical working hours (Flexible to ensure deadlines are kept)
 * IST : 10am to 1pm and 3pm - 9pm
 * UTC : 4:30am to 7:30am and 9:30am - 3:30pm

About me
I'm a college student from India, and at my college I learn a lot of varied things. I've made and designed a few websites earlier and am familiar with PHP, JavaScript, HTML/CSS. I've also dabbled in android development (although I do not own an android phone right now). I have a very varied skill set and love doing things that interest me and make me learn new things. I've recently started contributing to open source software, and MediaWiki was the right fit for me as I'm well versed with web technologies.

Current experience with Mediawiki

 * Have set-up the development and debug environment on the core and mediawiki-codesniffer.
 * Basic familiarity of code and code conventions.
 * Understood the process of submitting a patch and review (phabricator, gerrit and git).
 * Understood how to write a PHPCS sniffer and written a few of them (see "Bugs worked on" for more details).
 * As a users, obviously, I have used Wikipedia and other wiki sites as any other student has :)

Time management
I will not be working on any other projects during the time Dec 7 to Mar 7. My winter holidays happen during the time of Outreachy, so I will not be having academics interfering with it.

I may plan a vacation for a few days (maximum 4 days) around Christmas (Dec 25), but I can make up the time in other weeks.

I plan to work around 8 hours a day (as mentioned in Typical working hours) and that gives around 40 hrs per week (not including weekends). These are of courses flexible depending on whether all my deadlines are met.

Bugs worked on

 * T92744 : Assign in if/while in CodeSniffer (patch submitted)
 * T114633 : Handle comments with multiple # (patch submitted)
 * T92751 : Test suite revamp in CodeSniffer - also a fix for T108458 (patch submitted)
 * T101311 : If else structure in CodeSniffer (done)

Also gave inputs on a host of other tasks which can be seen at my profile
 * T114267 : Sniff to detect usage of  (done)
 * T100467 : Rename "resource" module names for MobileFrontend (done)
 * T106005 : Change blue colors to standard color (done)

Other Information
(as mandated by Outreachy application format)

Do you meet the eligibility requirements outlined? Yes

Preferred pronoun - she

Education - Student at Stella Maris in Bachelor, Visual Arts. Graduating in 2017

How did you hear about this program - A friend who participated in GSoC