Skip to content

Commit c7deeea

Browse files
authored
Update RevApi and cleanup suppressions (Azure#45070)
Update RevApi and cleanup suppressions
1 parent f667e81 commit c7deeea

File tree

19 files changed

+230
-541
lines changed

19 files changed

+230
-541
lines changed

eng/code-quality-reports/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@
7070
<dependency>
7171
<groupId>org.revapi</groupId>
7272
<artifactId>revapi</artifactId>
73-
<version>0.15.0</version> <!-- {x-version-update;org.revapi:revapi;external_dependency} -->
73+
<version>0.15.1</version> <!-- {x-version-update;org.revapi:revapi;external_dependency} -->
7474
</dependency>
7575

7676
<dependency>
7777
<groupId>org.revapi</groupId>
7878
<artifactId>revapi-java</artifactId>
79-
<version>0.28.1</version> <!-- {x-version-update;org.revapi:revapi-java;external_dependency} -->
79+
<version>0.28.3</version> <!-- {x-version-update;org.revapi:revapi-java;external_dependency} -->
8080
<exclusions>
8181
<exclusion>
8282
<groupId>org.apache.logging.log4j</groupId>
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>org.revapi</groupId>
9494
<artifactId>revapi-java-spi</artifactId>
95-
<version>0.25.0</version> <!-- {x-version-update;org.revapi:revapi-java-spi;external_dependency} -->
95+
<version>0.25.1</version> <!-- {x-version-update;org.revapi:revapi-java-spi;external_dependency} -->
9696
</dependency>
9797

9898
<dependency>

eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/JavadocCodeSnippetCheck.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.puppycrawl.tools.checkstyle.api.FullIdent;
1111
import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
1212
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
13+
import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck;
1314
import com.puppycrawl.tools.checkstyle.utils.BlockCommentPosition;
1415
import com.puppycrawl.tools.checkstyle.utils.JavadocUtil;
1516

@@ -36,11 +37,7 @@ public class JavadocCodeSnippetCheck extends AbstractCheck {
3637
+ " does not refer to any sample.";
3738

3839
private static final int[] TOKENS = new int[] {
39-
TokenTypes.PACKAGE_DEF,
40-
TokenTypes.BLOCK_COMMENT_BEGIN,
41-
TokenTypes.CLASS_DEF,
42-
TokenTypes.METHOD_DEF
43-
};
40+
TokenTypes.PACKAGE_DEF, TokenTypes.BLOCK_COMMENT_BEGIN, TokenTypes.CLASS_DEF, TokenTypes.METHOD_DEF };
4441

4542
private String packageName;
4643
// A LIFO queue contains all class name visited, remove the class name when leave the same token
@@ -96,6 +93,11 @@ public void visitToken(DetailAST token) {
9693
}
9794
}
9895

96+
@Override
97+
public void destroy() {
98+
super.destroy();
99+
}
100+
99101
/**
100102
* Check if the given block comment is on method. If not, skip the check.
101103
* Otherwise, check if the codesnippet has matching the naming pattern

eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/JavadocThrowsChecks.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.HashMap;
1717
import java.util.HashSet;
1818
import java.util.Map;
19+
import java.util.Set;
1920

2021
/**
2122
* Verifies that all throws in the public API have JavaDocs explaining why and when they are thrown.
@@ -37,8 +38,8 @@ public class JavadocThrowsChecks extends AbstractCheck {
3738
private static final String THIS_TOKEN = "this";
3839
private static final String CLASS_TOKEN = "class";
3940

40-
private Map<String, HashSet<String>> javadocThrowsMapping;
41-
private Map<String, HashSet<String>> exceptionMapping;
41+
private Map<String, Set<String>> javadocThrowsMapping;
42+
private Map<String, Set<String>> exceptionMapping;
4243
private String currentScopeIdentifier;
4344
private boolean currentScopeNeedsChecking;
4445

@@ -79,7 +80,9 @@ public void visitToken(DetailAST token) {
7980
break;
8081

8182
case TokenTypes.BLOCK_COMMENT_BEGIN:
82-
findJavadocThrows(token);
83+
if (currentScopeNeedsChecking) {
84+
findJavadocThrows(token);
85+
}
8386
break;
8487

8588
case TokenTypes.LITERAL_THROWS:
@@ -177,7 +180,7 @@ private void findJavadocThrows(DetailAST blockCommentToken) {
177180
}
178181

179182
// Append the line number to differentiate overloads.
180-
HashSet<String> javadocThrows = javadocThrowsMapping.getOrDefault(currentScopeIdentifier, new HashSet<>());
183+
Set<String> javadocThrows = javadocThrowsMapping.getOrDefault(currentScopeIdentifier, new HashSet<>());
181184

182185
// Iterate through all the top level nodes in the Javadoc, looking for the @throws statements.
183186
for (DetailNode node : javadocNode.getChildren()) {
@@ -218,7 +221,7 @@ private void addExceptionMapping(DetailAST definitionToken) {
218221
}
219222
}
220223
String identifier = scope + definitionToken.findFirstToken(TokenTypes.IDENT).getText();
221-
HashSet<String> types = exceptionMapping.getOrDefault(identifier, new HashSet<>());
224+
Set<String> types = exceptionMapping.getOrDefault(identifier, new HashSet<>());
222225

223226
if (typeToken.getType() == TokenTypes.BOR) {
224227
TokenUtil.forEachChild(typeToken, TokenTypes.IDENT, (identityToken) -> tryToAddType(identityToken, types));
@@ -229,7 +232,7 @@ private void addExceptionMapping(DetailAST definitionToken) {
229232
exceptionMapping.put(identifier, types);
230233
}
231234

232-
private void tryToAddType(DetailAST typeToken, HashSet<String> types) {
235+
private void tryToAddType(DetailAST typeToken, Set<String> types) {
233236
String type = typeToken.getText();
234237
if (type.endsWith("Exception") || type.endsWith("Error")) {
235238
types.add(type);
@@ -241,7 +244,7 @@ private void tryToAddType(DetailAST typeToken, HashSet<String> types) {
241244
* @param throwsToken Throws token.
242245
*/
243246
private void verifyCheckedThrowJavadoc(DetailAST throwsToken) {
244-
HashSet<String> methodJavadocThrows = javadocThrowsMapping.get(currentScopeIdentifier);
247+
Set<String> methodJavadocThrows = javadocThrowsMapping.get(currentScopeIdentifier);
245248
if (methodJavadocThrows == null) {
246249
log(throwsToken, MISSING_THROWS_TAG_MESSAGE);
247250
return;
@@ -260,7 +263,7 @@ private void verifyCheckedThrowJavadoc(DetailAST throwsToken) {
260263
*/
261264
private void verifyUncheckedThrowJavadoc(DetailAST throwToken) {
262265
// Early out check for method that don't have Javadocs, they cannot have @throws documented.
263-
HashSet<String> methodJavadocThrows = javadocThrowsMapping.get(currentScopeIdentifier);
266+
Set<String> methodJavadocThrows = javadocThrowsMapping.get(currentScopeIdentifier);
264267
if (methodJavadocThrows == null) {
265268
log(throwToken, MISSING_THROWS_TAG_MESSAGE);
266269
return;
@@ -308,7 +311,7 @@ private void verifyUncheckedThrowJavadoc(DetailAST throwToken) {
308311
}
309312

310313
String throwIdentName = lastIdentifier.getText();
311-
HashSet<String> types = findMatchingExceptionType(currentScopeIdentifier, throwIdentName);
314+
Set<String> types = findMatchingExceptionType(currentScopeIdentifier, throwIdentName);
312315

313316
if (types == null) {
314317
return;
@@ -322,9 +325,9 @@ private void verifyUncheckedThrowJavadoc(DetailAST throwToken) {
322325
}
323326
}
324327

325-
private HashSet<String> findMatchingExceptionType(String scope, String throwIdent) {
328+
private Set<String> findMatchingExceptionType(String scope, String throwIdent) {
326329
// check current scope
327-
HashSet<String> types = exceptionMapping.get(scope + throwIdent);
330+
Set<String> types = exceptionMapping.get(scope + throwIdent);
328331
if (types == null) {
329332
// if a matching type is not found in current method scope, search object scope
330333
types = exceptionMapping.get(THIS_TOKEN + throwIdent);

eng/code-quality-reports/src/main/resources/checkstyle/checkstyle.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ page at http://checkstyle.sourceforge.net/config.html -->
380380
1) Package, class and method names should be concatenated by dot '.'. Ex. packageName.className.methodName
381381
2) Methods arguments should be concatenated by dash '-'. Ex. string-string for methodName(String s, String s2)
382382
3) Use '#' to concatenate 1) and 2), ex packageName.className.methodName#string-string -->
383-
<module name="com.azure.tools.checkstyle.checks.JavadocCodeSnippetCheck"/>
383+
<!-- Disabled as {@codesnippet} is no longer used. -->
384+
<!-- <module name="com.azure.tools.checkstyle.checks.JavadocCodeSnippetCheck"/> -->
384385

385386
<!--CUSTOM CHECKS-->
386387
<!-- Good Logging Practice

eng/code-quality-reports/src/main/resources/revapi/revapi.json

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
},
205205
{
206206
"code": "java.method.addedToInterface",
207-
"new" : "method long com.azure.spring.data.cosmos.core.CosmosOperations::sum(com.azure.cosmos.models.SqlQuerySpec, java.lang.String)",
207+
"new": "method long com.azure.spring.data.cosmos.core.CosmosOperations::sum(com.azure.cosmos.models.SqlQuerySpec, java.lang.String)",
208208
"justification": "Spring interfaces are allowed to add methods."
209209
},
210210
{
@@ -229,7 +229,7 @@
229229
},
230230
{
231231
"code": "java.method.addedToInterface",
232-
"new" : "method reactor.core.publisher.Mono<java.lang.Long> com.azure.spring.data.cosmos.core.ReactiveCosmosOperations::sum(com.azure.cosmos.models.SqlQuerySpec, java.lang.String)",
232+
"new": "method reactor.core.publisher.Mono<java.lang.Long> com.azure.spring.data.cosmos.core.ReactiveCosmosOperations::sum(com.azure.cosmos.models.SqlQuerySpec, java.lang.String)",
233233
"justification": "Spring interfaces are allowed to add methods."
234234
},
235235
{
@@ -716,14 +716,14 @@
716716
},
717717
{
718718
"ignore": true,
719-
"code" : "java.method.removed",
720-
"old" : "method com.azure.resourcemanager.cosmos.models.DatabaseAccountCreateUpdateParameters com.azure.resourcemanager.cosmos.models.DatabaseAccountCreateUpdateParameters::withDatabaseAccountOfferType(java.lang.String)",
719+
"code": "java.method.removed",
720+
"old": "method com.azure.resourcemanager.cosmos.models.DatabaseAccountCreateUpdateParameters com.azure.resourcemanager.cosmos.models.DatabaseAccountCreateUpdateParameters::withDatabaseAccountOfferType(java.lang.String)",
721721
"justification": "The property is a constant, which should not be changed."
722722
},
723723
{
724724
"ignore": true,
725-
"code" : "java.method.removed",
726-
"old" : "method com.azure.resourcemanager.storage.models.StorageAccountCheckNameAvailabilityParameters com.azure.resourcemanager.storage.models.StorageAccountCheckNameAvailabilityParameters::withType(java.lang.String)",
725+
"code": "java.method.removed",
726+
"old": "method com.azure.resourcemanager.storage.models.StorageAccountCheckNameAvailabilityParameters com.azure.resourcemanager.storage.models.StorageAccountCheckNameAvailabilityParameters::withType(java.lang.String)",
727727
"justification": "The property is a constant, which should not be changed."
728728
},
729729
{
@@ -734,35 +734,40 @@
734734
},
735735
{
736736
"ignore": true,
737-
"code" : "java.method.removed",
738-
"old" : "method com.azure.resourcemanager.keyvault.models.VaultCheckNameAvailabilityParameters com.azure.resourcemanager.keyvault.models.VaultCheckNameAvailabilityParameters::withType(java.lang.String)",
737+
"code": "java.method.removed",
738+
"old": "method com.azure.resourcemanager.keyvault.models.VaultCheckNameAvailabilityParameters com.azure.resourcemanager.keyvault.models.VaultCheckNameAvailabilityParameters::withType(java.lang.String)",
739739
"justification": "The property is a constant, which should not be changed."
740740
},
741741
{
742742
"ignore": true,
743-
"code" : "java.method.removed",
744-
"old" : "method com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile::withEffectiveOutboundIPs(java.util.List<com.azure.resourcemanager.containerservice.models.ResourceReference>)",
743+
"code": "java.method.removed",
744+
"old": "method com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile com.azure.resourcemanager.containerservice.models.ManagedClusterLoadBalancerProfile::withEffectiveOutboundIPs(java.util.List<com.azure.resourcemanager.containerservice.models.ResourceReference>)",
745745
"justification": "The effectiveOutboundIPs was never a client-side modifiable property."
746746
},
747747
{
748748
"ignore": true,
749-
"code" : "java.method.removed",
750-
"old" : "method com.azure.resourcemanager.containerservice.models.ManagedClusterNatGatewayProfile com.azure.resourcemanager.containerservice.models.ManagedClusterNatGatewayProfile::withEffectiveOutboundIPs(java.util.List<com.azure.resourcemanager.containerservice.models.ResourceReference>)",
749+
"code": "java.method.removed",
750+
"old": "method com.azure.resourcemanager.containerservice.models.ManagedClusterNatGatewayProfile com.azure.resourcemanager.containerservice.models.ManagedClusterNatGatewayProfile::withEffectiveOutboundIPs(java.util.List<com.azure.resourcemanager.containerservice.models.ResourceReference>)",
751751
"justification": "The effectiveOutboundIPs was never a client-side modifiable property."
752752
},
753753
{
754754
"ignore": true,
755-
"code" : "java.method.numberOfParametersChanged",
756-
"old" : "method void com.azure.search.documents.indexes.models.SearchResourceEncryptionKey::<init>(java.lang.String, java.lang.String, java.lang.String)",
757-
"new" : "method void com.azure.search.documents.indexes.models.SearchResourceEncryptionKey::<init>(java.lang.String, java.lang.String)",
755+
"code": "java.method.numberOfParametersChanged",
756+
"old": "method void com.azure.search.documents.indexes.models.SearchResourceEncryptionKey::<init>(java.lang.String, java.lang.String, java.lang.String)",
757+
"new": "method void com.azure.search.documents.indexes.models.SearchResourceEncryptionKey::<init>(java.lang.String, java.lang.String)",
758758
"justification": "Breaking change in Search 03-01-2025 preview."
759759
},
760760
{
761761
"regex": true,
762-
"code" : "java.field.enumConstantOrderChanged",
763-
"old" : "field com\\.azure\\.resourcemanager\\.storage\\.models\\.ProvisioningState\\.(CANCELED|DELETING|FAILED)",
764-
"new" : "field com\\.azure\\.resourcemanager\\.storage\\.models\\.ProvisioningState\\.(CANCELED|DELETING|FAILED)",
762+
"code": "java.field.enumConstantOrderChanged",
763+
"old": "field com\\.azure\\.resourcemanager\\.storage\\.models\\.ProvisioningState\\.(CANCELED|DELETING|FAILED)",
764+
"new": "field com\\.azure\\.resourcemanager\\.storage\\.models\\.ProvisioningState\\.(CANCELED|DELETING|FAILED)",
765765
"justification": "Add Accepted to ProvisioningState."
766+
},
767+
{
768+
"regex": true,
769+
"code": "java\\.method\\.varargOverloadsOnlyDifferInVarargParameter",
770+
"old": "method com\\.azure\\.communication\\.email\\.models\\.EmailMessage com\\.azure\\.communication\\.email\\.models\\.EmailMessage::set(Cc|Bcc|To)Recipients.*"
766771
}
767772
]
768773
}

0 commit comments

Comments
 (0)