Love thy module; add those tests already, will ya?


Prologue

I just came back to my home-office after a short holiday break and I ran straight to my laptop to check - for the millionth time in recent weeks - the usage statistics for File Upload Secure Validator. Unsurprisingly I saw again what I could not fathom. The numbers went up… again.

Same as last week and the week before that. Below are some ruminations about a humble, insignificant contrib module and its early path to being a best-seller. I am going to make some - quite obvious - points and reach a convenient conclusion in the end. So, no scientific standards met in this read. :-)

alt text

File Upload… whaaat?

Allow me first to introduce you to one of the tiniest contrib modules out there; the FUSV (File Upload Secure Validator). A couple of years ago we were going through a security audit checklist for an enterprise-grade application that was reaching its final development stages. That thread led my highly esteemed colleague dcre and I to put together a speck of code that would allow the core file validation to use the fileinfo extension, instead of extracting the MIME type from the uploaded file’s extension.

And the FUSV was born. For Drupal 7 that was.

No love, no popularity

This is not about being popular for yourself, this is about self-indulgence for geeks. The more downloads your module gets, the better you feel about your programming self. The more sites are reported using your module, the more you start realising that the problem you solved is a significant one. It took FUSV about 11 months from its publication date (September 27, 2015 - August 14, 2016) to report more than 50 sites using it. During that time, the maximum observed increase peak (MOIP) was 8 sites.

And MOIP is what exactly?

It’s my own acronym for the difference between the highest observed global maximum to date and the current global maximum, in case it’s higher.
The following table gives an example of how the MOIP is calculated.

Week/ Downloads/ Highest global max/ MOIP
#1 0 0 -
#2 10 10 10
#3 6 10 10
#4 14 14 10
#5 36 36 22

First signs of love: Issues are created

In the meantime, as expected since at least some few people were actually using FUSV, two issues came in, in May and September of 2016 respectively, around the time that the 50+ sites milestone was reached. It took little more than a month for us to work with and supervise the submitted patch for the first issue all the way to commiting the changes. The second bug report came without a patch and we resolved it on the same day.

The fact that we tried to be responsive in a timely manner as well as cooperative with the issue reporters, all the way to solving them issues, on the one hand was a given and on the other hand can be loosely regarded as a reason why the numbers kept rising - albeit slightly.

So, and as is probably quite obvious, even if working with the issue queue is expected from a maintainer:

Observation 1. # Working with the issue queue is critically important for the adoption of your module.

Second sign of love: Port it, it’s worth it!

Shortly after that, and exactly a year after the original release (September 28, 2016), a first experimental(-dev) Drupal 8 version was released. That might have actually improved the popularity of the module in general, since from that point on, the numbers kept rising - slowly but surely.

To further support this, the MOIP after the D8 release came up to 12 sites.

Observation 2. # A D8 version increases the visibility of your module.

Third sign of love: Add those tests!

On the 26th of March 2017, we added tests to the D7 version of the module (which also forced some refactoring, like, TDD, like). The MOIP rose to 18 a couple of weeks later!

Observation 3. # Providing tests for your code increases the credibility of your module.

Meanwhile, the D8 version was stuck between 0 and 2 reported sites using it. On top of the low numbers, the one and only reported D8 issue did not receive any attention for two months. Ouchhhh!

4th sign of love: Add those ported tests!

On the 21st of May 2017, we finally released a stable D8 version with tests included. That allowed us to close all pending bug reports and have a clean slate for both D7 and D8. Because, in the end, a stable version with tests should be the goal for your module.

And then? And then, well, love spreads

Okay, so, why is all these important? Because, according to the latest numbers, we see some really positive responses to these changes.

a) The D7 version’s usage numbers keeps rising and touched the 150+ sites milestone, a year after stepping over the 50+ and two years after the first release.

b) The usage for the D8 version is also on the uprise, but in a more explosive fashion. It went from 4 reported sites in the beginning of July to 104 after just 4 weeks. It also reported a MOIP record of 52 sites.

Even though working with the bug reports is still very important, it seems to me that the big difference comes from offering tests. And that led to an increase in usage in July 2017 of more than 2000%.

Conclusion # Adding tests to your module could increase its popularity immensely

Disclaimer: This is a purely subjective, non-scientific conclusion, but my gut feeling is just telling me FUSV can be the next… well… the next… Composer autoloader?