Skip to content
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

Adding --json to lint #654

Merged
merged 60 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cb94206
Rework `lint`
linozen Jan 11, 2023
3ae8af7
Add --json` argument
linozen Jan 24, 2023
2e6805e
Slim down data dictionary creation
linozen Jan 24, 2023
5a03e9e
Rework plaintext formatter
linozen Jan 24, 2023
21d0026
Move JSON formatter and re-add `lint` function
linozen Jan 24, 2023
0b473f0
Remove old output generation functions
linozen Jan 24, 2023
74fd00e
Adapt tests
linozen Jan 24, 2023
fb32ead
Add new tests
linozen Jan 24, 2023
ff3d3c3
Satisfy pylint
linozen Jan 24, 2023
cfcac8e
Satisfy isort
linozen Jan 24, 2023
d749d51
Make showing of license (not path) work on Windows
linozen Jan 24, 2023
5dcd872
Satisfy pylint (again)
linozen Jan 24, 2023
e03fb3e
Add changelog entry
linozen Jan 24, 2023
89dbd8b
Fix typo
linozen Jan 24, 2023
034a9af
Move `collect_data_from_report` to `ProjectReport.to_dict`
linozen Feb 15, 2023
6bb2a47
(convenience) Add `--format` to easily switch between plain and JSON …
linozen Feb 15, 2023
6bc172a
Get `__REUSE_version__` from report object
linozen Feb 15, 2023
2a2e44f
Add newline at the end of the output
linozen Feb 15, 2023
5c25198
Update tests according to code changes
linozen Feb 15, 2023
f697c73
Fix minor issues in `report.py`
linozen Apr 5, 2023
f20429f
Fix plaintext output
linozen Apr 5, 2023
1b2bd90
Add custom JSON serializer
linozen Apr 5, 2023
d98d162
Adapt `SpdxInfo` namedtuple to contain source path
linozen Apr 5, 2023
9c106f1
Remove useless line
linozen Apr 5, 2023
9beac70
Actually return license/copyright source path
linozen Apr 5, 2023
c43c91f
Determine license source correctly
linozen Apr 5, 2023
6fc5ec1
Allow returning empty arrays
linozen Apr 5, 2023
3ad1fe3
Satisfy black
linozen Apr 6, 2023
2fcc8eb
Ensure consistency of the JSON output
linozen Apr 6, 2023
d50d15e
Ensure consistency of the plaintext output
linozen Apr 6, 2023
fbf6e53
Move logic to FileReport.to_dict and rename method to to_dict_lint
carmenbianca Apr 10, 2023
bd59465
Create ProjectReport.is_compliant
carmenbianca Apr 10, 2023
8f3b5d0
Rename json_version to lint_version
carmenbianca Apr 10, 2023
8feed9e
Remove superfluous function
carmenbianca Apr 10, 2023
7423f62
Make tests run by importing an existing function
carmenbianca May 11, 2023
f648356
Repair boolean check of SpdxInfo; object not iterable
carmenbianca May 21, 2023
c75a3e3
Correctly use format_plain
carmenbianca May 21, 2023
5bc2c58
fixup! Rename json_version to lint_version
carmenbianca May 21, 2023
54a8a66
fixup! fixup! Rename json_version to lint_version
carmenbianca May 21, 2023
d3208db
Don't pass string where (optional) set is expected
carmenbianca May 21, 2023
8a40fb6
fixup! Don't pass string where (optional) set is expected
carmenbianca May 21, 2023
a769306
fixup! fixup! Don't pass string where (optional) set is expected
carmenbianca May 21, 2023
cc5a383
Create SpdxInfo.contains_copyright_or_licensing
carmenbianca May 21, 2023
23fa4cc
Make lint version a global constant
carmenbianca May 21, 2023
8fa808a
Add tool version to json output
carmenbianca May 21, 2023
c94b5a0
Refactoring precedence for license path
linozen May 25, 2023
7493ed1
Add two `--json` specific test to `tests/test_lint.py`
linozen May 25, 2023
bb3217a
Adapting two tests to new precedence behaviour
linozen May 25, 2023
f2f1ef0
Adding a warning when information is overriden
linozen May 25, 2023
cd820e1
Import `Path` instead of `PosixPath`
linozen May 25, 2023
6c51545
Use `StringIO` object instead of normal string object
linozen May 25, 2023
d1c2146
Make sure that some keys are on top of sorted output
linozen May 25, 2023
c8baa6e
Make `summary_contents` a dictionary
linozen May 25, 2023
983b0c4
Simplify `lint --quiet`
linozen May 26, 2023
d7af2e2
Move dictionary sorting and test it
linozen May 26, 2023
33456cb
Rename `SpdxInfo` to `ReuseInfo`
linozen May 26, 2023
962521f
Rename `ReuseInfo.license_path` to `ReuseInfo.source_path`
linozen May 26, 2023
852b3fb
Also encode `source_type` in `ReuseInfo`
linozen May 26, 2023
322dd8a
Rename `spdx_info_of` to `reuse_info_of`
linozen May 26, 2023
7346234
Add SourceType enum and use it for source_type in ReuseInfo
linozen Jun 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/reuse/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,24 @@ def custom_serializer(obj):
f"Object of type {obj.__class__.__name__} is not JSON serializable"
)

def custom_sort_key(key):
order = {
"lint_version": 0,
"reuse_spec_version": 1,
"reuse_tool_version": 2,
}
return (order.get(key, 3), key)

report_dict = report.to_dict_lint()
sorted_report_dict = dict(
sorted(report_dict.items(), key=lambda item: custom_sort_key(item[0]))
)
linozen marked this conversation as resolved.
Show resolved Hide resolved

return json.dumps(
report.to_dict_lint(),
sorted_report_dict,
indent=2,
# Serialize sets to lists
default=custom_serializer,
sort_keys=True,
)


Expand Down
1 change: 1 addition & 0 deletions test
Submodule test added at 2703ff