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

#6992 Add SPDX checking for copyright/license (java) #7404

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

planetf1
Copy link
Member

@planetf1 planetf1 commented Feb 6, 2023

Signed-off-by: Nigel Jones nigel.l.jones [email protected]

Description

One of the missing aspects to the gradle build is SPDX header checking. There is a shortage of gradle plugins, or github actions.

My approximation so far is to use ‘checkstyle’ which allows specification of REGEXes which must match -for example one for copyright, one for license.

Due to the way the gradle build works, for now these only check java files.

In the process, I’ve noticed some omissions

  • Some files incorrectly use /* SPDX-License-Identifier: Apache 2.0 */ whilst it should be /* SPDX-License-Identifier: Apache-2.0 */ . Subtle, but it breaches the SPDX spec which specifically requires certain identifiers. There are over 2500 source files breaching this.
  • We do have a number, even of java, source files with no copyright, or incorrect ie typos. The most entertaining was in glossary author where we have /* Copyright Contributors to the ODPi Egeria category. */ where clearly a search/replace on project->category was done

Both are easy to fix, especially the former, (the latter is slightly more tedious) and I’m happy to do so, but it will result in thousands of file changes in a commit.

For now I can submit this additional check, ERROR will be reported in the output log, but will not fail the build.
Interesting that our previous maven based checks did not find these errors.

Related Issue(s)

Testing

Release Notes & Documentation

Additional notes

@planetf1
Copy link
Member Author

planetf1 commented Feb 6, 2023

Here's an example of the output in context:

Screenshot 2023-02-06 at 18 55 34

@planetf1
Copy link
Member Author

planetf1 commented Feb 6, 2023

Note - It's possible to customize the message given for a rule violation

@planetf1
Copy link
Member Author

planetf1 commented Feb 7, 2023

There is a 3rd party checkstyle plugin for intelliJ. This may make it easier to find issues in the UI.

Note that currently (with these rules) there are many errors ie

Checkstyle found 2,973 item(s) in 2,946 file(s)

@planetf1 planetf1 marked this pull request as ready for review February 7, 2023 09:31
@planetf1 planetf1 closed this Mar 2, 2023
@planetf1 planetf1 reopened this Mar 2, 2023
@planetf1
Copy link
Member Author

planetf1 commented Mar 7, 2023

This has been discussed in developer/tsc calls. No objects received so will now

  • merge this change using checkstyle to add WARNINGS into the build
  • raise new PRs to fix the warnings shown
  • raise PR to change from warning to error

@planetf1 planetf1 enabled auto-merge March 7, 2023 09:17
@planetf1 planetf1 merged commit eab9551 into odpi:main Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant