reuse-tool icon indicating copy to clipboard operation
reuse-tool copied to clipboard

Treatment of 0-size files by reuse lint

Open richardfontana opened this issue 2 years ago • 4 comments

Suppose I have a LICENSES/ directory containing GPL-3.0-or-later.txt, a conformant .reuse/dep5 file with the following contents:

Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Project
Upstream-Contact: Jane Doe <[email protected]>
Source: https://example.com/jane/project

Files: *
Copyright: Richard Fontana
License: GPL-3.0-or-later

and then I add an empty file using touch foo.txt. reuse lint reports: Unfortunately, your project is not compliant with version 3.0 of the REUSE Specification :-(

But if I edit foo.txt so that it contains one whitespace character, or a conformant SPDX-License-Identifier: statement (but foo.txt otherwise remains empty), reuse lint reports: Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)

Why should 0-size files along with a conformant dep5 file be treated differently from these other cases?

richardfontana avatar Apr 23 '23 18:04 richardfontana

Unfortunately you didn't provide the full report, but I suppose it looks like the following:

# UNUSED LICENSES

The following licenses are not used:
* GPL-3.0-or-later


# SUMMARY

* Bad licenses:
* Deprecated licenses:
* Licenses without file extension:
* Missing licenses:
* Unused licenses: GPL-3.0-or-later
* Used licenses:
* Read errors: 0
* Files with copyright information: 0 / 0
* Files with license information: 0 / 0

Unfortunately, your project is not compliant with version 3.0 of the REUSE Specification :-(

The problem is that there is a license text file (LICENSES/GPL-3.0-or-later.txt) that isn't applicable to any file. Quote from the REUSE spec: "A Project MUST NOT include License Files for licenses under which none of the files in the Project are licensed."

Even if you remove the 0-sized file, it would result in the same error, as 0-sized files and symlinks are ignored by the linter.

One could argue that a completely empty repo with just a license text file could still be REUSE compliant, but I wonder which edge case this would solve.

mxmehl avatar Apr 24 '23 08:04 mxmehl

Admittedly the use case here is probably just the psychological benefit of frequent use of reuse lint (with positive feedback) for REUSE fans or potential fans. I may be unusual in using touch to create new files that I know I will want to eventually populate (e.g., skeleton files for a given type of repository).

I didn't see that sentence in the spec, but maybe it should be clarified that 0-size files are not considered to be files, while nonzero-size but effectively empty files are considered to be files. This difference is nonobvious to me and I spent a little bit of frustrating time trying to figure out why my new repo was not REUSE compliant.

Anyhow feel free to close this issue if you don't see any need for action. :)

richardfontana avatar Apr 25 '23 00:04 richardfontana

I changed the tag from pending/close to documentation. I'm sure we can document this better somewhere.

It's currently documented as a single line here: https://reuse.readthedocs.io/en/latest/usage.html

Symbolic links and files that are zero-sized are automatically ignored.

carmenbianca avatar Apr 25 '23 07:04 carmenbianca

I'm not sure whether we speak about the same. Let's take this example:

.
├── foobar
└── LICENSES
    └── MIT.txt

The repo will not comply with REUSE in all of these cases:

  1. foobar does not exist at all
  2. foobar is empty (0 bytes content) or a symlink
  3. foobar is non-empty but does not contain SPDX-License-Identifier: MIT (alternatively via dep5 or foobar.license)

In all cases, the error is that there exists a MIT licence file while there is no file being licensed under MIT.

So the 0-sized file thing is not the deciding factor as I see it. But perhaps I misunderstand both of you? Or rather, how could we improve documentation?

mxmehl avatar May 03 '23 15:05 mxmehl