rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

Add support for MethodParamPadding to java style auto-detection

Open pway99 opened this issue 1 year ago • 1 comments

Issue discovered with src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java

Problem

Error: src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java:[494] (sizes) LineLength: Line is longer than 120 characters (found 124). Error: src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java:[494,84] (whitespace) ParenPad: '(' is not followed by whitespace. Error: src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java:[494,122] (whitespace) ParenPad: ')' is not preceded with whitespace.

Expected behavior

Method Parameter Padding and Line Lenght style violations should not fail

Example diff

         {
             try
             {
-                if ( sourceDirectoryToCheck.getCanonicalPath().startsWith( excludeDir.getCanonicalPath() ) )
+                if ( sourceDirectoryToCheck.getCanonicalFile().toPath().startsWith(excludeDir.getCanonicalFile().toPath()) )
                 {
                     getLog().debug( "Directory " + sourceDirectoryToCheck.getAbsolutePath()
                                         + " has been excluded as it matches excludeRoot "

https://github.com/apache/maven-build-cache-extension/blob/master/src/main/java/org/apache/maven/buildcache/CacheUtils.java

             while ( entry != null )
             {
                 Path file = out.resolve( entry.getName() );
+                if (!file.normalize().startsWith(out.normalize())) {
+                    throw new RuntimeException("Bad zip entry");
+                }
                 if ( entry.isDirectory() )
                 {
                     Files.createDirectory( file );

Recipes in example diff:

  • org.openrewrite.java.security.PartialPathTraversalVulnerability

References:

  • Recipe ID: undefined
  • Recipe Name: "Partial path traversal vulnerability"
  • Repository: apache/maven-pmd-plugin/master
  • Created at Fri Jul 29 2022 07:21:08 GMT-0700 (Pacific Daylight Time)

pway99 avatar Jul 29 '22 14:07 pway99

Still requires update for AutoDecting Spaces#Within.MethodCallParentheses

pway99 avatar Aug 04 '22 00:08 pway99