From 8cf80dbf89334498111ba00606e444b493990015 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 2 Apr 2025 12:30:35 +0000 Subject: [PATCH 01/82] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 117762d3e6f..27ce2365290 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.puppycrawl.tools checkstyle - 10.23.0 + 10.23.1-SNAPSHOT jar checkstyle From 752f3f9f1d1defd86ef0320e2598aa94f4d40c0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 21:16:41 +0000 Subject: [PATCH 02/82] dependency: bump checkerframework.version from 3.49.1 to 3.49.2 Bumps `checkerframework.version` from 3.49.1 to 3.49.2. Updates `org.checkerframework:checker-qual` from 3.49.1 to 3.49.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.1...checker-framework-3.49.2) Updates `org.checkerframework:checker` from 3.49.1 to 3.49.2 - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.49.1...checker-framework-3.49.2) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-version: 3.49.2 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.checkerframework:checker dependency-version: 3.49.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../checker-lock-tainting-suppressions.xml | 28 +++ ...er-methods-resource-fenum-suppressions.xml | 204 +++++------------- ...llness-optional-interning-suppressions.xml | 47 +++- pom.xml | 2 +- 4 files changed, 124 insertions(+), 157 deletions(-) diff --git a/config/checker-framework-suppressions/checker-lock-tainting-suppressions.xml b/config/checker-framework-suppressions/checker-lock-tainting-suppressions.xml index 4214831d955..2d1113b8753 100644 --- a/config/checker-framework-suppressions/checker-lock-tainting-suppressions.xml +++ b/config/checker-framework-suppressions/checker-lock-tainting-suppressions.xml @@ -437,6 +437,9 @@ Stream.iterate(startNode.getLastChild(), Objects::nonNull,
unsatisfiable constraint: @GuardedBy DetailAST <: @GuardSatisfied Object + use of T from Stream.iterate(startNode.getLastChild(), Objects::nonNull, DetailAST::getPreviousSibling) <: @GuardSatisfied Object + From complementary bound.: Objects::nonNull -> inference type: java.util.function.Predicate<? super T> + From: Argument constraint
@@ -447,6 +450,8 @@ .map(children::indexOf);
unsatisfiable constraint: @GuardedBy DetailAST <: @GuardSatisfied Object + children::indexOf -> inference type: java.util.function.Function<? super com.puppycrawl.tools.checkstyle.api.DetailAST,? extends U> + From: Argument constraint
@@ -472,6 +477,9 @@ result = Stream.iterate(nonCommentAst.getPreviousSibling(),
unsatisfiable constraint: @GuardedBy DetailAST <: @GuardSatisfied Object + use of T from Stream.iterate(nonCommentAst.getPreviousSibling(), Objects::nonNull, DetailAST::getPreviousSibling) <: @GuardSatisfied Object + From complementary bound.: Objects::nonNull -> inference type: java.util.function.Predicate<? super T> + From: Argument constraint
@@ -571,6 +579,9 @@ .collect(Collectors.joining(", ")),
unsatisfiable constraint: @GuardedBy String <: @GuardSatisfied Object + use of R from missingRequiredTokenNames.stream().map(String::valueOf).collect(Collectors.joining(", ")) <: @GuardSatisfied Object + From complementary bound.: use of R from missingRequiredTokenNames.stream().map(String::valueOf).collect(Collectors.joining(", ")) -> @GuardSatisfied Object + From: Constraint between method call type and target type for method call:missingRequiredTokenNames.stream().map(String::valueOf).collect(Collectors.joining(", "))
@@ -677,6 +688,9 @@ Stream.iterate(
unsatisfiable constraint: @GuardedBy DetailAST <: @GuardSatisfied Object + use of T from Stream.iterate(node.getLastChild(), Objects::nonNull, DetailAST::getPreviousSibling) <: @GuardSatisfied Object + From complementary bound.: Objects::nonNull -> inference type: java.util.function.Predicate<? super T> + From: Argument constraint
@@ -1360,6 +1374,10 @@ .collect(BitSet::new, BitSet::set, BitSet::or);
unsatisfiable constraint: @GuardedBy BitSet <: @GuardSatisfied BitSet + @GuardedBy BitSet <: use of R from Arrays.stream(tokens).map(String::trim).filter(Predicate.not(String::isEmpty)).mapToInt(TokenUtil::getTokenId).collect(BitSet::new, BitSet::set, BitSet::or) + From complementary bound.: @GuardedBy BitSet -> use of R from Arrays.stream(tokens).map(String::trim).filter(Predicate.not(String::isEmpty)).mapToInt(TokenUtil::getTokenId).collect(BitSet::new, BitSet::set, BitSet::or) + BitSet::new -> inference type: java.util.function.Supplier<R> + From: Argument constraint
@@ -1370,6 +1388,10 @@ .collect(BitSet::new, BitSet::set, BitSet::or);
unsatisfiable constraint: @GuardedBy BitSet <: @GuardSatisfied BitSet + @GuardedBy BitSet <: use of R from IntStream.of(tokens).collect(BitSet::new, BitSet::set, BitSet::or) + From complementary bound.: @GuardedBy BitSet -> use of R from IntStream.of(tokens).collect(BitSet::new, BitSet::set, BitSet::or) + BitSet::new -> inference type: java.util.function.Supplier<R> + From: Argument constraint
@@ -1380,6 +1402,12 @@ .collect(Collectors.toUnmodifiableMap(
unsatisfiable constraint: @GuardedBy Field <: @GuardSatisfied Field + @GuardedBy Field <: use of T from Collectors.toUnmodifiableMap(Field::getName, (fld)->getIntFromField(fld, null)) + From complementary bound.: @GuardedBy Field <: use of captured T from Collectors.toUnmodifiableMap(Field::getName, (fld)->getIntFromField(fld, null)) + From complementary bound.: use of captured T from Collectors.toUnmodifiableMap(Field::getName, (fld)->getIntFromField(fld, null)) <= ? extends @GuardedBy Object super @GuardedBy Field + inference type: java.util.stream.Collector<T,A,R> <: inference type: java.util.stream.Collector<? super java.lang.reflect.Field,A,R> + inference type: java.util.stream.Collector<T,A,R> -> inference type: java.util.stream.Collector<? super java.lang.reflect.Field,A,R> + From: Captured constraint from method call: Collectors.toUnmodifiableMap(Field::getName, (fld)->getIntFromField(fld, null))
diff --git a/config/checker-framework-suppressions/checker-methods-resource-fenum-suppressions.xml b/config/checker-framework-suppressions/checker-methods-resource-fenum-suppressions.xml index ada00f50579..cdfd767131e 100644 --- a/config/checker-framework-suppressions/checker-methods-resource-fenum-suppressions.xml +++ b/config/checker-framework-suppressions/checker-methods-resource-fenum-suppressions.xml @@ -3,23 +3,15 @@ src/main/java/com/puppycrawl/tools/checkstyle/Main.java required.method.not.called - @MustCall method close may not have been invoked on getOutputStream(options.outputPath) or any of its aliases. - listener = new XpathFileGeneratorAuditListener(getOutputStream(options.outputPath), -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + final OutputStream out = getOutputStream(outputLocation);
src/main/java/com/puppycrawl/tools/checkstyle/Main.java required.method.not.called - @MustCall method close may not have been invoked on out or any of its aliases. - final OutputStream out = getOutputStream(outputLocation); -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: possible exceptional exit due to format.createListener(out, closeOutputStreamOption) with exception type java.io.IOException -
+ (required.method.not.called) + listener = new XpathFileGeneratorAuditListener(getOutputStream(options.outputPath),
@@ -36,111 +28,71 @@ src/main/java/com/puppycrawl/tools/checkstyle/XmlLoader.java required.method.not.called - @MustCall method close may not have been invoked on dtdIs or any of its aliases. + (required.method.not.called) final InputStream dtdIs = loader.getResourceAsStream(dtdResourceName); -
- The type of object is: java.io.InputStream. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on Files.newOutputStream(toFile.toPath()) or any of its aliases. - sarifLogger = new SarifLogger(Files.newOutputStream(toFile.toPath()), -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: possible exceptional exit due to new SarifLogger(Files.newOutputStream(toFile.toPath()), OutputStreamOptions.CLOSE) with exception type java.io.IOException -
+ (required.method.not.called) + final OutputStream debug = new LogOutputStream(this, Project.MSG_DEBUG);
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on Files.newOutputStream(toFile.toPath()) or any of its aliases. - xmlLogger = new XMLLogger(Files.newOutputStream(toFile.toPath()), -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + final OutputStream err = new LogOutputStream(this, Project.MSG_ERR);
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on debug or any of its aliases. - final OutputStream debug = new LogOutputStream(this, Project.MSG_DEBUG); -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + final OutputStream infoStream = Files.newOutputStream(toFile.toPath());
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on err or any of its aliases. - final OutputStream err = new LogOutputStream(this, Project.MSG_ERR); -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + new LogOutputStream(task, Project.MSG_DEBUG),
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on infoStream or any of its aliases. - final OutputStream infoStream = Files.newOutputStream(toFile.toPath()); -
- The type of object is: java.io.OutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + new LogOutputStream(task, Project.MSG_ERR),
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on new LogOutputStream(task, Project.MSG_DEBUG) or any of its aliases. - new LogOutputStream(task, Project.MSG_DEBUG), -
- The type of object is: org.apache.tools.ant.taskdefs.LogOutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + sarifLogger = new SarifLogger(Files.newOutputStream(toFile.toPath()),
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on new LogOutputStream(task, Project.MSG_ERR) or any of its aliases. - new LogOutputStream(task, Project.MSG_ERR), -
- The type of object is: org.apache.tools.ant.taskdefs.LogOutputStream. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + sarifLogger = new SarifLogger(new LogOutputStream(task, Project.MSG_INFO),
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on new LogOutputStream(task, Project.MSG_INFO) or any of its aliases. - sarifLogger = new SarifLogger(new LogOutputStream(task, Project.MSG_INFO), -
- The type of object is: org.apache.tools.ant.taskdefs.LogOutputStream. - Reason for going out of scope: possible exceptional exit due to new SarifLogger(new LogOutputStream(task, Project.MSG_INFO), OutputStreamOptions.CLOSE) with exception type java.io.IOException -
+ (required.method.not.called) + xmlLogger = new XMLLogger(Files.newOutputStream(toFile.toPath()),
src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java required.method.not.called - @MustCall method close may not have been invoked on new LogOutputStream(task, Project.MSG_INFO) or any of its aliases. + (required.method.not.called) xmlLogger = new XMLLogger(new LogOutputStream(task, Project.MSG_INFO), -
- The type of object is: org.apache.tools.ant.taskdefs.LogOutputStream. - Reason for going out of scope: regular method exit -
@@ -168,12 +120,8 @@ src/main/java/com/puppycrawl/tools/checkstyle/meta/XmlMetaReader.java required.method.not.called - @MustCall method close may not have been invoked on XmlMetaReader.class.getResourceAsStream("/" + fileName) or any of its aliases. + (required.method.not.called) moduleDetails = read(XmlMetaReader.class.getResourceAsStream("/" + fileName), -
- The type of object is: java.io.InputStream. - Reason for going out of scope: possible exceptional exit due to throw new IllegalStateException("Problem to read all modules including third party if any. Problem detected at file: " + fileName, ex); with exception type java.lang.IllegalStateException -
@@ -198,6 +146,8 @@ .map(Pattern.class::cast)
unsatisfiable constraint: capture extends @FenumTop Object <: @FenumUnqualified Object + Pattern.class::cast -> inference type: java.util.function.Function<? super capture of ?,? extends R> + From: Argument constraint
@@ -208,18 +158,16 @@ .map(String.class::cast)
unsatisfiable constraint: capture extends @FenumTop Object <: @FenumUnqualified Object + String.class::cast -> inference type: java.util.function.Function<? super capture of ?,? extends R> + From: Argument constraint
src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateSink.java required.method.not.called - @MustCall method close may not have been invoked on new CustomPrintWriter(writer) or any of its aliases. + (required.method.not.called) super(new CustomPrintWriter(writer)); -
- The type of object is: com.puppycrawl.tools.checkstyle.site.XdocsTemplateSink.CustomPrintWriter. - Reason for going out of scope: regular method exit -
@@ -229,160 +177,106 @@ .map(elementType::cast)
unsatisfiable constraint: S extends @FenumTop Object <: @FenumUnqualified Object + elementType::cast -> inference type: java.util.function.Function<? super S,? extends R> + From: Argument constraint
src/main/java/com/puppycrawl/tools/checkstyle/xpath/AbstractNode.java required.method.not.called - @MustCall method close may not have been invoked on axisIterator or any of its aliases. + (required.method.not.called) AxisIterator axisIterator = iterateAxis(axisNumber); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: variable overwritten by assignment axisIterator = new Navigator.AxisFilter(axisIterator, nodeTest) -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/DescendantIterator.java required.method.not.called - @MustCall method close may not have been invoked on SingleNodeIterator.makeIterator(start) or any of its aliases. + (required.method.not.called) descendantEnum = SingleNodeIterator.makeIterator(start); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/DescendantIterator.java required.method.not.called - @MustCall method close may not have been invoked on queue.poll().iterateAxis(AxisInfo.CHILD) or any of its aliases. + (required.method.not.called) descendantEnum = queue.poll().iterateAxis(AxisInfo.CHILD); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/DescendantIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.CHILD) or any of its aliases. + (required.method.not.called) descendantEnum = start.iterateAxis(AxisInfo.CHILD); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIterator.java required.method.not.called - @MustCall method close may not have been invoked on parent.iterateAxis(AxisInfo.FOLLOWING_SIBLING) or any of its aliases. - siblingEnum = parent.iterateAxis(AxisInfo.FOLLOWING_SIBLING); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + ancestorEnum = start.iterateAxis(AxisInfo.ANCESTOR);
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIterator.java required.method.not.called - @MustCall method close may not have been invoked on result.iterateAxis(AxisInfo.DESCENDANT) or any of its aliases. + (required.method.not.called) descendantEnum = result.iterateAxis(AxisInfo.DESCENDANT); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.ANCESTOR) or any of its aliases. - ancestorEnum = start.iterateAxis(AxisInfo.ANCESTOR); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + siblingEnum = parent.iterateAxis(AxisInfo.FOLLOWING_SIBLING);
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.FOLLOWING_SIBLING) or any of its aliases. + (required.method.not.called) siblingEnum = start.iterateAxis(AxisInfo.FOLLOWING_SIBLING); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIterator.java required.method.not.called - @MustCall method close may not have been invoked on new ReverseDescendantIterator(result) or any of its aliases. - descendantEnum = new ReverseDescendantIterator(result); -
- The type of object is: com.puppycrawl.tools.checkstyle.xpath.iterators.ReverseDescendantIterator. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + ancestorEnum = start.iterateAxis(AxisInfo.ANCESTOR);
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIterator.java required.method.not.called - @MustCall method close may not have been invoked on result.iterateAxis(AxisInfo.PRECEDING_SIBLING) or any of its aliases. - previousSiblingEnum = result.iterateAxis(AxisInfo.PRECEDING_SIBLING); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + descendantEnum = new ReverseDescendantIterator(result);
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.ANCESTOR) or any of its aliases. - ancestorEnum = start.iterateAxis(AxisInfo.ANCESTOR); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
+ (required.method.not.called) + previousSiblingEnum = result.iterateAxis(AxisInfo.PRECEDING_SIBLING);
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.PRECEDING_SIBLING) or any of its aliases. + (required.method.not.called) previousSiblingEnum = start.iterateAxis(AxisInfo.PRECEDING_SIBLING); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseDescendantIterator.java required.method.not.called - @MustCall method close may not have been invoked on queue.poll().iterateAxis(AxisInfo.CHILD) or any of its aliases. + (required.method.not.called) pushToStack(queue.poll().iterateAxis(AxisInfo.CHILD)); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
src/main/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseDescendantIterator.java required.method.not.called - @MustCall method close may not have been invoked on start.iterateAxis(AxisInfo.CHILD) or any of its aliases. + (required.method.not.called) pushToStack(start.iterateAxis(AxisInfo.CHILD)); -
- The type of object is: net.sf.saxon.tree.iter.AxisIterator. - Reason for going out of scope: regular method exit -
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 29a15bb2ad7..32de9448dc0 100644 --- a/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml +++ b/config/checker-framework-suppressions/checker-nullness-optional-interning-suppressions.xml @@ -793,6 +793,10 @@ .collect(Collectors.groupingBy(Class::getSimpleName,
unsatisfiable constraint: @Initialized @Nullable String <: @Initialized @NonNull String + @Initialized @Nullable String <: use of U from Collectors.mapping(Class::getCanonicalName, Collectors.toCollection(HashSet::new)) + From complementary bound.: @Initialized @Nullable String -> use of U from Collectors.mapping(Class::getCanonicalName, Collectors.toCollection(HashSet::new)) + Class::getCanonicalName -> inference type: java.util.function.Function<? super java.lang.Class<?>,? extends U> + From: Argument constraint
@@ -2801,6 +2805,11 @@ return new SimpleEntry<>(variableUsageAst, dist);
unsatisfiable constraint: @Initialized @Nullable DetailAST <: @Initialized @NonNull DetailAST + use of K from new SimpleEntry<>(variableUsageAst, dist) <: @Initialized @NonNull DetailAST + From complementary bound.: use of K from new SimpleEntry<>(variableUsageAst, dist) <= @Initialized @NonNull DetailAST + inference type: java.util.AbstractMap.SimpleEntry<K,V> <: @Initialized @NonNull Entry<@Initialized @NonNull DetailAST, @Initialized @NonNull Integer> + inference type: java.util.AbstractMap.SimpleEntry<K,V> -> @Initialized @NonNull Entry<@Initialized @NonNull DetailAST, @Initialized @NonNull Integer> + From: Constraint between method call type and target type for method call:new SimpleEntry<>(variableUsageAst, dist)
@@ -2811,6 +2820,11 @@ return new SimpleEntry<>(variableUsageAst, dist);
unsatisfiable constraint: @Initialized @Nullable DetailAST <: @Initialized @NonNull DetailAST + use of K from new SimpleEntry<>(variableUsageAst, dist) <: @Initialized @NonNull DetailAST + From complementary bound.: use of K from new SimpleEntry<>(variableUsageAst, dist) <= @Initialized @NonNull DetailAST + inference type: java.util.AbstractMap.SimpleEntry<K,V> <: @Initialized @NonNull Entry<@Initialized @NonNull DetailAST, @Initialized @NonNull Integer> + inference type: java.util.AbstractMap.SimpleEntry<K,V> -> @Initialized @NonNull Entry<@Initialized @NonNull DetailAST, @Initialized @NonNull Integer> + From: Constraint between method call type and target type for method call:new SimpleEntry<>(variableUsageAst, dist)
@@ -5523,6 +5537,12 @@ .collect(Collectors.toUnmodifiableList());
unsatisfiable constraint: @Initialized @PolyNull AbstractNode <: @Initialized @NonNull AbstractNode + use of T from Collectors.toUnmodifiableList() = @Initialized @NonNull AbstractNode + From complementary bound.: use of T from Collectors.toUnmodifiableList() <= @Initialized @NonNull AbstractNode + inference type: java.util.List<T> <: @UnknownInitialization @Nullable List<@Initialized @NonNull AbstractNode> + use of R from getItems(event).stream().map(AbstractNode.class::cast).collect(Collectors.toUnmodifiableList()) <: @UnknownInitialization @Nullable List<@Initialized @NonNull AbstractNode> + From complementary bound.: use of R from getItems(event).stream().map(AbstractNode.class::cast).collect(Collectors.toUnmodifiableList()) -> @UnknownInitialization @Nullable List<@Initialized @NonNull AbstractNode> + From: Constraint between method call type and target type for method call:getItems(event).stream().map(AbstractNode.class::cast).collect(Collectors.toUnmodifiableList())
@@ -5902,6 +5922,8 @@ .map(ElementNode::getUnderlyingNode)
unsatisfiable constraint: @Initialized @PolyNull ElementNode <: @Initialized @NonNull ElementNode + ElementNode::getUnderlyingNode -> inference type: java.util.function.Function<? super com.puppycrawl.tools.checkstyle.xpath.ElementNode,? extends R> + From: Argument constraint
@@ -6334,6 +6356,8 @@ .map(Pattern.class::cast)
unsatisfiable constraint: capture extends @Initialized @Nullable Object <: @Initialized @PolyNull Object + Pattern.class::cast -> inference type: java.util.function.Function<? super capture of ?,? extends R> + From: Argument constraint
@@ -6344,6 +6368,8 @@ .map(String.class::cast)
unsatisfiable constraint: capture extends @Initialized @Nullable Object <: @Initialized @PolyNull Object + String.class::cast -> inference type: java.util.function.Function<? super capture of ?,? extends R> + From: Argument constraint
@@ -6593,7 +6619,20 @@ Could not infer type arguments for Map.copyOf return Map.copyOf(map);
- unsatisfiable constraint: K extends @Initialized @Nullable Object <: @Initialized @NonNull Object V extends @Initialized @Nullable Object <: @Initialized @NonNull Object + unsatisfiable constraint: K extends @Initialized @Nullable Object <: @Initialized @NonNull Object + capture extends K extends @Initialized @Nullable Object <: use of K from Map.copyOf(map) + From complementary bound.: capture extends K extends @Initialized @Nullable Object <= inference type: ? extends K + @Initialized @NonNull Map<capture extends K extends @Initialized @Nullable Object, capture extends V extends @Initialized @Nullable Object> <: inference type: java.util.Map<? extends K,? extends V> + @Initialized @NonNull Map<capture extends K extends @Initialized @Nullable Object, capture extends V extends @Initialized @Nullable Object> -> inference type: java.util.Map<? extends K,? extends V> + map -> inference type: java.util.Map<? extends K,? extends V> + From: Argument constraint + V extends @Initialized @Nullable Object <: @Initialized @NonNull Object + capture extends V extends @Initialized @Nullable Object <: use of V from Map.copyOf(map) + From complementary bound.: capture extends V extends @Initialized @Nullable Object <= inference type: ? extends V + @Initialized @NonNull Map<capture extends K extends @Initialized @Nullable Object, capture extends V extends @Initialized @Nullable Object> <: inference type: java.util.Map<? extends K,? extends V> + @Initialized @NonNull Map<capture extends K extends @Initialized @Nullable Object, capture extends V extends @Initialized @Nullable Object> -> inference type: java.util.Map<? extends K,? extends V> + map -> inference type: java.util.Map<? extends K,? extends V> + From: Argument constraint
@@ -6604,6 +6643,12 @@ .collect(Collectors.toUnmodifiableList());
unsatisfiable constraint: T extends @Initialized @PolyNull Object <: T extends @Initialized @Nullable Object + use of T from Collectors.toUnmodifiableList() = T extends @Initialized @Nullable Object + From complementary bound.: use of T from Collectors.toUnmodifiableList() <= T extends @Initialized @Nullable Object + inference type: java.util.List<T> <: @Initialized @NonNull List<T extends @Initialized @Nullable Object> + use of R from items.stream().map(elementType::cast).collect(Collectors.toUnmodifiableList()) <: @Initialized @NonNull List<T extends @Initialized @Nullable Object> + From complementary bound.: use of R from items.stream().map(elementType::cast).collect(Collectors.toUnmodifiableList()) -> @Initialized @NonNull List<T extends @Initialized @Nullable Object> + From: Constraint between method call type and target type for method call:items.stream().map(elementType::cast).collect(Collectors.toUnmodifiableList())
diff --git a/pom.xml b/pom.xml index 27ce2365290..e6b55f25b7f 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,7 @@ 5.12.1 3.8 1.2.0 - 3.49.1 + 3.49.2 2.31.0 0.15.0 1.12.0 From 6f7ade57e1f340bc672d17760a475bb59d5e93be Mon Sep 17 00:00:00 2001 From: Konstantinos Koutsilis Date: Wed, 2 Apr 2025 18:56:00 +0100 Subject: [PATCH 03/82] minor: Update JavadocMethodCheck allowInlineReturn release version --- .../tools/checkstyle/checks/javadoc/JavadocMethodCheck.java | 2 +- src/site/xdoc/checks/javadoc/javadocmethod.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java index 7c09514d5ac..ca471e549d6 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java @@ -308,7 +308,7 @@ public class JavadocMethodCheck extends AbstractCheck { * Setter to control whether to allow inline return tags. * * @param value a {@code boolean} value - * @since 10.22.1 + * @since 10.23.0 */ public void setAllowInlineReturn(boolean value) { allowInlineReturn = value; diff --git a/src/site/xdoc/checks/javadoc/javadocmethod.xml b/src/site/xdoc/checks/javadoc/javadocmethod.xml index 8149a15d898..bbea52da2a0 100644 --- a/src/site/xdoc/checks/javadoc/javadocmethod.xml +++ b/src/site/xdoc/checks/javadoc/javadocmethod.xml @@ -105,7 +105,7 @@ public int checkReturnTag(final int aTagIndex, Control whether to allow inline return tags. boolean false - 10.22.1 + 10.23.0 allowMissingParamTags From 5691b022aabdc20be9f4c4f53e24e12b8d84b19e Mon Sep 17 00:00:00 2001 From: sersawy Date: Sun, 30 Mar 2025 21:41:09 +0200 Subject: [PATCH 04/82] Issue #16361: Update SarifLoggerTest.java to use verifyWithInlineConfigParserAndLogger --- .../tools/checkstyle/SarifLoggerTest.java | 14 ++++++-------- .../ExpectedSarifLoggerSingleErrorColumn0.sarif | 8 ++++---- .../InputSarifLoggerErrorColumn0.java | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/InputSarifLoggerErrorColumn0.java diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java index 4abc4b6dca5..f4e046c1886 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java @@ -124,16 +124,14 @@ public void testAddErrorAtColumn1() throws IOException { } @Test - public void testAddErrorAtColumn0() throws IOException { + public void testAddErrorAtColumn0() throws Exception { + final String inputFile = "InputSarifLoggerErrorColumn0.java"; + final String expectedReportFile = "ExpectedSarifLoggerSingleErrorColumn0.sarif"; final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); - logger.auditStarted(null); - final Violation violation = - new Violation(1, 0, - "messages.properties", "ruleId", null, SeverityLevel.ERROR, null, - getClass(), "found an error\nplease try again"); - executeLogger(this, logger, "Test.java", violation); - verifyContent(getPath("ExpectedSarifLoggerSingleErrorColumn0.sarif"), outStream); + + verifyWithInlineConfigParserAndLogger( + getPath(inputFile), getPath(expectedReportFile), logger, outStream); } @Test diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleErrorColumn0.sarif b/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleErrorColumn0.sarif index 30bb8f90bb9..963c329e914 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleErrorColumn0.sarif +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleErrorColumn0.sarif @@ -24,18 +24,18 @@ { "physicalLocation": { "artifactLocation": { - "uri": "file:Test.java" + "uri": "file:src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/InputSarifLoggerErrorColumn0.java" }, "region": { - "startLine": 1 + "startLine": 13 } } } ], "message": { - "text": "found an error\nplease try again" + "text": "Copyright comment found. \\n try again" }, - "ruleId": "ruleId" + "ruleId": "Copyright comment found. \n try again" } ] } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/InputSarifLoggerErrorColumn0.java b/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/InputSarifLoggerErrorColumn0.java new file mode 100644 index 00000000000..9e967ed980b --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/InputSarifLoggerErrorColumn0.java @@ -0,0 +1,16 @@ +/*xml + + + + + + + + +*/ + +package com.puppycrawl.tools.checkstyle.sariflogger; +// This code is copyrighted. +public class InputSarifLoggerErrorColumn0 { + +} From 5e783834222f1fc95720f96c427ab347bef7b960 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 21:28:24 +0000 Subject: [PATCH 05/82] dependency: bump maven.jacoco.plugin.version from 0.8.12 to 0.8.13 Bumps `maven.jacoco.plugin.version` from 0.8.12 to 0.8.13. Updates `org.jacoco:org.jacoco.agent` from 0.8.12 to 0.8.13 - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.12...v0.8.13) Updates `org.jacoco:jacoco-maven-plugin` from 0.8.12 to 0.8.13 - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.12...v0.8.13) --- updated-dependencies: - dependency-name: org.jacoco:org.jacoco.agent dependency-version: 0.8.13 dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.jacoco:jacoco-maven-plugin dependency-version: 0.8.13 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e6b55f25b7f..574f0a09b8d 100644 --- a/pom.xml +++ b/pom.xml @@ -211,7 +211,7 @@ 4.9.3.0 3.26.0 7.12.0 - 0.8.12 + 0.8.13 5.2.0 12.5 3.6.0 From 2aec174ce7f344896aabd183714a14eb3e207ad1 Mon Sep 17 00:00:00 2001 From: atharv Date: Mon, 31 Mar 2025 16:30:55 +0530 Subject: [PATCH 06/82] Issue #14019: Cover pitest survivals with tests in DetailNodeTreeStringPrinter --- .../pitest-tree-walker-suppressions.xml | 27 ------------------- .../DetailNodeTreeStringPrinter.java | 4 +-- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml index 5863d23fdeb..3a61b4e4bb4 100644 --- a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml +++ b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml @@ -1,32 +1,5 @@ - - DetailNodeTreeStringPrinter.java - com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter - parseFile - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to java/nio/charset/Charset::name - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); - - - - DetailNodeTreeStringPrinter.java - com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter - parseFile - org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator - replaced call to java/lang/System::getProperty with argument - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); - - - - DetailNodeTreeStringPrinter.java - com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter - parseFile - org.pitest.mutationtest.engine.gregor.mutators.experimental.NakedReceiverMutator - replaced call to java/io/File::getAbsoluteFile with receiver - final FileText text = new FileText(file.getAbsoluteFile(), - - JavadocDetailNodeParser.java com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java b/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java index 2625609d2a0..a1b05efbfd5 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage; import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus; @@ -169,8 +168,7 @@ private static String getIndentation(DetailNode node) { * @throws IOException if the file could not be read. */ private static DetailNode parseFile(File file) throws IOException { - final FileText text = new FileText(file.getAbsoluteFile(), - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); + final FileText text = new FileText(file, System.getProperty("file.encoding")); return parseJavadocAsDetailNode(text.getFullText().toString()); } From 9d134875f93bc40c84caa6a0738d7e5b65709b77 Mon Sep 17 00:00:00 2001 From: atharv Date: Mon, 31 Mar 2025 19:51:16 +0530 Subject: [PATCH 07/82] Issue #14019: Cover pitest survivals in SuppressionStringPrinter --- .../pitest-tree-walker-suppressions.xml | 18 ------------------ .../checkstyle/SuppressionsStringPrinter.java | 4 +--- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml index 3a61b4e4bb4..3cbdcc4d5f4 100644 --- a/config/pitest-suppressions/pitest-tree-walker-suppressions.xml +++ b/config/pitest-suppressions/pitest-tree-walker-suppressions.xml @@ -9,24 +9,6 @@ htmlTagNameStart = stack.pop(); - - SuppressionsStringPrinter.java - com.puppycrawl.tools.checkstyle.SuppressionsStringPrinter - printSuppressions - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to java/nio/charset/Charset::name - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); - - - - SuppressionsStringPrinter.java - com.puppycrawl.tools.checkstyle.SuppressionsStringPrinter - printSuppressions - org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator - replaced call to java/lang/System::getProperty with argument - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); - - TreeWalker.java com.puppycrawl.tools.checkstyle.TreeWalker diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java b/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java index f1940daa616..158d386c3fc 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -73,8 +72,7 @@ public static String printSuppressions(File file, String suppressionLineColumnNu throw new IllegalStateException(exceptionMsg); } - final FileText fileText = new FileText(file, - System.getProperty("file.encoding", StandardCharsets.UTF_8.name())); + final FileText fileText = new FileText(file, System.getProperty("file.encoding")); final DetailAST detailAST = JavaParser.parseFileText(fileText, JavaParser.Options.WITH_COMMENTS); final int lineNumber = Integer.parseInt(matcher.group(1)); From a9b815a45725a49b29dfd3d285878ef1489c916a Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Wed, 2 Apr 2025 13:17:36 +0530 Subject: [PATCH 08/82] Issue #14019: Kill Mutation For CheckstyleAntTask --- config/pitest-suppressions/pitest-ant-suppressions.xml | 9 --------- .../tools/checkstyle/ant/CheckstyleAntTaskTest.java | 9 +++++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/config/pitest-suppressions/pitest-ant-suppressions.xml b/config/pitest-suppressions/pitest-ant-suppressions.xml index 4056a74e419..0134d71d1e0 100644 --- a/config/pitest-suppressions/pitest-ant-suppressions.xml +++ b/config/pitest-suppressions/pitest-ant-suppressions.xml @@ -63,15 +63,6 @@ Checker.class.getPackage().getName() + ".", moduleClassLoader); - - CheckstyleAntTask.java - com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask - createRootModule - org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator - replaced call to java/lang/String::format with argument - throw new BuildException(String.format(Locale.ROOT, "Unable to create Root Module: " - - CheckstyleAntTask.java com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java index 9929794f746..655a600dc55 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java @@ -317,9 +317,11 @@ public final void testNonExistentConfig() throws IOException { final BuildException ex = getExpectedThrowable(BuildException.class, antTask::execute, "BuildException is expected"); + final String expectedMessage = String.format(Locale.ROOT, + "Unable to create Root Module: config {%s}.", getPath(NOT_EXISTING_FILE)); assertWithMessage("Error message is unexpected") .that(ex.getMessage()) - .startsWith("Unable to create Root Module: config"); + .isEqualTo(expectedMessage); } @Test @@ -331,9 +333,12 @@ public final void testEmptyConfigFile() throws IOException { final BuildException ex = getExpectedThrowable(BuildException.class, antTask::execute, "BuildException is expected"); + final String expectedMessage = String.format(Locale.ROOT, + "Unable to create Root Module: config {%s}.", + getPath("InputCheckstyleAntTaskEmptyConfig.xml")); assertWithMessage("Error message is unexpected") .that(ex.getMessage()) - .startsWith("Unable to create Root Module: config"); + .isEqualTo(expectedMessage); } @Test From 54473c006c3ec0aedaa8ba6d24df1c38ecc9234d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:49:04 +0000 Subject: [PATCH 09/82] dependency: bump de.thetaphi:forbiddenapis from 3.8 to 3.9 Bumps [de.thetaphi:forbiddenapis](https://github.com/policeman-tools/forbidden-apis) from 3.8 to 3.9. - [Commits](https://github.com/policeman-tools/forbidden-apis/compare/3.8...3.9) --- updated-dependencies: - dependency-name: de.thetaphi:forbiddenapis dependency-version: '3.9' dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 574f0a09b8d..aec7901847b 100644 --- a/pom.xml +++ b/pom.xml @@ -232,7 +232,7 @@ 1.0.6 **/test/resources/**/*,**/it/resources/**/* 5.12.1 - 3.8 + 3.9 1.2.0 3.49.2 2.31.0 From 7f7ee49717c9d2694c169b4cddb3dcc692534a73 Mon Sep 17 00:00:00 2001 From: Priyambada Roul Date: Thu, 3 Apr 2025 19:55:13 +0530 Subject: [PATCH 10/82] Issue #14019: Kill argument propogation mutation in CheckstyleAntTask --- config/pitest-suppressions/pitest-ant-suppressions.xml | 9 --------- .../tools/checkstyle/ant/CheckstyleAntTaskTest.java | 8 +++++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/config/pitest-suppressions/pitest-ant-suppressions.xml b/config/pitest-suppressions/pitest-ant-suppressions.xml index 0134d71d1e0..e60718459a3 100644 --- a/config/pitest-suppressions/pitest-ant-suppressions.xml +++ b/config/pitest-suppressions/pitest-ant-suppressions.xml @@ -81,15 +81,6 @@ final int formatterCount = Math.max(1, formatters.size()); - - CheckstyleAntTask.java - com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask - getListeners - org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator - replaced call to java/lang/String::format with argument - throw new BuildException(String.format(Locale.ROOT, "Unable to create listeners: " - - CheckstyleAntTask.java com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java index 655a600dc55..a34064ff24c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java @@ -317,11 +317,12 @@ public final void testNonExistentConfig() throws IOException { final BuildException ex = getExpectedThrowable(BuildException.class, antTask::execute, "BuildException is expected"); - final String expectedMessage = String.format(Locale.ROOT, + // Verify exact format of error message (testing String.format mutation) + final String expectedExceptionFormat = String.format(Locale.ROOT, "Unable to create Root Module: config {%s}.", getPath(NOT_EXISTING_FILE)); assertWithMessage("Error message is unexpected") .that(ex.getMessage()) - .isEqualTo(expectedMessage); + .isEqualTo(expectedExceptionFormat); } @Test @@ -654,7 +655,8 @@ public final void testCreateListenerException() throws IOException { "BuildException is expected"); assertWithMessage("Error message is unexpected") .that(ex.getMessage()) - .startsWith("Unable to create listeners: formatters"); + .isEqualTo("Unable to create listeners: formatters " + + "{" + List.of(formatter) + "}."); } @Test From cf2c9351b86ea40d7b9e8dc73b5bda4c6aba9d9f Mon Sep 17 00:00:00 2001 From: Prarthana-Ramesh <149136492+Prarthana-Ramesh@users.noreply.github.com> Date: Fri, 4 Apr 2025 15:58:10 +0530 Subject: [PATCH 11/82] Issue #13999: Resolved Pitest Suppression in JavadocNodeImpl --- .../compile-phase-suppressions.xml | 6 ------ .../pitest-javadoc-suppressions.xml | 9 --------- .../checkstyle/checks/javadoc/JavadocNodeImpl.java | 4 ++-- .../checkstyle/checks/javadoc/JavadocNodeImplTest.java | 10 +++++++++- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/config/error-prone-suppressions/compile-phase-suppressions.xml b/config/error-prone-suppressions/compile-phase-suppressions.xml index ae37e1fef6d..a4704688b08 100644 --- a/config/error-prone-suppressions/compile-phase-suppressions.xml +++ b/config/error-prone-suppressions/compile-phase-suppressions.xml @@ -1,11 +1,5 @@ - - JavadocNodeImpl.java - ArrayHashCode - hashcode method on array does not hash array contents - + ", children=" + Objects.hashCode(children) - PropertiesMacro.java diff --git a/config/pitest-suppressions/pitest-javadoc-suppressions.xml b/config/pitest-suppressions/pitest-javadoc-suppressions.xml index 4332970ee6b..4aa07e375c8 100644 --- a/config/pitest-suppressions/pitest-javadoc-suppressions.xml +++ b/config/pitest-suppressions/pitest-javadoc-suppressions.xml @@ -1,14 +1,5 @@ - - JavadocNodeImpl.java - com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl - toString - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to java/util/Objects::hashCode - + ", children=" + Objects.hashCode(children) - - JavadocTagInfo.java com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagInfo$11 diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl.java index 3ca99f5a1c8..d875b5b427c 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl.java @@ -19,7 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; -import java.util.Objects; +import java.util.Arrays; import java.util.Optional; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -180,7 +180,7 @@ public String toString() { + ", text='" + text + '\'' + ", lineNumber=" + lineNumber + ", columnNumber=" + columnNumber - + ", children=" + Objects.hashCode(children) + + ", children=" + Arrays.hashCode(children) + ", parent=" + parent + ']'; } diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java index d0103a66599..ccb30daa255 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java @@ -21,6 +21,8 @@ import static com.google.common.truth.Truth.assertWithMessage; +import java.util.Arrays; + import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; @@ -33,13 +35,19 @@ public void testToString() { javadocNode.setType(JavadocTokenTypes.CODE_LITERAL); javadocNode.setLineNumber(1); javadocNode.setColumnNumber(2); + final JavadocNodeImpl child1 = new JavadocNodeImpl(); + final JavadocNodeImpl child2 = new JavadocNodeImpl(); + child1.setType(JavadocTokenTypes.CODE_LITERAL); + child2.setType(JavadocTokenTypes.CODE_LITERAL); + javadocNode.setChildren(child1, child2); final String result = javadocNode.toString(); assertWithMessage("Invalid toString result") .that(result) .isEqualTo("JavadocNodeImpl[index=0, type=CODE_LITERAL, text='null', lineNumber=1," - + " columnNumber=2, children=0, parent=null]"); + + " columnNumber=2, children=" + Arrays.hashCode(javadocNode.getChildren()) + + ", parent=null]"); } @Test From e382b8d6ca4bf5cc63b8708b2b3de2725ced8286 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 21:24:02 +0000 Subject: [PATCH 12/82] dependency: bump nl.jqno.equalsverifier:equalsverifier Bumps [nl.jqno.equalsverifier:equalsverifier](https://github.com/jqno/equalsverifier) from 3.19.2 to 3.19.3. - [Release notes](https://github.com/jqno/equalsverifier/releases) - [Changelog](https://github.com/jqno/equalsverifier/blob/main/CHANGELOG.md) - [Commits](https://github.com/jqno/equalsverifier/commits) --- updated-dependencies: - dependency-name: nl.jqno.equalsverifier:equalsverifier dependency-version: 3.19.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aec7901847b..445ed4eaa0c 100644 --- a/pom.xml +++ b/pom.xml @@ -386,7 +386,7 @@ nl.jqno.equalsverifier equalsverifier - 3.19.2 + 3.19.3 test From fbb8a9b18ff95fda8860002ca9ea44997ca50232 Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Sun, 6 Apr 2025 18:42:54 +0530 Subject: [PATCH 13/82] Issue #16759: Removed Broken Flattr Link and Image on Sponsoring Page --- config/jsoref-spellchecker/whitelist.words | 1 - pom.xml | 4 ---- src/site/xdoc/sponsoring.xml | 10 ---------- 3 files changed, 15 deletions(-) diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words index 6af2a2121b6..8f9c7b27ead 100644 --- a/config/jsoref-spellchecker/whitelist.words +++ b/config/jsoref-spellchecker/whitelist.words @@ -456,7 +456,6 @@ FIXME Fjava Fjavadoc Flas -flattr fluido Fmain Fmessages diff --git a/pom.xml b/pom.xml index 445ed4eaa0c..fffb46c8d1a 100644 --- a/pom.xml +++ b/pom.xml @@ -2133,10 +2133,6 @@ https://twitter.com/checkstyle_java/ - - https://flattr.com/submit/ - - https://button.flattr.com/flattr-badge-large.png http://tide.olympe.in/* http://dl.acm.org/* diff --git a/src/site/xdoc/sponsoring.xml b/src/site/xdoc/sponsoring.xml index 7b44d75aa05..c0c08a6b54b 100644 --- a/src/site/xdoc/sponsoring.xml +++ b/src/site/xdoc/sponsoring.xml @@ -18,16 +18,6 @@

- - - - Flattr this - - - -
From ceb1e87874ccd20b82cada0ca2a54eaa370d9388 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:24:53 +0000 Subject: [PATCH 14/82] dependency: bump org.pitest:pitest-maven from 1.19.0 to 1.19.1 Bumps [org.pitest:pitest-maven](https://github.com/hcoles/pitest) from 1.19.0 to 1.19.1. - [Release notes](https://github.com/hcoles/pitest/releases) - [Commits](https://github.com/hcoles/pitest/compare/1.19.0...1.19.1) --- updated-dependencies: - dependency-name: org.pitest:pitest-maven dependency-version: 1.19.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fffb46c8d1a..afd622120a5 100644 --- a/pom.xml +++ b/pom.xml @@ -223,7 +223,7 @@ 3.14.0 11 ${java.version} - 1.19.0 + 1.19.1 10 HTML,XML 50000 From cd6aa1fa026fefbaaed37b2e99ba900ea4fbbe6c Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Tue, 8 Apr 2025 03:16:11 +0530 Subject: [PATCH 15/82] Issue #15456: Defined violation message for ConstantNameCheck in InlineConfigParser.java --- .../checkstyle/bdd/InlineConfigParser.java | 1 - .../constantname/InputConstantNameInner.java | 4 ++-- .../InputConstantNameMemberExtended.java | 18 +++++++++--------- .../constantname/InputConstantNameSimple1.java | 4 ++-- .../constantname/InputConstantNameSimple2.java | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java index 1182c2e54aa..538bd26650b 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java @@ -269,7 +269,6 @@ public final class InlineConfigParser { "com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck", "com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck", - "com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.IllegalIdentifierNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck", diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameInner.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameInner.java index 7e89dce90f4..235796b6f9a 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameInner.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameInner.java @@ -28,7 +28,7 @@ class InnerInner2 interface InnerInterface2 { // Ignore - should be all upper case - String data = "zxzc"; // violation + String data = "zxzc"; // violation 'Name 'data' must match pattern' // Ignore class InnerInterfaceInnerClass @@ -68,7 +68,7 @@ public static void main() @interface InnerAnnotation { /** Ignore - should be all upper case. */ - String data = "zxzc"; // violation + String data = "zxzc"; // violation 'Name 'data' must match pattern' } /** enum with public member variable */ diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameMemberExtended.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameMemberExtended.java index f80bf911634..8ff6037beaa 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameMemberExtended.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameMemberExtended.java @@ -53,15 +53,15 @@ class Inner { interface In { - public int mPublic = 0; // violation - int mProtected = 0; // violation - int mPackage = 0; // violation - int mPrivate = 0; // violation - - public int _public = 0; // violation - int _protected = 0; // violation - int _package = 0; // violation - int _private = 0; // violation + public int mPublic = 0; // violation 'Name 'mPublic' must match pattern' + int mProtected = 0; // violation 'Name 'mProtected' must match pattern' + int mPackage = 0; // violation 'Name 'mPackage' must match pattern' + int mPrivate = 0; // violation 'Name 'mPrivate' must match pattern' + + public int _public = 0; // violation 'Name '_public' must match pattern' + int _protected = 0; // violation 'Name '_protected' must match pattern' + int _package = 0; // violation 'Name '_package' must match pattern' + int _private = 0; // violation 'Name '_private' must match pattern' } enum Direction { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple1.java index bf2a7e17499..00084790c74 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple1.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple1.java @@ -28,7 +28,7 @@ final class InputConstantNameSimple1 // Name format tests // /** Invalid format **/ - public static final int badConstant = 2; // violation + public static final int badConstant = 2; // violation 'Name 'badConstant' must match pattern' /** Valid format **/ public static final int MAX_ROWS = 2; @@ -145,7 +145,7 @@ void ALL_UPPERCASE_METHOD() } /** test illegal constant **/ - private static final int BAD__NAME = 3; // violation + private static final int BAD__NAME = 3; // violation 'Name 'BAD__NAME' must match pattern' // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$" // long line that has a tab -> <- and would be OK if tab counted as 1 char diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple2.java index 6c9704c1ff7..f5f453b4cd7 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple2.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/constantname/InputConstantNameSimple2.java @@ -145,7 +145,7 @@ void ALL_UPPERCASE_METHOD() } /** test illegal constant **/ - private static final int BAD__NAME = 3; // violation + private static final int BAD__NAME = 3; // violation 'Name 'BAD__NAME' must match pattern' // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$" // long line that has a tab -> <- and would be OK if tab counted as 1 char From a9a1c243f878f34322eb58965ceca141d9ca9448 Mon Sep 17 00:00:00 2001 From: "MD. Zaid" <146553796+Zed69696969@users.noreply.github.com> Date: Mon, 7 Apr 2025 21:46:47 +0530 Subject: [PATCH 16/82] minor: correction in GRAMMAR_UPDATES.md --- docs/GRAMMAR_UPDATES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/GRAMMAR_UPDATES.md b/docs/GRAMMAR_UPDATES.md index 0ae278ff0d5..a0932075074 100644 --- a/docs/GRAMMAR_UPDATES.md +++ b/docs/GRAMMAR_UPDATES.md @@ -152,7 +152,7 @@ have updated TokenTypes to include `LITERAL_WHEN`. At this point, we are able to parse the new syntax, however, the new tokens will not appear in the AST unless we update the JavaAstVisitor. This is because our ANTLR grammar -provides us with a parse tree, which we use the JavaAstVisitor to traverse and build our AST. +provides us with a parse tree, which we traverse using the JavaAstVisitor to build our AST. ```java @Override From 0184f5259c0580532f31f92c528530f6eb105290 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Tue, 8 Apr 2025 05:29:08 -0700 Subject: [PATCH 17/82] infra: Update azure-pipelines.yml to use ubuntu-24.04 --- azure-pipelines.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cf323331cac..9018e68d136 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,7 +20,7 @@ strategy: matrix: # testing age of pr 'pr-age': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh pr-age" skipCache: true @@ -32,62 +32,62 @@ strategy: # unit tests (openjdk11) 'test': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test" # unit tests in German locale (openjdk11) 'test-de': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-de" # unit tests in Spanish locale (openjdk11) 'test-es': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-es" # unit tests in Finnish locale (openjdk11) 'test-fi': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-fi" # unit tests in French locale (openjdk11) 'test-fr': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-fr" # unit tests in Chinese locale (openjdk11) 'test-zh': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-zh" # unit tests in Japanese locale (openjdk11) 'test-ja': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-ja" # unit tests in Portuguese locale (openjdk11) 'test-pt': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-pt" # unit tests in Turkish locale (openjdk11) 'test-tr': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-tr" # unit tests in Russian locale (openjdk11) 'test-ru': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-ru" # unit tests in Albanian locale (openjdk11) 'test-al': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh test-al" # OpenJDK11 verify 'OpenJDK11 verify': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "mvn -e --no-transfer-progress verify" # MacOS JDK11 verify @@ -103,14 +103,14 @@ strategy: # moved back to Travis till we find a way to keep secrets in azure # ensure that all modules are used in no exception configs # 'verify-no-exception-configs': - # image: 'ubuntu-20.04' + # image: 'ubuntu-24.04' # cmd: "./.ci/validation.sh verify-no-exception-configs" # skipCache: true # needXmlstarlet: true # versions to update 'versions': - image: 'ubuntu-20.04' + image: 'ubuntu-24.04' cmd: "./.ci/validation.sh versions" onCronOnly: true From 6fcc53b8d7307a758e80e91341cc338d3207e9f1 Mon Sep 17 00:00:00 2001 From: ZaeemSheikh <124173573+SheikhZaeem@users.noreply.github.com> Date: Sat, 15 Mar 2025 17:26:02 +0300 Subject: [PATCH 18/82] Issue #14631: Updated DT to new AST format --- .../checkstyle/api/JavadocTokenTypes.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java index c629d7d472e..0f0bffb8ded 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java @@ -2442,7 +2442,28 @@ public final class JavadocTokenTypes { /** End description of a term tag. */ public static final int DD_TAG_END = JavadocParser.RULE_ddTagEnd + RULE_TYPES_OFFSET; - /** Description term html tag: {@code

}. */ + /** + * DT html tag. + * + *

Example AST:

+ *
{@code 
Description Term
}
+ *
+     * {@code
+     *   --HTML_ELEMENT -> HTML_ELEMENT
+     *      `--DT -> DT
+     *          |--DT_TAG_START -> DT_TAG_START
+     *          |   |--START -> <
+     *          |   |--DT_HTML_TAG_NAME -> dt
+     *          |   `--END -> >
+     *          |--TEXT -> "Description term"
+     *          `--DT_TAG_END -> DT_TAG_END
+     *              |--START -> <
+     *              |--SLASH -> /
+     *              |--DT_HTML_TAG_NAME -> dt
+     *              `--END -> >
+     * }
+     * 
+ */ public static final int DT = JavadocParser.RULE_dt + RULE_TYPES_OFFSET; /** Start description term tag. */ public static final int DT_TAG_START = JavadocParser.RULE_dtTagStart + RULE_TYPES_OFFSET; From ba1aa1c5c7d4e2b00fbb8a365c047b7f64ee33fc Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Wed, 2 Apr 2025 21:50:30 +0530 Subject: [PATCH 19/82] Issue #14631: Updated BODY_TAG_START to new AST format --- .../tools/checkstyle/api/JavadocTokenTypes.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java index 0f0bffb8ded..70e259cf73d 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java @@ -2282,14 +2282,14 @@ public final class JavadocTokenTypes { * | |--SLASH -> / * | |--BODY_HTML_TAG_NAME -> body * | `--END -> > - * |--NEWLINE -> \n - * |--LEADING_ASTERISK -> * - * |--TEXT -> / - * |--NEWLINE -> \n - * |--TEXT -> public class Test { - * |--NEWLINE -> \n - * |--TEXT -> } - * |--NEWLINE -> \n + * |--NEWLINE -> \n + * |--LEADING_ASTERISK -> * + * |--TEXT -> / + * |--NEWLINE -> \n + * |--TEXT -> public class Test { + * |--NEWLINE -> \n + * |--TEXT -> } + * |--NEWLINE -> \n * } * */ From c6cdb048b5a5869b9e4d57877e454e25c93131b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:14:07 +0000 Subject: [PATCH 20/82] dependency: bump com.google.guava:guava from 33.4.6-jre to 33.4.7-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.4.6-jre to 33.4.7-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-version: 33.4.7-jre dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afd622120a5..bf4b225d4f7 100644 --- a/pom.xml +++ b/pom.xml @@ -308,7 +308,7 @@ com.google.guava guava - 33.4.6-jre + 33.4.7-jre org.checkerframework From c0802d2b01092c1899c40aca89ca84cc7956c4be Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 2 Apr 2025 19:34:37 +0530 Subject: [PATCH 21/82] Issue #14631: Updated HEAD_HTML_TAG_NAME to new AST format --- .../checkstyle/api/JavadocTokenTypes.java | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java index 70e259cf73d..bbcb1ce9927 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java @@ -1507,7 +1507,63 @@ public final class JavadocTokenTypes { */ public static final int DT_HTML_TAG_NAME = JavadocParser.DT_HTML_TAG_NAME; - /** Head tag name. */ + /** + * Head tag name. + * + *

Example:

+ *
{@code
+     * <head>
+     *   <title>Page Title</title>
+     *   <meta charset="UTF-8">
+     * </head>
+     * }
+ * Tree: + *
{@code
+     *  HEAD -> HEAD
+     *   |--HEAD_TAG_START -> HEAD_TAG_START
+     *   |   |--START -> <
+     *   |   |--HEAD_HTML_TAG_NAME -> head
+     *   |   `--END -> >
+     *   |--NEWLINE -> \r\n
+     *   |--LEADING_ASTERISK ->  *
+     *   |--TEXT ->
+     *   |--HTML_TAG -> HTML_TAG
+     *   |   |--HTML_ELEMENT_START -> HTML_ELEMENT_START
+     *   |   |   |--START -> <
+     *   |   |   |--HTML_TAG_NAME -> title
+     *   |   |   `--END -> >
+     *   |   |--TEXT -> Page Title
+     *   |   `--HTML_ELEMENT_END -> HTML_ELEMENT_END
+     *   |       |--START -> <
+     *   |       |--SLASH -> /
+     *   |       |--HTML_TAG_NAME -> title
+     *   |       `--END -> >
+     *   |--NEWLINE -> \r\n
+     *   |--LEADING_ASTERISK ->  *
+     *   |--TEXT ->
+     *   |--SINGLETON_ELEMENT -> SINGLETON_ELEMENT
+     *   |   `--META_TAG -> META_TAG
+     *   |       |--START -> <
+     *   |       |--META_HTML_TAG_NAME -> meta
+     *   |       |--WS ->
+     *   |       |--ATTRIBUTE -> ATTRIBUTE
+     *   |       |   |--HTML_TAG_NAME -> charset
+     *   |       |   |--EQUALS -> =
+     *   |       |   `--ATTR_VALUE -> "UTF-8"
+     *   |       `--END -> >
+     *   |--NEWLINE -> \r\n
+     *   |--LEADING_ASTERISK ->  *
+     *   |--TEXT ->
+     *   `--HEAD_TAG_END -> HEAD_TAG_END
+     *       |--START -> <
+     *       |--SLASH -> /
+     *       |--HEAD_HTML_TAG_NAME -> head
+     *       `--END -> >
+     * }
+     * 
+ * + * @see #HEAD_HTML_TAG_NAME + */ public static final int HEAD_HTML_TAG_NAME = JavadocParser.HEAD_HTML_TAG_NAME; /** Html tag name. */ From 0f9d47e2ae3f0af2b1df2f98e44280db6b4d4931 Mon Sep 17 00:00:00 2001 From: abdelrhmansersawy Date: Sat, 5 Apr 2025 02:21:50 +0200 Subject: [PATCH 22/82] Issue #14019: Kill Mutation For CheckstyleAntTask --- config/pitest-suppressions/pitest-ant-suppressions.xml | 9 --------- .../tools/checkstyle/ant/CheckstyleAntTaskTest.java | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/config/pitest-suppressions/pitest-ant-suppressions.xml b/config/pitest-suppressions/pitest-ant-suppressions.xml index e60718459a3..4df3db543fd 100644 --- a/config/pitest-suppressions/pitest-ant-suppressions.xml +++ b/config/pitest-suppressions/pitest-ant-suppressions.xml @@ -90,15 +90,6 @@ + Objects.toString(checkstyleVersion, "")
- - CheckstyleAntTask.java - com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask - processFiles - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask::getLocation - throw new BuildException(failureMsg, getLocation()); - - CheckstyleAntTask.java com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java index a34064ff24c..b6b6402414a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java @@ -358,12 +358,18 @@ public final void testMaxWarningExceeded() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(WARNING_INPUT))); antTask.setMaxWarnings(0); + final Location fileLocation = new Location("build.xml", 42, 10); + antTask.setLocation(fileLocation); + final BuildException ex = getExpectedThrowable(BuildException.class, antTask::execute, "BuildException is expected"); assertWithMessage("Error message is unexpected") .that(ex.getMessage()) .isEqualTo("Got 0 errors (max allowed: 0) and 1 warnings."); + assertWithMessage("Location is missing in exception") + .that(ex.getLocation()) + .isEqualTo(fileLocation); } @Test From f07e7f233cb103317ab9c4962b0b1fb823f6d900 Mon Sep 17 00:00:00 2001 From: atharv Date: Fri, 4 Apr 2025 17:19:08 +0530 Subject: [PATCH 23/82] Issue #11166: Removed usage of getFileContents() in EmptyLineSeparatorCheck --- config/suppressions.xml | 1 - .../checks/whitespace/EmptyLineSeparatorCheck.java | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/config/suppressions.xml b/config/suppressions.xml index aa1ca151aba..47aba1bddd7 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -125,7 +125,6 @@ - diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java index 3fb2a611994..165cfd665d6 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java @@ -27,7 +27,6 @@ import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; -import com.puppycrawl.tools.checkstyle.api.FileContents; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -661,15 +660,12 @@ private static Optional findCommentUnder(DetailAST packageDef) { * @return {@code true} if found any blank line within the range, {@code false} * otherwise */ - // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") private boolean hasEmptyLine(int startLine, int endLine) { // Initial value is false - blank line not found boolean result = false; - final FileContents fileContents = getFileContents(); for (int line = startLine; line <= endLine; line++) { // Check, if the line is blank. Lines are numbered from 0, so subtract 1 - if (fileContents.lineIsBlank(line - 1)) { + if (CommonUtil.isBlank(getLine(line - 1))) { result = true; break; } From 2b874223778395f60a16ab3425823b0f8f5116b1 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 9 Apr 2025 01:04:19 +0530 Subject: [PATCH 24/82] Issue #15456: Defined violation message for PackageNameCheck in InlineConfigParser.java --- .../puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java | 1 - .../checks/naming/packagename/InputPackageNameSimple1.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java index 538bd26650b..ef4cf86be0a 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java @@ -272,7 +272,6 @@ public final class InlineConfigParser { "com.puppycrawl.tools.checkstyle.checks.naming.IllegalIdentifierNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterNameCheck", - "com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.PatternVariableNameCheck", "com.puppycrawl.tools.checkstyle.checks.naming.RecordComponentNameCheck", diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/packagename/InputPackageNameSimple1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/packagename/InputPackageNameSimple1.java index a97fabd0960..7ace398ff56 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/packagename/InputPackageNameSimple1.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/packagename/InputPackageNameSimple1.java @@ -5,7 +5,8 @@ */ -package com.puppycrawl.tools.checkstyle.checks.naming.packagename; // violation +package com.puppycrawl.tools.checkstyle.checks.naming.packagename; +// violation above 'must match pattern' /** * Contains simple mistakes: From 0efa4da454d2070a69a5ad6b433403663fb02b0b Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Thu, 10 Apr 2025 05:19:38 +0530 Subject: [PATCH 25/82] Issue #11163: Enforce file size for IndentationInvalidMethodIndent --- config/checkstyle-resources-suppressions.xml | 2 - .../indentation/IndentationCheckTest.java | 73 ++++++++----- .../InputIndentationInvalidMethodIndent1.java | 103 ++++++++++++++++++ ...InputIndentationInvalidMethodIndent2.java} | 90 +-------------- 4 files changed, 152 insertions(+), 116 deletions(-) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationInvalidMethodIndent1.java rename src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/{InputIndentationInvalidMethodIndent.java => InputIndentationInvalidMethodIndent2.java} (60%) diff --git a/config/checkstyle-resources-suppressions.xml b/config/checkstyle-resources-suppressions.xml index 6f8ab7f70ca..73bba799561 100644 --- a/config/checkstyle-resources-suppressions.xml +++ b/config/checkstyle-resources-suppressions.xml @@ -278,8 +278,6 @@ files="[\\/]test[\\/]resources[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]checks[\\/]avoidescapedunicodecharacters[\\/]InputAvoidEscapedUnicodeCharacters2\.java"/> - Date: Wed, 2 Apr 2025 11:00:55 +0530 Subject: [PATCH 26/82] Issue #14631: Updated EMBED_TAG to new AST format --- .../checkstyle/api/JavadocTokenTypes.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java index bbcb1ce9927..fd1aa0d898c 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.java @@ -2860,9 +2860,37 @@ public final class JavadocTokenTypes { public static final int PARAM_TAG = JavadocParser.RULE_paramTag + RULE_TYPES_OFFSET; /** - * HTML void element {@code }. + * HTML void element. * - * @see #SINGLETON_ELEMENT + *

Example:

+ *
{@code
+     * 
+     * }
+ * Tree: + *
+     * {@code
+     *    |--HTML_ELEMENT -> HTML_ELEMENT
+     *    |   `--SINGLETON_ELEMENT -> SINGLETON_ELEMENT
+     *    |       `--EMBED_TAG -> EMBED_TAG
+     *    |           |--START -> <
+     *    |           |--EMBED_HTML_TAG_NAME -> embed
+     *    |           |--WS ->
+     *    |           |--ATTRIBUTE -> ATTRIBUTE
+     *    |           |   |--HTML_TAG_NAME -> src
+     *    |           |   |--EQUALS -> =
+     *    |           |   `--ATTR_VALUE -> "URL"
+     *    |           |--WS ->
+     *    |           |--ATTRIBUTE -> ATTRIBUTE
+     *    |           |   |--HTML_TAG_NAME -> type
+     *    |           |   |--EQUALS -> =
+     *    |           |   `--ATTR_VALUE -> "MIME_type"
+     *    |           `--END -> >
+     *    |--NEWLINE -> \r\n
+     *    |--TEXT ->
+     * }
+     * 
+ * + * @see #EMBED_TAG * @see
* W3 docs */ From 3d7969d2c87454791e769d755356e23008122ba0 Mon Sep 17 00:00:00 2001 From: "MD. Zaid" <146553796+Zed69696969@users.noreply.github.com> Date: Sat, 5 Apr 2025 16:53:10 +0530 Subject: [PATCH 27/82] config: removed unnecessary suppression for GetFileContents Method in suppression.xml --- config/suppressions.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/suppressions.xml b/config/suppressions.xml index 47aba1bddd7..dac2ee5d870 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -114,7 +114,6 @@ - From d767eab0d48357647c8cb7994817815af0665940 Mon Sep 17 00:00:00 2001 From: Harsh-Agrawal96 Date: Mon, 31 Mar 2025 21:14:40 +0530 Subject: [PATCH 28/82] Issue #11641: use of simple name check in aliasList --- config/checkstyle-examples-suppressions.xml | 4 + .../checks/SuppressWarningsHolder.java | 30 ++++++ .../annotation/suppresswarningsholder.xml | 94 ++++++++++++++++--- .../suppresswarningsholder.xml.template | 35 ++++++- .../checks/SuppressWarningsHolderTest.java | 80 ++++++++++++++++ .../InputSuppressWarningsHolderAlias4.java | 26 +++++ .../InputSuppressWarningsHolderAlias5.java | 44 +++++++++ .../InputSuppressWarningsHolderAlias6.java | 82 ++++++++++++++++ .../InputSuppressWarningsHolderAlias7.java | 69 ++++++++++++++ .../SuppressWarningsHolderExamplesTest.java | 28 +++++- .../suppresswarningsholder/Example1.java | 15 ++- .../suppresswarningsholder/Example2.java | 10 +- .../suppresswarningsholder/Example3.java | 30 ++++++ .../suppresswarningsholder/Example4.java | 30 ++++++ 14 files changed, 543 insertions(+), 34 deletions(-) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias4.java create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias5.java create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias6.java create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias7.java create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example3.java create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example4.java diff --git a/config/checkstyle-examples-suppressions.xml b/config/checkstyle-examples-suppressions.xml index 11993f2a64c..8db5cbd2e1e 100644 --- a/config/checkstyle-examples-suppressions.xml +++ b/config/checkstyle-examples-suppressions.xml @@ -138,6 +138,10 @@ + + + diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java index 6dde5f85950..30a7e22b334 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java @@ -28,11 +28,14 @@ import java.util.Optional; import java.util.regex.Pattern; +import javax.annotation.Nullable; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; /** *
@@ -122,6 +125,30 @@ public static String getDefaultAlias(String sourceName) { return sourceNameLower.substring(startIndex, endIndex); } + /** + * Returns the alias of simple check name for a check, The alias is + * for the form of CheckNameCheck or CheckName. + * + * @param sourceName the source name of the check (generally the class + * name) + * @return the alias of the simple check name for the given check + */ + @Nullable + private static String getSimpleNameAlias(String sourceName) { + final String checkName = CommonUtil.baseClassName(sourceName); + final String checkNameSuffix = "Check"; + // check alias for the CheckNameCheck + String checkAlias = CHECK_ALIAS_MAP.get(checkName); + if (checkAlias == null && checkName.endsWith(checkNameSuffix)) { + final int checkStartIndex = checkName.length() - checkNameSuffix.length(); + final String checkNameWithoutSuffix = checkName.substring(0, checkStartIndex); + // check alias for the CheckName + checkAlias = CHECK_ALIAS_MAP.get(checkNameWithoutSuffix); + } + + return checkAlias; + } + /** * Returns the alias for the source name of a check. If an alias has been * explicitly registered via {@link #setAliasList(String...)}, that @@ -133,6 +160,9 @@ public static String getDefaultAlias(String sourceName) { */ public static String getAlias(String sourceName) { String checkAlias = CHECK_ALIAS_MAP.get(sourceName); + if (checkAlias == null) { + checkAlias = getSimpleNameAlias(sourceName); + } if (checkAlias == null) { checkAlias = getDefaultAlias(sourceName); } diff --git a/src/site/xdoc/checks/annotation/suppresswarningsholder.xml b/src/site/xdoc/checks/annotation/suppresswarningsholder.xml index 6a865fbce81..3ad6895f74a 100644 --- a/src/site/xdoc/checks/annotation/suppresswarningsholder.xml +++ b/src/site/xdoc/checks/annotation/suppresswarningsholder.xml @@ -50,14 +50,13 @@

 <module name="Checker">
   <module name="TreeWalker">
-  <module name="MemberName"/>
-  <module name="ConstantName"/>
-  <module name="ParameterNumber">
-    <property name="id" value="ParamNumberId"/>
-  </module>
-  <module name=
-    "NoWhitespaceAfter"/>
-  <module name="SuppressWarningsHolder"/>
+    <module name="MemberName"/>
+    <module name="ConstantName"/>
+    <module name="ParameterNumber">
+      <property name="id" value="ParamNumberId"/>
+    </module>
+    <module name="NoWhitespaceAfter"/>
+    <module name="SuppressWarningsHolder"/>
   </module>
   <module name="SuppressWarningsFilter"/>
 </module>
@@ -91,17 +90,18 @@ class Example1 {
         

If aliasList property was provided you can use your own names e.g. below - code will work if there was provided a ParameterNumberCheck=paramnum in - the aliasList: + code will work if there was provided a + com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck=paramnum + in the aliasList:


 <module name="Checker">
   <module name="TreeWalker">
-  <module name="ParameterNumber"/>
-  <module name="SuppressWarningsHolder">
-    <property name="aliasList" value=
-      "com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck=paramnum"/>
-  </module>
+    <module name="ParameterNumber"/>
+    <module name="SuppressWarningsHolder">
+      <property name="aliasList"
+        value="com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck=paramnum"/>
+    </module>
   </module>
   <module name="SuppressWarningsFilter"/>
 </module>
@@ -121,6 +121,70 @@ class Example2 {
     // ...
   }
 
+}
+
+

+ You can also use simple check name like ParameterNumberCheck=paramnum + instead to use fully qualified name of check in the aliasList: +

+

+<module name="Checker">
+  <module name="TreeWalker">
+    <module name="ParameterNumber"/>
+    <module name="SuppressWarningsHolder">
+      <property name="aliasList" value="ParameterNumberCheck=paramnum"/>
+    </module>
+  </module>
+  <module name="SuppressWarningsFilter"/>
+</module>
+
+

Example:

+

+public class Example3 {
+  // violation below, 'More than 7 parameters (found 8)'
+  public void needsLotsOfParameters (int a,
+    int b, int c, int d, int e, int f, int g, int h) {
+    // ...
+  }
+
+  @SuppressWarnings("paramnum")
+  public void needsLotsOfParameters1 (int a, // violation suppressed
+    int b, int c, int d, int e, int f, int g, int h) {
+    // ...
+  }
+
+}
+
+

+ The check can also be used without suffix of "Check" like + ParameterNumber=paramnum in the aliasList: +

+

+<module name="Checker">
+  <module name="TreeWalker">
+    <module name="ParameterNumber"/>
+    <module name="SuppressWarningsHolder">
+      <property name="aliasList" value="ParameterNumber=paramnum"/>
+    </module>
+  </module>
+  <module name="SuppressWarningsFilter"/>
+</module>
+
+

Example:

+

+public class Example4 {
+  // violation below, 'More than 7 parameters (found 8)'
+  public void needsLotsOfParameters (int a,
+    int b, int c, int d, int e, int f, int g, int h) {
+    // ...
+  }
+
+  @SuppressWarnings("paramnum")
+  public void needsLotsOfParameters1 (int a, // violation suppressed
+    int b, int c, int d, int e, int f, int g, int h) {
+    // ...
+  }
+
 }
 
diff --git a/src/site/xdoc/checks/annotation/suppresswarningsholder.xml.template b/src/site/xdoc/checks/annotation/suppresswarningsholder.xml.template index 5a6ed01a990..fe00e536cb0 100644 --- a/src/site/xdoc/checks/annotation/suppresswarningsholder.xml.template +++ b/src/site/xdoc/checks/annotation/suppresswarningsholder.xml.template @@ -52,8 +52,9 @@

If aliasList property was provided you can use your own names e.g. below - code will work if there was provided a ParameterNumberCheck=paramnum in - the aliasList: + code will work if there was provided a + com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck=paramnum + in the aliasList:

+

+ You can also use simple check name like ParameterNumberCheck=paramnum + instead to use fully qualified name of check in the aliasList: +

+ + + + +

Example:

+ + + + +

+ The check can also be used without suffix of "Check" like + ParameterNumber=paramnum in the aliasList: +

+ + + + +

Example:

+ + + + diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java index 855ce90a0f7..f6cb5a4eb14 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java @@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.coding.UnusedLocalVariableCheck.MSG_UNUSED_LOCAL_VARIABLE; +import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY; import java.io.File; import java.lang.reflect.Constructor; @@ -44,6 +45,8 @@ import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; +import com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck; +import com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck; import com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck; @@ -517,6 +520,83 @@ public void testAliasList2() throws Exception { expected); } + @Test + public void testAliasList3() throws Exception { + final String[] expected = { + "16:17: " + getCheckMessage(ParameterNumberCheck.class, + ParameterNumberCheck.MSG_KEY, 7, 8), + "28:17: " + getCheckMessage(ParameterNumberCheck.class, + ParameterNumberCheck.MSG_KEY, 7, 8), + }; + + verifyWithInlineConfigParser( + getPath("InputSuppressWarningsHolderAlias5.java"), + expected); + } + + @Test + public void testAliasList4() throws Exception { + final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; + final String[] expected = { + "16:30: " + getCheckMessage(ConstantNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "a", pattern), + "19:30: " + getCheckMessage(ConstantNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "b", pattern), + }; + + verifyWithInlineConfigParser( + getPath("InputSuppressWarningsHolderAlias4.java"), + expected); + } + + @Test + public void testAliasList5() throws Exception { + final String[] expected = { + "18: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 80, 83), + "28: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 96), + "28: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 80, 96), + "58: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 76), + "65: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 87), + }; + + verifyWithInlineConfigParser( + getPath("InputSuppressWarningsHolderAlias6.java"), + expected); + } + + @Test + public void testAliasList6() throws Exception { + final String pattern1 = "^[a-z][a-zA-Z0-9]*$"; + final String pattern2 = "^[A-Z][a-zA-Z0-9]*$"; + + final String[] expected = { + "25:18: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "Method3", pattern1), + "30:20: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "Method5", pattern1), + "35:17: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "method7", pattern2), + "40:18: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "method9", pattern2), + "45:20: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "method11", pattern2), + "47:17: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "_methodCheck1", pattern2), + "53:18: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "_methodCheck3", pattern2), + "53:18: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "_methodCheck3", pattern1), + "61:20: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "_methodCheck5", pattern2), + "61:20: " + getCheckMessage(MethodNameCheck.class, + AbstractNameCheck.MSG_INVALID_PATTERN, "_methodCheck5", pattern1), + }; + + verifyWithInlineConfigParser( + getPath("InputSuppressWarningsHolderAlias7.java"), + expected); + } + @Test public void testIdent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias4.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias4.java new file mode 100644 index 00000000000..c768a370a32 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias4.java @@ -0,0 +1,26 @@ +/* +com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder +aliasList = ConstantNameCheck=constant + +com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilter + +com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck +format = (default)^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.suppresswarningsholder; + +public class InputSuppressWarningsHolderAlias4 { + private static final int a = 0; // violation 'Name 'a' must match pattern' + + @SuppressWarnings("Notconstant") + private static final int b = 0; // violation 'Name 'b' must match pattern' + + @SuppressWarnings("CONSTANT") // filtered violation 'invalid pattern' + private static final int c = 0; + + @SuppressWarnings("CONstant") // filtered violation 'invalid pattern' + private static final int d = 0; +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias5.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias5.java new file mode 100644 index 00000000000..a42ee9cdc74 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias5.java @@ -0,0 +1,44 @@ +/* +com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder +aliasList = ParameterNumber=paramnum + +com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilter + +com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck +max = (default)7 + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.suppresswarningsholder; + +public class InputSuppressWarningsHolderAlias5 { + public void needsLotsOfParameters0(int a, // violation 'More than 7 parameters (found 8)' + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("paramnum") + public void needsLotsOfParameters(int a, // filtered violation 'max parameter' + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("ParamnumUnknown") + public void needsLotsOfParameters2(int a, // violation 'More than 7 parameters (found 8)' + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("PAramnuM") + public void needsLotsOfParameters3(int a, // filtered violation 'max parameter' + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("PARAMNUM") + public void needsLotsOfParameters4(int a, // filtered violation 'max parameter' + int b, int c, int d, int e, int f, int g, int h) { + // ... + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias6.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias6.java new file mode 100644 index 00000000000..ad0f7404552 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias6.java @@ -0,0 +1,82 @@ +/* +com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder +aliasList = LineLengthCheck=line + +com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilter + +com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck +ignorePattern = ^ *\\* *[^ ]+$ + +com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck +max = 75 + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.suppresswarningsholder; + +import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY; +// violation above, 'Line is longer than 80 characters' + + +public class InputSuppressWarningsHolderAlias6 { + + void testMethod(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + + System.out.println("This line is long and exceeds the default limit of 80 characters."); + // 2 violations above: + // 'Line is longer than 75 characters' + // 'Line is longer than 80 characters' + } + + @SuppressWarnings("Line") + void testMethod2(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + + System.out.println("This line is long and exceeds the default limit of 80 characters."); + // filtered 2 violations above: + // 'Line is longer than 75 characters' + // 'Line is longer than 80 characters' + } + + @SuppressWarnings("LIne") + void testMethod3(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + + System.out.println("This line exceeds the limit of 75 characters."); + // filtered violation above, 'Line is longer than 75 characters' + } + + void testMethod4(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + + System.out.println("This line exceeds the limit of 75 characters."); + // violation above, 'Line is longer than 75 characters' + } + + // violation 3 lines below 'Line is longer than 75 characters' + /** + * This is a short Javadoc comment. + * ThisJavadocCommentIsAReallyLongWordThatExceedsDefaultLineLimitOfEightyCharacters. + */ + void testMethod5(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + } + + @SuppressWarnings("LINE") + // filtered violation 3 lines below, 'Line is longer than 75 characters' + /** + * This is a short Javadoc comment. + * ThisJavadocCommentIsAReallyLongWordThatExceedsDefaultLineLimitOfEightyCharacters. + */ + void testMethod6(String str) { + str = MSG_KEY; + System.out.println("This is a short line."); + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias7.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias7.java new file mode 100644 index 00000000000..7d8623a26e9 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/suppresswarningsholder/InputSuppressWarningsHolderAlias7.java @@ -0,0 +1,69 @@ +/* +com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder +aliasList = MethodName=name + +com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilter + +com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck +format = ^[A-Z][a-zA-Z0-9]*$ + +com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck +applyToPublic = false + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.suppresswarningsholder; + +public class InputSuppressWarningsHolderAlias7 { + + public void Method1() {} + + @SuppressWarnings("Name") + private void Method2() {} + + private void Method3() {} // violation 'Name 'Method3' must match pattern.' + + @SuppressWarnings("NAme") + protected void Method4() {} + + protected void Method5() {} // violation 'Name 'Method5' must match pattern.' + + @SuppressWarnings("NaMe") + public void method6() {} + + public void method7() {} // violation 'Name 'method7' must match pattern.' + + @SuppressWarnings("NAME") + private void method8() {} + + private void method9() {} // violation 'Name 'method9' must match pattern.' + + @SuppressWarnings("NAME") + protected void method10() {} + + protected void method11() {} // violation 'Name 'method11' must match pattern.' + + public void _methodCheck1() {} + // violation above 'Name '_methodCheck1' must match pattern.' + + @SuppressWarnings("name") + public void _methodCheck2() {} + + private void _methodCheck3() {} + // 2 violations above: + // 'Name '_methodCheck3' must match pattern.' + // 'Name '_methodCheck3' must match pattern.' + + @SuppressWarnings("NAME") + private void _methodCheck4() {} + + protected void _methodCheck5() {} + // 2 violations above: + // 'Name '_methodCheck5' must match pattern.' + // 'Name '_methodCheck5' must match pattern.' + + @SuppressWarnings("Name") + protected void _methodCheck6() {} + +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java index 82ce0366ede..1a28d690f0a 100644 --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java @@ -39,13 +39,13 @@ public void testExample1() throws Exception { final String pattern1 = "^[a-z][a-zA-Z0-9]*$"; final String pattern2 = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { - "21:15: " + getCheckMessage(MemberNameCheck.class, + "20:15: " + getCheckMessage(MemberNameCheck.class, AbstractNameCheck.MSG_INVALID_PATTERN, "K", pattern1), - "25:28: " + getCheckMessage(ConstantNameCheck.class, + "24:28: " + getCheckMessage(ConstantNameCheck.class, AbstractNameCheck.MSG_INVALID_PATTERN, "i", pattern2), - "35:15: " + getCheckMessage(NoWhitespaceAfterCheck.class, + "34:15: " + getCheckMessage(NoWhitespaceAfterCheck.class, NoWhitespaceAfterCheck.MSG_KEY, "int"), - "35:18: " + getCheckMessage(MemberNameCheck.class, + "34:18: " + getCheckMessage(MemberNameCheck.class, AbstractNameCheck.MSG_INVALID_PATTERN, "ARR", pattern1), }; @@ -63,4 +63,24 @@ public void testExample2() throws Exception { verifyWithInlineConfigParser(getPath("Example2.java"), expected); } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + "18:15: " + getCheckMessage(ParameterNumberCheck.class, + ParameterNumberCheck.MSG_KEY, 7, 8), + }; + + verifyWithInlineConfigParser(getPath("Example3.java"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + "18:15: " + getCheckMessage(ParameterNumberCheck.class, + ParameterNumberCheck.MSG_KEY, 7, 8), + }; + + verifyWithInlineConfigParser(getPath("Example4.java"), expected); + } } diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example1.java index b6d75032e6e..677f7cc7512 100644 --- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example1.java +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example1.java @@ -1,14 +1,13 @@ /*xml - - - - - - - + + + + + + + diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example2.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example2.java index cf67c92f2db..16ad0a2d1b1 100644 --- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example2.java +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example2.java @@ -1,11 +1,11 @@ /*xml - - - - + + + + diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example3.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example3.java new file mode 100644 index 00000000000..2606f1ef1a1 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example3.java @@ -0,0 +1,30 @@ +/*xml + + + + + + + + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarningsholder; + +// xdoc section -- start +public class Example3 { + // violation below, 'More than 7 parameters (found 8)' + public void needsLotsOfParameters (int a, + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("paramnum") + public void needsLotsOfParameters1 (int a, // violation suppressed + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example4.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example4.java new file mode 100644 index 00000000000..564e7e06a16 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder/Example4.java @@ -0,0 +1,30 @@ +/*xml + + + + + + + + + +*/ + +package com.puppycrawl.tools.checkstyle.checks.annotation.suppresswarningsholder; + +// xdoc section -- start +public class Example4 { + // violation below, 'More than 7 parameters (found 8)' + public void needsLotsOfParameters (int a, + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + + @SuppressWarnings("paramnum") + public void needsLotsOfParameters1 (int a, // violation suppressed + int b, int c, int d, int e, int f, int g, int h) { + // ... + } + +} +// xdoc section -- end From 93c0ffc9fb9ad1db10190898f26eab07d447bc54 Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Thu, 10 Apr 2025 21:16:06 +0530 Subject: [PATCH 29/82] Issue #16816: remove backport section from index.xml.vm and whitelist.words --- config/jsoref-spellchecker/whitelist.words | 1 - src/site/xdoc/index.xml.vm | 46 ---------------------- 2 files changed, 47 deletions(-) diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words index 8f9c7b27ead..7213fd7f2c2 100644 --- a/config/jsoref-spellchecker/whitelist.words +++ b/config/jsoref-spellchecker/whitelist.words @@ -88,7 +88,6 @@ Awarns aws awt azurewebsites -backport Backquote backticks BADN diff --git a/src/site/xdoc/index.xml.vm b/src/site/xdoc/index.xml.vm index f5f578fb9b4..86eeb77dfaf 100644 --- a/src/site/xdoc/index.xml.vm +++ b/src/site/xdoc/index.xml.vm @@ -171,52 +171,6 @@

-
-

- Since Checkstyle 7, some users have been unable to continue upgrading to newer versions - of the utility because of the new JDK compile requirements. The development team doesn't - have the resources to keep updating the utility for older JDKs for those that can't - work with the latest version. -

-

- However, some members of the community have created an unofficial backport of the latest - Checkstyle releases to be run with older JDKs. It is not always an easy process and provided - at the same release time as Checkstyle, but it tries to maintain a functional equivalent - alternative. -

-
- - - - - - - - - - - - - - - - -
Backport versionMin. JRE versionLink
- 10.0+ - - 8 - - github site -
- 7.0 - 8.45 - - 6 - - github site -
-
-
-

Checkstyle can parse all Java language features introduced From 53ddb7b0977425d122f0b78eab1147e6d9fca0e3 Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Mon, 7 Apr 2025 19:07:02 +0530 Subject: [PATCH 30/82] Issue #1241: Add table of contents macro to writinglisteners.xml.vm --- src/site/xdoc/writinglisteners.xml.vm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/site/xdoc/writinglisteners.xml.vm b/src/site/xdoc/writinglisteners.xml.vm index 9e63731db1f..8aaf945b552 100644 --- a/src/site/xdoc/writinglisteners.xml.vm +++ b/src/site/xdoc/writinglisteners.xml.vm @@ -9,6 +9,12 @@ +

+ + + + +

From 19ad14d308a5ff0c740e88455963f28d0d74a7d5 Mon Sep 17 00:00:00 2001 From: Brijeshthummar02 Date: Fri, 11 Apr 2025 09:16:57 +0530 Subject: [PATCH 31/82] Issue #16753: remove references to freedomsponsors from pom.xml, sponsoring.xml, and whitelist.words --- config/jsoref-spellchecker/whitelist.words | 1 - pom.xml | 2 -- src/site/xdoc/sponsoring.xml | 3 --- 3 files changed, 6 deletions(-) diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words index 7213fd7f2c2..be84d4dc706 100644 --- a/config/jsoref-spellchecker/whitelist.words +++ b/config/jsoref-spellchecker/whitelist.words @@ -466,7 +466,6 @@ forbiddenapis Foreach Fpuppycrawl fq -freedomsponsors freemarker Fregexp Fresources diff --git a/pom.xml b/pom.xml index bf4b225d4f7..04c9681f7cf 100644 --- a/pom.xml +++ b/pom.xml @@ -2171,8 +2171,6 @@ https://opencollective.com/* https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - https://freedomsponsors.org/* https://liberapay.com/checkstyle/ diff --git a/src/site/xdoc/sponsoring.xml b/src/site/xdoc/sponsoring.xml index c0c08a6b54b..ccef374c289 100644 --- a/src/site/xdoc/sponsoring.xml +++ b/src/site/xdoc/sponsoring.xml @@ -51,9 +51,6 @@
- - freedomsponsors - checkstyle -

From 78cdf2d75378bb3f0633343d912207dc97556345 Mon Sep 17 00:00:00 2001 From: Konstantinos Koutsilis Date: Fri, 11 Apr 2025 08:55:07 +0100 Subject: [PATCH 32/82] minor: Revert fork usage in ci validations on no-error-pmd --- .ci/validation.sh | 9 ++------- config/jsoref-spellchecker/whitelist.words | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.ci/validation.sh b/.ci/validation.sh index c96ae3eebf5..d2802a97b28 100755 --- a/.ci/validation.sh +++ b/.ci/validation.sh @@ -216,17 +216,12 @@ no-error-pmd) echo "CS_version: ${CS_POM_VERSION}" mvn -e --no-transfer-progress clean install -Pno-validations echo "Checkout target sources ..." - # checkout_from "https://github.com/pmd/build-tools.git" - checkout_from "https://github.com/kkoutsilis/build-tools.git" + checkout_from "https://github.com/pmd/build-tools.git" cd .ci-temp/build-tools/ - git ls-remote - git checkout "66d""ed33c74662cb3da612f3d34a5ae""fa""a629b443" mvn -e --no-transfer-progress install cd .. - git clone https://github.com/kkoutsilis/pmd.git + git clone https://github.com/pmd/pmd.git cd pmd - git ls-remote - git checkout "fa6a862ac8278906d7bcf21852f6552d27a46a73" ./mvnw verify --show-version --errors --batch-mode --no-transfer-progress \ -DskipTests \ -Dmaven.javadoc.skip=true \ diff --git a/config/jsoref-spellchecker/whitelist.words b/config/jsoref-spellchecker/whitelist.words index be84d4dc706..2b4d5a6c783 100644 --- a/config/jsoref-spellchecker/whitelist.words +++ b/config/jsoref-spellchecker/whitelist.words @@ -743,7 +743,6 @@ KDoc keygen keyname keyscan -kkoutsilis konstantinos Kordas Kotlin From fde84377a3d5d4144084ffcafe2a30c035fd1da6 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Thu, 10 Apr 2025 05:51:21 -0700 Subject: [PATCH 33/82] infra: disable nondex due to frequent instability in execution --- .semaphore/semaphore.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index edf51c087e1..dd0af5db2f1 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -52,7 +52,10 @@ blocks: - .ci/validation.sh verify-regexp-id - .ci/no-exception-test.sh guava-with-google-checks - .ci/no-exception-test.sh guava-with-sun-checks - - .ci/validation.sh nondex + # until https://github.com/checkstyle/checkstyle/issues/14086 + # - .ci/no-exception-test.sh no-exception-samples-ant + # permanently disabled as it is very unstable in execution + # - .ci/validation.sh nondex # until https://github.com/checkstyle/checkstyle/issues/9807 # - mvn -e --no-transfer-progress clean package -Passembly,no-validations # && .ci/validation.sh no-violation-test-josm From 01e7ddc1de4cdda60a4150be401bd3af100699a3 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Thu, 10 Apr 2025 10:27:50 +0200 Subject: [PATCH 34/82] Pull #16811: fix whitespace typo in `Note : ` -> `Note: ` --- .../checks/coding/VariableDeclarationUsageDistanceCheck.java | 2 +- .../checks/coding/VariableDeclarationUsageDistanceCheck.xml | 2 +- .../xdoc/checks/coding/variabledeclarationusagedistance.xml | 2 +- .../checks/coding/variabledeclarationusagedistance.xml.template | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java index 39170cfe30c..c232c7d0f77 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheck.java @@ -37,7 +37,7 @@ /** *

* Checks the distance between declaration of variable and its first usage. - * Note : Variable declaration/initialization statements are not counted while calculating length. + * Note: Variable declaration/initialization statements are not counted while calculating length. *
*