Skip to content

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

Open
cesarhernandezgt wants to merge 4 commits into
eclipse-ee4j:masterfrom
cesarhernandezgt:issue-9
Open

cesarhernandezgt wants to merge 4 commits into
eclipse-ee4j:masterfrom
cesarhernandezgt:issue-9

Conversation

@cesarhernandezgt

@cesarhernandezgt cesarhernandezgt commented May 2, 2020 •

Copy link
Copy Markdown

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 <chernandez@tomitribe.com>
@scottmarlow

Copy link
Copy Markdown
Member

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

@kwsutter kwsutter left a comment

Copy link
Copy Markdown

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.

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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.

}

/**
/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indentation problem again?


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

Copy link
Copy Markdown

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in 620fdb2

* -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
Copy Markdown

Choose a reason for hiding this comment

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

indentation again...

"(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
Copy Markdown

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
Copy Markdown
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

kwsutter commented May 4, 2020

Copy link
Copy Markdown

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
Copy Markdown
Member

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

@arjantijms

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Signed-off-by: CesarHernandezGt <chernandez@tomitribe.com>
…or editing

Signed-off-by: CesarHernandezGt <chernandez@tomitribe.com>
Signed-off-by: CesarHernandezGt <chernandez@tomitribe.com>
@cesarhernandezgt

cesarhernandezgt commented May 8, 2020 •

Copy link
Copy Markdown
Author

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
Copy Markdown
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