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

Added -e flag to exclude repair of a file containing DO NOT ALTER OR REMOVE COPYRIGHT NOTICES #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cesarhernandezgt
Copy link

@cesarhernandezgt cesarhernandezgt commented May 2, 2020

Fixes #9
How to test this PR:

  1. mvn clean install
  2. Assuming you are using command line execution with maven installed in ~
$ java -cp  ~/.m2/repository/org/glassfish/copyright/glassfish-copyright-maven-plugin/2.4-SNAPSHOT/glassfish-copyright-maven-plugin-2.4-SNAPSHOT.jar org.glassfish.copyright.Copyright -c -r -e /Users/cesar/git/jakartaee-tck/lib/schemas/connector_1_5.xsd
  1. The output would be:
/Users/cesar/git/jakartaee-tck/lib/schemas/connector_1_5.xsd: WARNING: contains:       DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
/Users/cesar/git/jakartaee-tck/lib/schemas/connector_1_5.xsd: WARNING: extra copyright:       Copyright 2003-2007 Sun Microsystems, Inc. All rights reserved.
/Users/cesar/git/jakartaee-tck/lib/schemas/connector_1_5.xsd:  SKIPPED: it contains: DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

The repair is not applied if the file contains the Do not alter or remove notices.

…REMOVE COPYRIGHT NOTICES

Signed-off-by: CesarHernandezGt <[email protected]>
@scottmarlow
Copy link
Member

I noticed that this project uses tab instead of spaces, not sure if that is an issue for this pr.

Copy link

@kwsutter kwsutter left a comment

Choose a reason for hiding this comment

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

I think the main issue is the indentation. I didn't mark every occurrence via this review, but I think you'll get the picture. Thanks.

@@ -93,6 +95,8 @@
private static Pattern bsdpat = Pattern.compile(
"(THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS)"+
"|(SPDX-License-Identifier: BSD-3-Clause)", Pattern.MULTILINE);
// patter to detect DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copy link

Choose a reason for hiding this comment

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

nit typo: "pattern"

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 620fdb2

if (c.warn && !c.quiet)
warnCopyright(file, r);
if (c.warn && !c.quiet){
warnCopyright(file, r);
Copy link

Choose a reason for hiding this comment

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

Formatting doesn't look right. Are you using tabs or spaces (preferred)?

if (c.warn && !c.quiet)
warnCopyright(file, r);
if (c.warn && !c.quiet){
warnCopyright(file, r);
Copy link

Choose a reason for hiding this comment

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

Formatting doesn't look right. Are you using tabs or spaces (preferred)? Way too much indentation.

@@ -332,7 +345,24 @@ else if (lc == null)
System.out.println("No errors: " + file);
}

/**
/**
Copy link

Choose a reason for hiding this comment

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

Indentation problem again?

@@ -332,7 +345,24 @@ else if (lc == null)
System.out.println("No errors: " + file);
}

/**
/**
* Verifies if he file contains the message:
Copy link

Choose a reason for hiding this comment

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

nit typo: "if the file.."

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 620fdb2

@@ -39,6 +39,7 @@
* -x check XML syntax files
* -p check properties syntax files
* -t check other text files
* -e exclude files that contains DO NOT ALTER OR REMOVE COPYRIGHT NOTICES
Copy link

Choose a reason for hiding this comment

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

indentation again...

@@ -93,6 +95,8 @@
private static Pattern bsdpat = Pattern.compile(
"(THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS)"+
"|(SPDX-License-Identifier: BSD-3-Clause)", Pattern.MULTILINE);
// patter to detect DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
protected static Pattern dontpat = Pattern.compile(DONT_ALTER_HEADER);
Copy link

Choose a reason for hiding this comment

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

Personally, I'd make this variable name a little easier to understand and readable. I know you were just following the pattern for the "bsdpat" variable, but I would think something like "doNotAlterPattern" would be clearer. I'll leave it to you though.

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 620fdb2

@kwsutter
Copy link

kwsutter commented May 4, 2020

I noticed that this project uses tab instead of spaces, not sure if that is an issue for this pr.

I agree, Scott. Spaces should be used instead of tabs.

@romain-grecourt
Copy link
Member

IIRC all the sources in this project are formatted with tabs. CC @bshannon

@arjantijms
Copy link
Contributor

IIRC all the sources in this project are formatted with tabs. CC @bshannon

According to the Jakarta Code Convention it should indeed be spaces. Although we had it in words once (it was lost during a wiki transfer, and should be redone), it's in code here:

https://github.com/eclipse-ee4j/ee4j/tree/master/codestyle

@romain-grecourt
Copy link
Member

I'm not disagreeing with the rules :) This project was donated as-is and not converted to spaces. @bshannon is the original author, I just wanted to make sure he knows about this discussion.

@cesarhernandezgt
Copy link
Author

Thank you for the review so far. I'll polish the variable name and fix the typos during the week.

About the space vs tab, I don't have any strong opinion. My proposal would be:

  1. Convert the current PR spaces to tabs in order to comply with the current project code format.
  2. If we all agree that the project will follow the ee4j codestyle, I would vote to do this on a separate PR in order to keep the scope of current PR focused on the new flag.

@cesarhernandezgt
Copy link
Author

cesarhernandezgt commented May 8, 2020

Thanks for the review so far.
In 620fdb2 I ended up importing https://github.com/eclipse-ee4j/ee4j/blob/master/codestyle/ee4j_intellij_formatting.xml and then applying a cmd+l to allow the IDE to auto-format the code.

As you can check that didn't resolve the majority of the indentation issues.
Then in 923b4e0 and 39e6c63 I disable in my IDE the "Detect and use existing file indents for editing" option and give a try again using the imported code format.
Hope this time it's better.

@bshannon
Copy link
Contributor

IIRC all the sources in this project are formatted with tabs. CC @bshannon

Rule # 0 - follow the existing project conventions.
Rule #1 - use new project conventions for substantial new code.

Bottom line, please don't change it.

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.

Do not alter Copyright notice in files that contain "DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER"
6 participants