Skip to content

dependency: bump org.gaul:modernizer-maven-plugin from 2.9.0 to 3.0.0#16095

Merged
romani merged 1 commit into
masterfrom
dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0
Jan 14, 2025
Merged

dependency: bump org.gaul:modernizer-maven-plugin from 2.9.0 to 3.0.0#16095
romani merged 1 commit into
masterfrom
dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Dec 30, 2024

Copy link
Copy Markdown
Contributor

Bumps org.gaul:modernizer-maven-plugin from 2.9.0 to 3.0.0.

Release notes

Sourced from org.gaul:modernizer-maven-plugin's releases.

Modernizer Maven Plugin 3.0.0

  • Add File violations, #301
  • Add violation for ByteStreams.toByteArray
  • Add violation for StringReader, #291
  • Add violations for Maps and Sets with expected size, #258
  • Rework pom.xml structure, #263, #264
  • Upgrade to asm 9.7.1 for Java 24 compatibility, #286

Thanks @​cstamas and @​mkarg for sending pull requests to improve Modernizer!

Commits
  • 29746e7 modernizer-maven-plugin 3.0.0 release
  • 2c6c8b9 Add missing url and description
  • bc5061a Add nexus-staging-maven-plugin
  • c2042e3 ci.yml: Java 8 -> Java11
  • 243a9a9 Do not ask people to stick with java.io.FileWriter in Java 11 when asking peo...
  • f2f1b8c fixup! Add violation for FileReader
  • 507d6c0 Tests for File, Paths, FileInputStream, FileOutputStream, FileReader and File...
  • e457fad Add violation for FileWriter
  • 53f81ce Do not ask people to stick with java.io.FileReader in Java 11 when asking peo...
  • 964d4cc Add violation for FileReader
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot Bot added dependencies Pull requests that update a dependency file java Pull requests that update Java code labels Dec 30, 2024
@romani

romani commented Dec 30, 2024

Copy link
Copy Markdown
Member

Hmmm

All violations are same type
https://ci.appveyor.com/project/Checkstyle/checkstyle/builds/51243757/job/11ofykje5pdh6pet#L1849

[INFO] --- modernizer-maven-plugin:3.0.0:modernizer (modernizer) @ checkstyle ---
[ERROR] C:\projects\checkstyle\src\main\java\com\puppycrawl\tools\checkstyle\
ant\CheckstyleAntTask.java:491: 
Prefer java.nio.file.Paths.get(String)

Here are details gaul/modernizer-maven-plugin#301

@Bananeweizen

Bananeweizen commented Dec 31, 2024

Copy link
Copy Markdown
Contributor

for anyone working on this change, please DON'T use Paths.get(...) when refactoring, but rather Path.of(...). See the javadoc of Paths.get(...) and gaul/modernizer-maven-plugin#303

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from eb7ae6d to 520a366 Compare January 3, 2025 22:50
@romani romani added the blocked label Jan 3, 2025
@romani

romani commented Jan 3, 2025

Copy link
Copy Markdown
Member

blocked by gaul/modernizer-maven-plugin#303

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 520a366 to 2c9b323 Compare January 4, 2025 15:41
@romani romani removed the blocked label Jan 4, 2025
@romani

romani commented Jan 4, 2025

Copy link
Copy Markdown
Member
[ERROR] com.puppycrawl.tools.checkstyle.utils.CommonUtilTest.testGetUriByFilenameClasspathPrefixLoadConfig -- Time elapsed: 0 s <<< ERROR!
java.nio.file.InvalidPathException: Illegal char <:> at index 9: classpath:com/puppycrawl/tools/checkstyle/utils/commonutil/InputCommonUtilTestWithChecks.xml
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getFilepathOrClasspathUri(CommonUtil.java:394)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getUriByFilename(CommonUtil.java:358)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtilTest.testGetUriByFilenameClasspathPrefixLoadConfig(CommonUtilTest.java:546)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
[ERROR] com.puppycrawl.tools.checkstyle.utils.CommonUtilTest.testGetUriByFilenameFindsRelativeResourceOnClasspathPrefix -- Time elapsed: 0 s <<< ERROR!
java.nio.file.InvalidPathException: Illegal char <:> at index 9: classpath:com/puppycrawl/tools/checkstyle/utils/commonutil/InputCommonUtilTest_empty_checks.xml
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getFilepathOrClasspathUri(CommonUtil.java:394)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getUriByFilename(CommonUtil.java:358)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtilTest.testGetUriByFilenameFindsRelativeResourceOnClasspathPrefix(CommonUtilTest.java:560)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)

<<< ERROR!
java.nio.file.InvalidPathException: Illegal char <:> at index 4: http://^%$^* %&% %^&
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getFilepathOrClasspathUri(CommonUtil.java:394)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.getUriByFilename(CommonUtil.java:358)
	at com.puppycrawl.tools.checkstyle.utils.CommonUtil.sourceFromFilename(CommonUtil.java:343)
	at com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader.loadSuppressions(SuppressionsLoader.java:220)
	at com.puppycrawl.tools.checkstyle.filters.SuppressionsLoaderTest.testLoadFromNonExistentUrl(SuppressionsLoaderTest.java:100)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
[

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 2c9b323 to 7434ad3 Compare January 4, 2025 17:27
@romani

romani commented Jan 4, 2025

Copy link
Copy Markdown
Member
diff --git a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml b/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
index fe7ca14..1edf78d 100644
--- a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
+++ b/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml
@@ -4222,6 +4222,[13](https://github.com/checkstyle/checkstyle/actions/runs/12611739184/job/35147701899?pr=16095#step:7:14) @@
     </details>
   </checkerFrameworkError>
 
+  <checkerFrameworkError unstable="false">
+    <fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheck.java</fileName>
+    <specifier>dereference.of.nullable</specifier>
+    <message>dereference of possibly-null reference dir</message>
+    <lineContent>final File packageInfo = Path.of(dir.getPath(), &quot;package-info.java&quot;).toFile();</lineContent>
+  </checkerFrameworkError>
+
   <checkerFrameworkError unstable="false">
     <fileName>src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheck.java</fileName>
     <specifier>method.invocation</specifier>
EOF

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 7434ad3 to 833b3fc Compare January 4, 2025 17:32
@mkarg

mkarg commented Jan 4, 2025

Copy link
Copy Markdown

The target is to get rid of the File class. Wherever you see java.io.File get rid of it.

// oops, we've got an additional one to process, don't
// forget it. No sweat, it's fully resolved via the setter.
log("Adding standalone file for audit", Project.MSG_VERBOSE);
allFiles.add(new File(fileName));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Either return List<Path> (preferrable, if consumer is on Java 7+), otherwise (and only then) stick with new File(fileName) but annotate the code line to be ignored by Modernizer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Windows test execution is failing, so update is not that trivial.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wherever you see java.io.File get rid of it.

Hmmm, looks like we need to do this in phases, too much to change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Modernizing is a non-trivial task, typically, and Modernizer ist just a trigger to think over the solution - it does not provide it. ;-)

@romani romani Jan 5, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mkarg , do you know how to make suppression annotation to work ?

    @SuppressWarnings("modernizer")
    private static URI getFilepathOrClasspathUri(String filename) throws CheckstyleException {

I pushed this to PR ... but it is ignored, I tried on class - ignored, on variable - ignored. Ignored means still violation present.

✔ ~/java/github/checkstyle/checkstyle [dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0|✔] 
$ mvn modernizer:modernizer
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] 
[INFO] ------------------< com.puppycrawl.tools:checkstyle >-------------------
[INFO] Building checkstyle 10.21.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- modernizer-maven-plugin:3.0.0:modernizer (default-cli) @ checkstyle ---
[ERROR] /home/rivanov/java/github/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java:396: Prefer java.nio.file.Paths.get(String)

@SuppressModernizer is not an option as it will extend dependencies, we are library project we do not do this easily.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@romani

what is wrong with this update allFiles.add(Paths.get(fileName).toFile()); ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CI failure #16095 (comment)

We need someone with Windows to figure out a reason and do workaround in test implementation

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@romani

what is wrong with this update allFiles.add(Paths.get(fileName).toFile()); ?

Nothing, as long as you are on Java 7...10; on Java 11+ replace Paths.get by Path.of.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mkarg , do you know how to make suppression annotation to work ?

    @SuppressWarnings("modernizer")
    private static URI getFilepathOrClasspathUri(String filename) throws CheckstyleException {

I pushed this to PR ... but it is ignored, I tried on class - ignored, on variable - ignored. Ignored means still violation present.

✔ ~/java/github/checkstyle/checkstyle [dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0|✔] 
$ mvn modernizer:modernizer
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] 
[INFO] ------------------< com.puppycrawl.tools:checkstyle >-------------------
[INFO] Building checkstyle 10.21.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- modernizer-maven-plugin:3.0.0:modernizer (default-cli) @ checkstyle ---
[ERROR] /home/rivanov/java/github/checkstyle/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java:396: Prefer java.nio.file.Paths.get(String)

@SuppressModernizer is not an option as it will extend dependencies, we are library project we do not do this easily.

This is not supported yet. Feel free to post a PR if needed.

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 833b3fc to d434230 Compare January 5, 2025 16:22
final List<Integer> result = new ArrayList<>();
try (BufferedReader br = Files.newBufferedReader(
Paths.get(aFileName), StandardCharsets.UTF_8)) {
Path.of(aFileName), StandardCharsets.UTF_8)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Paths.html#get(java.net.URI)

public static Path get(URI uri)
Converts the given URI to a Path object.
Implementation Requirements:
This method simply invokes Path.of(URI) with the given parameter.

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from d434230 to 28b7d06 Compare January 12, 2025 14:51
@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 28b7d06 to ec95fdb Compare January 12, 2025 23:19
@romani

romani commented Jan 13, 2025

Copy link
Copy Markdown
Member
$ mvn modernizer:3.0.0:modernizer 
....
INFO] --- modernizer-maven-plugin:3.0.0:modernizer (modernizer) @ checkstyle ---
[ERROR] ....\ant\CheckstyleAntTask.java:491: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\ant\CheckstyleAntTask.java:534: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\filters\SuppressWithNearbyTextFilter.java:229: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\filters\SuppressWithPlainTextCommentFilter.java:224: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\gui\Main.java:57: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\meta\XmlMetaWriter.java:188: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\PropertiesMacro.java:137: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\PropertiesMacro.java:115: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:321: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:322: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:323: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:324: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:325: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:326: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:327: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:328: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:329: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:330: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:331: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:332: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\SiteUtil.java:333: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\site\SiteUtil.java:334: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\site\XdocsTemplateParser.java:182: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\utils\CheckUtil.java:566: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\utils\CommonUtil.java:395: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\utils\CommonUtil.java:488: Prefer java.nio.file.Paths.get(String)
[ERROR] ....\utils\CommonUtil.java:511: Prefer java.nio.file.Path.of(String, String...)
[ERROR] ....\XpathFileGeneratorAuditListener.java:99: Prefer java.nio.file.Paths.get(String)
....
Found 28 violations

@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from f792590 to 545327b Compare January 14, 2025 14:16
Bumps commons-beanutils:commons-beanutils from 1.9.4 to 1.10.0.

---
updated-dependencies:
- dependency-name: commons-beanutils:commons-beanutils
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@romani romani force-pushed the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch from 545327b to ee60147 Compare January 14, 2025 14:37
Comment thread pom.xml
<exclusionPattern>java/util/Optional.get:.*</exclusionPattern>
<!-- until https://github.com/gaul/modernizer-maven-plugin/issues/318 -->
<exclusionPattern>java/io/File.*</exclusionPattern>
<exclusionPattern>java/nio/file/Paths.get:.*</exclusionPattern>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was not able to find way to suppress violation on
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java:321: Prefer java.nio.file.Path.of(String, String...) by exact match to pattern, so falled back to regexp. kind of suppress all, unfortunate.

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not ideal , but we moving forward.

Migration to nio API will be continuing at #16155

@romani romani merged commit 64e2339 into master Jan 14, 2025
@romani romani deleted the dependabot/maven/org.gaul-modernizer-maven-plugin-3.0.0 branch January 14, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants