-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not only comments are scanned #429
Comments
I nailed it down to the function It takes a text as argument (usually the whole file content) and scans for the SPDX identifiers in the whole text. To fix this issue, either this function would have to be given only the text within comments, or it would have to be given the comment style as argument too, and then make sure it only considers SPDX identifiers found in actual comments. What do you think? |
Yeah, we've had this problem a couple of times. There are some ugly tricks to circumvent, e.g.: reuse-tool/tests/test_header.py Lines 45 to 53 in 149f843
or reuse-tool/tests/test_header.py Lines 182 to 184 in 149f843
Obviously, that is not satisfying. Therefore, in fsfe/reuse-docs#70 we try to define solutions. E.g. have a look at option 3 which is currently the most preferred. A Your solution would be nice as well. However, can we be sure to avoid false-positives and especially false-negatives? The REUSE tool defines recommended comment syntaxes for file types, but for some languages there may be multiple options. E.g. take this bad example of a PHP file: <html>
<!-- SPDX-License-Identifier: MIT -->
<head><title>My website</title></head>
<body>
<?php
/* SPDX-License-Identifier: Apache-2.0 */
// SPDX-FileCopyrightText: foobar
echo date("Ymd");
?>
</body>
</html> We have multiple comments styles here: PHP multiline, PHP singleline, and HTML. Ideas and input welcome how to tackle this! |
Regarding PHP, I'd say: start supporting the most common use-cases first and incrementally add more if/when people start complaining. I think HTML based PHP templates should probably be mostly left alone, as the developer will have to decide for themselves if they want HTML or PHP comment regarding their copyright... The most common use-case of modern PHP would be class files. I'd suggest a file-level doc-block should suffice: <?php
/**
* SPDX-FileCopyrightText: <year> <author>
* SPDX-License-Identifier: <license>
*/ That would also make it possible to re-use/extend such a doc-block with other PhpDocumentor tags. |
Would be solved by #463 |
Absolutely, that is the next best solution for these kinds of issues. |
Users running into the problem like I do here, |
@hoijui It's in the official documentation: https://reuse.readthedocs.io/en/stable/usage.html#ignoring-parts-of-a-file |
The reuse tool fails to scan the following BASH file because of the
echo "SPDX-...
lines,no matter whether the file is called
tst
,tst.sh
ortst.bash
.As the prefix to the trouble-some lines is
echo "
,which is not a valid comment line in any format,
I imagine it should be technically possible to make this work,
at least in theory.
The text was updated successfully, but these errors were encountered: