-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add --json
flag to lint
#183
Comments
I've had a longer think about this.
So I recently learnt that SPDX soon wants to adopt JSON and YAML as new output formats. Or rather, they want to formalise those formats. @silverhook brought up that YAML is likely to become dominant among the output formats. I would personally prefer JSON over YAML because JSON is in the Python standard library, and is imo a much cleaner, clearer standard, but I can concede that YAML is a lot prettier to look at. So instead of doing our own JSON API, it would be much nicer to simply output SPDX JSON/YAML. If the SPDX JSON/YAML doesn't contain some stuff that we need, we can:
The way I see it, this could be implemented really well through https://github.com/spdx/tools-python as a library. We could contribute to that project to add some of the things we need, and remove some code in this repository in the process. As a plus, if we use that repository (and patch it up), we get multiple output formats for free. It'd be a matter of The only problem, however, is that I am not entirely happy with I'm fairly confident, however, that tighter integration with an improved |
Interesting thoughts! One way to bring this issue on SPDX' table could be to write an email to the spdx-tech mailing list (https://lists.spdx.org/g/spdx-tech) and perhaps have this as a topic in one of their calls. |
My thoughts are that YAML should deprecate tag:value, but I think JSON will be the more popular choice in SDPX. It is already happening, see: https://github.com/spdx/spdx-spec/blob/7ca9672d1abf2b60985b840d5705a6539ee36635/chapters/1-rationale.md#17-format-requirements- In any case, I agree that joining the SPDX Technical mailing list and calls would make sense for at least one of you, if not both. |
I've been subscribed to the lists for a long time, but very passive. I'll be able to be more proactive in the coming months; see if I can attend some meetings. |
The new SPDX spec should include JSON and YAML by now :) |
I'd like to have more support for other SPDX formats as well. RDF and YAML are nice, but JSON is something I can directly inject into Elasticsearch and generate dashboards for a project overview. Now that it is part of the SPDX spec it feels like the right moment to adopt this. JSON spec: https://github.com/spdx/spdx-spec/blob/master/schemas/spdx-schema.json I'd have to look into the source code, but I assume that maybe the As the JSON spec contains the |
In today's maintainers call, we agreed that we want to have this in the next release. What we agreed on:
These questions remain:
We should also take #256 into consideration when working on this feature |
Personally I like YAML, but since there’s already official SPDX Tools that are well capable of transforming one valid SPDX format into another, let’s first concentrate on getting one right, and let that one be the one that will be the most useful for users. |
We had another meeting in which we've discussed the remaining questions and also the relation to other topics linked with the The decisions we've made:
Suggestion of JSON outputsBefore starting to work on the code, we want to agree on a format for the JSON output. @carmenbianca also mentioned that we could draw inspiration from the From the outputs I deleted all logger errors as I imagine these would be the same in both output types. Example for compliant repoI base this on the master branch of the example repo which is compliant. Current output of reuse lint
Suggested output of reuse lint --json{
"json_version": "1.0",
"reuse_version": "3.0",
"non_compliant": {
"missing_licenses": [],
"unused_licenses": [],
"deprecated_licenses": [],
"bad_licenses": [],
"licenses_without_extension": [],
"missing_copyright_info": [],
"missing_licensing_info": [],
"read_errors": []
},
"files": {
".gitignore": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <jane@example.com>",
"source": ".gitignore"
},
"license": {
"value": "CC0-1.0",
"source": ".gitignore"
}
},
"Makefile": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <jane@example.com>",
"source": "Makefile"
},
"license": {
"value": "GPL-3.0-or-later",
"source": "Makefile"
}
},
"README.md": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <jane@example.com>",
"source": "README.md"
},
"license": {
"value": "GPL-3.0-or-later",
"source": "README.md"
}
},
"img/cat.jpg": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2017 Peter Janzen",
"source": "img/cat.jpg.license"
},
"license": {
"value": "CC-BY-SA-4.0",
"source": "img/cat.jpg.license"
}
},
"img/dog.jpg": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2017 Raffael Herrmann",
"source": "img/dog.jpg.license"
},
"license": {
"value": "GPL-3.0-or-later",
"source": "img/dog.jpg.license"
}
},
"src/main.c": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <jane@example.com>",
"source": "src/main.c"
},
"license": {
"value": "GPL-3.0-or-later",
"source": "src/main.c"
}
}
},
"summary": {
"used_licenses": [
"CC-BY-SA-4.0",
"CC0-1.0",
"GPL-3.0-or-later"
],
"files_total": 6,
"files_with_copyright_info": 6,
"files_with_licensing_info": 6,
"compliant": true
}
} Example for many errorsCheck out this branch to get the basis for the output below. Additionally, I made Current output of reuse lint
Suggested output for reuse lint --json{
"json_version": "1.0",
"reuse_version": "3.0",
"non_compliant": {
"missing_licenses": [
"MIT"
],
"unused_licenses": [
"CC-BY-SA-4.0",
"GPL-2.0+",
"InVaLiD",
"Apache-2.0"
],
"deprecated_licenses": [
"GPL-2.0+"
],
"bad_licenses": [
"InVaLiD"
],
"licenses_without_extension": [
"Apache-2.0"
],
"missing_copyright_info": [
"Makefile",
"src/main.c"
],
"missing_licensing_info": [
".gitignore",
"src/main.c"
],
"read_errors": [
"README.md"
]
},
"files": {
".gitignore": {
"copyright": {
"value": "Copyright (c) 2012 Myself",
"source": ".gitignore"
},
"license": {
"value": null,
"source": null
}
},
"Makefile": {
"copyright": {
"value": null,
"source": null
},
"license": {
"value": "MIT",
"source": "Makefile"
}
},
"img/cat.jpg": {
"copyright": {
"value": "SPDX-FileCopyrightText: 2022 me",
"source": "img/cat.jpg.license"
},
"license": {
"value": "MIT",
"source": "img/cat.jpg.license"
}
},
"img/dog.jpg": {
"copyright": {
"value": "2022 me",
"source": ".reuse/dep5"
},
"license": {
"value": "MIT",
"source": ".reuse/dep5"
}
},
"src/main.c": {
"copyright": {
"value": null,
"source": null
},
"license": {
"value": null,
"source": null
}
}
},
"summary": {
"used_licenses": [
"MIT"
],
"files_total": 5,
"files_with_copyright_info": 3,
"files_with_licensing_info": 3,
"compliant": false
}
} Open questions/comments
|
Great work! Covering multiple copyright values was my first thought reading this: ".gitignore": {
"copyrights": [
{
"value": "SPDX-FileCopyrightText: 2019 Jane Doe <jane@example.com>",
"source": ".gitignore"
},
{
"value": "SPDX-FileCopyrightText: 2012 John Doe <john@example.com>",
"source": ".gitignore"
},
],
"license": {
"value": "CC0-1.0",
"source": ".gitignore"
}
}, And maybe the same for licenses as well? |
All the infrastructure for this is already in place, but it could be really helpful for people who want to programmatically automate stuff: a
reuse json
interface. It'd simply output a combination ofreuse lint
andreuse spdx
, but in JSON format.The text was updated successfully, but these errors were encountered: