Page MenuHomePhabricator

Add a linter rule for detecting empty files
ClosedPublic

Authored by joshuaspence on Aug 13 2015, 10:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 10:46 AM
Unknown Object (File)
Wed, Mar 20, 11:51 PM
Unknown Object (File)
Mar 6 2024, 4:42 AM
Unknown Object (File)
Mar 6 2024, 4:42 AM
Unknown Object (File)
Jan 28 2024, 8:10 AM
Unknown Object (File)
Jan 28 2024, 8:10 AM
Unknown Object (File)
Jan 28 2024, 8:10 AM
Unknown Object (File)
Jan 27 2024, 2:08 AM

Details

Summary

Adds two different linter rules (one general purpose and another PHP specific) to prevent empty files from being added to a repository. For some unknown reason, people seem to like to do this.

Test Plan

Added test cases.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Add a linter rule for detecting empty files.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 13 2015, 2:37 PM

FWIW Creating an hidden empty file in a directoy seems to be the convention for making git create a directory in the working copy on checkout.

It's also practically required with python (To specify a package directory with __init__.py).
Sometimes people put stuff in it, which makes it even worse, IMO.

Maybe default this to advice?

Ah, good points.

You can put some text in .keep files to explain what the directory is used for, and they're normally fairly few and far between. This probably isn't a bad practice, but this isn't terribly obvious and is a little cumbersome. And this is pretty unreasonable to expect of __init__.py files.

We could try excluding .dotfiles and __init__.py by default. I'm not sure if this gets us 50% or 99% coverage of exceptions.

We could toss the generic version of the rule or disable it by default.

This is also tricky because there's no way to selectively disable it on-site via some eventual syntax added by T1549.

joshuaspence edited edge metadata.

Exclude __init__.py and filename beginning with .

This revision was automatically updated to reflect the committed changes.