Contributions to Homebrew in GSoC '17
Past couple of months, I have been contributing to Homebrew as a GSoC project. This post summarizes the work that has been done, and the road ahead.
Summary
All Pull Requests in Homebrew/brew by me can be accessed here:
List of all the above PRs (both merged/open) (Click to expand)
Pull requests that got merged during GSoC work period:
- #2610: Add autocorrect method for ComponentsOrder rubocop and tests
- #2628: audit: Detect multiline and interpolated strings in formula desc cop
- #2631: audit: Port audit_homepage method to rubocop and add tests
- #2662: audit: Port audit_text method to rubocop and add tests
- #2664: audit: Port audit_caveats method to rubocop and add tests
- #2755: audit: Port audit_checksum method to rubocop and add tests
- #2776: audit: Fix audit_checksum method's rubocop and add more tests
- #2790: audit: Port audit_legacy_patches method to rubocop and add tests
- #2842: audit: Don't run audit methods when `--only-cops` option is passed
- #2843: audit: Port audit_conflicts method to rubocop and add tests
- #2853: style: Don't run FormulaAuditStrict cops when `brew style foo` cmd is executed
- #2879: audit: Port audit_options non-strict rules to rubocop and add tests
- #2901: audit: Port audit_options strict rules to rubocop and add tests
- #2905: audit: Port audit_options rules for new formulae to rubocop and add test
- #2906: style: disable NewFormulaAudit cops' execution by default unless specified
- #2911: audit: Port audit_urls partially to rubocop and add corresponding tests
- #2932: audit: Port audit_urls to rubocop and add corresponding tests Part 2
- #2957: audit: Run style violations check when `--new-formula` is passed
- #2964: audit: Port dependency rules from line_problems to rubocop and add tests
- #2975: audit: Port audit_urls strict rules to rubocop, add tests, autocorrect
- #2976: audit: Port patches audit code to a rubocop and add tests
- #2980: audit: fix bug where `brew audit foo` runs every style check.
- #3012: Add node pattern methods to handle dependency audits in a better way
- #2995: audit: Port line_problems to rubocop and add tests part 2
- #3063: audit: In Cops and their tests convert all multiline strings to heredocs
- #3087: audit: Add previously unported GH patch audit rule in Patches cop
Pull requests still under review:
Stats
Project Description
This project implements RuboCop custom cops to check Homebrew’s coding style violations programmatically. More details can be found here and here.
Project Learnings
Searching through the whole git history has been very helpful, as it would mostly lead me to the first PR where the concerned contributor or maintainer would have written about the code. PR checklist template FTW!
I learnt to test my code extensively before opening a PR. The importance of this cannot be stressed enough. Do not ever be negligent and assume that your code will always work. Then things will break when that nasty edge case is encountered.
I also learnt to not be afraid and jump into source code instead of reading the docs. RuboCop has a more user driven documentation, while documentation of its internals is rather scarce. By going through the source of RuboCop, I came across an undocumented and a powerful feature of RuboCop. It greatly simplified some parts of my GSoC Project. Also, I reported a bug, and contributed in writing a new cop in RuboCop project. I also got to understand how certain aspects of RuboCop offense checks work, thus preventing unexpected bugs in Homebrew.
The reason why 3 out of the 15 methods could not be ported is because RuboCop runs in a separate process and these methods use Homebrew’s internals, hence are not available in that process. Unix sockets for interprocess communication(IPC) could be used but making it complicated is just not worth it.
Road ahead
Whilst the audit
rules have been ported to RuboCop cops, few of them have autocorrect
. Now I would be looking at adding autocorrect
methods, so correcting the style offenses across
huge number of Formulae
can be automated. I also look forward to continue contributing to Homebrew. Its the project which makes macOS usable to developers and I myself
use brew
heavily on a day to day basis.
Over all, it has been an amazing experience for me, working on a popular project, with awesome supportive friendly talented mentors (MikeMcQuaid & Jcount) and co interns.
Credits
This project would never have gotten to this stage without the code reviews and discussions with my mentors. A huge shout out & sincere Thanks to all the mentors at Homebrew (MikeMcQuaid, Jcount, ilovezfs, alyssais, apjanke , woodruffw, bfontaine & others) and amazing people at Google for this opportunity and giving a headstart in OSS. You simply rock!
Until next time and May the source be with you!