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

RAT-377: Create a STANDARD process filter like the ARCHIVE process switch in RAT-372 #249

Merged
merged 5 commits into from
May 14, 2024

Conversation

Claudenw
Copy link
Contributor

@Claudenw Claudenw commented May 9, 2024

Fixes RAT-377

This change is dependent upon RAT-372 and should not be considered for merged until after that change has been accepted.

The solution for process archive files (RAT-372) introduces a command line switch to change from just reporting the presence of archive files to reporting what licenses they contain or reporting licenses contains as well as missing licenses.

This request is for a similar change in STANDARD reporting.

The use case is for non-ASF projects that don't require a license header in every file but do require licensing to be declared within the project.

Using --standard PRESENCE would cause Rat to list all the declared licenses in the scan, without the overhead noise of 'missing license headers'

@Claudenw Claudenw marked this pull request as ready for review May 10, 2024 22:03
@Claudenw Claudenw requested a review from ottlinger May 10, 2024 22:03
@Claudenw Claudenw self-assigned this May 10, 2024
* Specify the processing of STANDARD files.
*/
static final Option STANDARD = Option.builder().longOpt("standard").hasArg().argName("ProcessingType")
.desc(format("Specifies the level of detail in STANDARD file reporting.. (default is %s)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double dot in this sentence - pls update the site template as well to keep it in sync with your changes.

@@ -74,25 +78,48 @@ public DefaultAnalyser(ReportConfiguration config, final Collection<ILicense> li
this.configuration = config;
}

/**
* Generates a predicateo to filter out licnses that should not be reported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LHF: typo predicateo / licnes

@@ -106,6 +104,7 @@ usage: java -jar apache-rat/target/apache-rat-${project.version}.jar
external xsl file may be specified or one of the internal named sheets: plain-rat (default),
missing-headers, or unapproved-licenses
--scan-hidden-directories Scan hidden directories
--standard <ProcessingType> Specifies the level of detail in STANDARD file reporting.. (default is ABSENCE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LHF: typo - double dot. Should the dot be at the end of the sentence.

@@ -72,6 +72,15 @@ https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd
</release>
-->
<release version="0.17-SNAPSHOT" date="xxxx-yy-zz" description="Current SNAPSHOT - release to be done">
<action issue="RAT-377" type="add" dev="claudenw">
Added ability to specify the leverl of reporting on STANDARD files within a project. This necessitated an addition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LHF: typo leverl ;) Sounds Austrian to my ear.

Copy link
Contributor

@ottlinger ottlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change ... apart from my minor things, looks good to me.

@Claudenw Claudenw requested a review from ottlinger May 13, 2024 05:00
@Claudenw
Copy link
Contributor Author

I had to rework some code to bring the errors down below the minimum. The net result is a much larger change. You may want to review the last commit. Please reapprove when you are satisfied.

lastMatch = null;
if (!checked) {
checked = true;
if (line.contains("SPDX-License-Identifier")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract this as a constant as it is used in line 62 as well, when defining the pattern?

@@ -75,7 +77,8 @@ public LicenseSetFactory(SortedSet<ILicense> licenses, Collection<String> approv
* @return An empty sorted set of ILicense objects.
*/
public static SortedSet<ILicense> emptyLicenseSet() {
return new TreeSet<>(ILicense.getComparator());
//return new TreeSet<>((a,b) -> a.getLicenseFamily().compareTo(b.getLicenseFamily()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LHF: rm old code

public static ILicense search(String licenseId, SortedSet<ILicense> licenses) {
ILicenseFamily searchFamily = ILicenseFamily.builder().setLicenseFamilyCategory(licenseId)
public static Optional<ILicense> search(String familyId, String licenseId, SortedSet<ILicense> licenses) {
// return licenses.stream().filter( l -> l.getId().equals(licenseId)).findFirst();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LHF: rm old code?

@@ -212,13 +221,14 @@ public IHeaderMatcher getMatcher() {

/**
* Search a SortedSet of licenses for the matching license.
* License must mach both family code, and license id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: mach / match

assertTrue(target.matches(AbstractMatcherTest.makeHeaders("SPDX-License-Identifier: hello", null)));
target.reset();
StringBuilder sb = new StringBuilder()
.append("SPDX-License-Identifier: world").append(System.lineSeparator())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constant from above could be used in these tests as well.

Copy link
Contributor

@ottlinger ottlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of the spotbugs findings, only minor things marked in this review run. Thanks again!

@Claudenw Claudenw merged commit 398735f into apache:master May 14, 2024
16 checks passed
@Claudenw Claudenw deleted the create_standard_process branch May 14, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants