Compare commits
4
Commits
727e6ad896
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1e3e960b1
|
||
|
|
85ca793893
|
||
|
|
0ccffb0642
|
||
|
|
1fe7ce65f6
|
@@ -4,12 +4,10 @@ on:
|
||||
branches: [ master ]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: hostinger
|
||||
runs-on: woryzen
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
- name: Execute Gradle build
|
||||
env:
|
||||
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
||||
|
||||
+38
-5
@@ -1,19 +1,51 @@
|
||||
package net.woggioni.finalguard;
|
||||
|
||||
import com.sun.source.tree.*;
|
||||
import com.sun.source.util.*;
|
||||
import com.sun.source.tree.AssignmentTree;
|
||||
import com.sun.source.tree.BlockTree;
|
||||
import com.sun.source.tree.CatchTree;
|
||||
import com.sun.source.tree.CompilationUnitTree;
|
||||
import com.sun.source.tree.CompoundAssignmentTree;
|
||||
import com.sun.source.tree.EnhancedForLoopTree;
|
||||
import com.sun.source.tree.ForLoopTree;
|
||||
import com.sun.source.tree.IdentifierTree;
|
||||
import com.sun.source.tree.LambdaExpressionTree;
|
||||
import com.sun.source.tree.MethodTree;
|
||||
import com.sun.source.tree.Tree;
|
||||
import com.sun.source.tree.TryTree;
|
||||
import com.sun.source.tree.UnaryTree;
|
||||
import com.sun.source.tree.VariableTree;
|
||||
import com.sun.source.util.JavacTask;
|
||||
import com.sun.source.util.Plugin;
|
||||
import com.sun.source.util.TaskEvent;
|
||||
import com.sun.source.util.TaskListener;
|
||||
import com.sun.source.util.TreePath;
|
||||
import com.sun.source.util.TreePathScanner;
|
||||
import com.sun.source.util.Trees;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.tools.Diagnostic;
|
||||
import java.util.*;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FinalGuardPlugin implements Plugin {
|
||||
public static final String DEFAULT_LEVEL_KEY = "default.level";
|
||||
public static final String EXCLUDE_KEY = "exclude";
|
||||
public static final String IGNORE_ABSTRACT_METHOD_PARAMS_KEY = "net.woggioni.finalguard.ignore.abstract.method.params";
|
||||
|
||||
enum VariableType {
|
||||
LOCAL_VAR("local.variable.level"),
|
||||
METHOD_PARAM("method.param.level"),
|
||||
@@ -75,7 +107,8 @@ public class FinalGuardPlugin implements Plugin {
|
||||
final String[] parts = arg.split("=", 2);
|
||||
if (parts.length == 2) {
|
||||
if (EXCLUDE_KEY.equals(parts[0])) {
|
||||
excluded.add(parts[1]);
|
||||
final Path path = Paths.get(parts[1]);
|
||||
excluded.add(path.toAbsolutePath().toString());
|
||||
} else {
|
||||
props.put(parts[0], parts[1]);
|
||||
}
|
||||
|
||||
+5
-1
@@ -154,7 +154,11 @@ public class PluginTest {
|
||||
)),
|
||||
Arguments.of(prefix + "TestCase12.java", Collections.emptyList()),
|
||||
Arguments.of(prefix + "TestCase13.java", Arrays.asList(ABSTRACT_METHOD_PARAM.getMessage("x"), ABSTRACT_METHOD_PARAM.getMessage("y"))),
|
||||
Arguments.of(prefix + "TestCase14.java", Arrays.asList(ABSTRACT_METHOD_PARAM.getMessage("x"), ABSTRACT_METHOD_PARAM.getMessage("y")))
|
||||
Arguments.of(prefix + "TestCase14.java", Arrays.asList(ABSTRACT_METHOD_PARAM.getMessage("x"), ABSTRACT_METHOD_PARAM.getMessage("y"))),
|
||||
Arguments.of(prefix + "TestCase15.java",
|
||||
Arrays.asList(
|
||||
LOCAL_VAR.getMessage("a"),
|
||||
METHOD_PARAM.getMessage("source")))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TestCase15 {
|
||||
public static void foo() {
|
||||
final InputStream source = null;
|
||||
final InputStream is = new FilterInputStream(source) {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int a = 5;
|
||||
return a;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static class Bar extends FilterInputStream {
|
||||
|
||||
public Bar(InputStream source) {
|
||||
super(source);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class FinalGuardPlugin implements Plugin<Project> {
|
||||
appendOption(xpluginArg, "catch.param.level", finalGuardExtension.getCatchParameterLevel());
|
||||
appendOption(xpluginArg, "lambda.param.level", finalGuardExtension.getLambdaParameterLevel());
|
||||
if (finalGuardExtension.getSkipGeneratedSources().getOrElse(true)) {
|
||||
final File generatedSourceDir = options.getGeneratedSourceOutputDirectory().getAsFile().getOrNull();
|
||||
final File generatedSourceDir = project.getLayout().getBuildDirectory().getAsFile().get();
|
||||
if (generatedSourceDir != null) {
|
||||
appendOption(xpluginArg, EXCLUDE_KEY, generatedSourceDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
lys.catalog.version=2025.12.27
|
||||
version.myGradlePlugins=2026.02.17
|
||||
version.myGradlePlugins=2026.02.23
|
||||
version.gradle=9.3.1
|
||||
|
||||
gitea.maven.url = https://gitea.woggioni.net/api/packages/woggioni/maven
|
||||
|
||||
@@ -2,6 +2,12 @@ plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility(JavaVersion.VERSION_1_8.toString())
|
||||
targetCompatibility(JavaVersion.VERSION_1_8.toString())
|
||||
modularity.inferModulePath = false
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("JPMSCheckPlugin") {
|
||||
|
||||
Reference in New Issue
Block a user