Skip to content

Commit 843c8ef

Browse files
authored
Migrate Identity libraries to new linting format (#42833)
Migrate Identity libraries to new linting format
1 parent 6cbc527 commit 843c8ef

File tree

49 files changed

+1045
-1190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1045
-1190
lines changed

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

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@
7474
<!-- Suppress LineLength for i18n message properties -->
7575
<suppress checks="LineLength" files="messages.properties"/>
7676

77-
<!-- Identity and opentelemetry tracing are plugin packages and shouldn't be referenced -->
77+
<!-- OpenTelemetry tracing are plugin packages and shouldn't be referenced -->
7878
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]monitor[/\\]opentelemetry[/\\]*"/>
7979
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]spring[/\\]cloud[/\\]autoconfigure[/\\]monitor[/\\]*"/>
80-
<suppress checks="IllegalImport" files=".*[/\\]com[/\\]azure[/\\]identity[/\\]*"/>
8180
<suppress checks="IllegalImport" files="com.azure.messaging.eventhubs.*Sample.*java"/>
8281
<suppress checks="IllegalImport" files="com.azure.messaging.eventhubs.*Test.*java"/>
8382

@@ -146,14 +145,6 @@
146145
<!-- Requires static access to logger to report errors while loading i18n messages (from within a static initializer )-->
147146
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="Messages.java"/>
148147

149-
<!-- Accesses Windows native credential api, doesn't follow java style.-->
150-
<suppress checks="MethodName|MemberName|VisibilityModifier|TypeName"
151-
files="com.azure.identity.implementation.WindowsCredentialApi.java"/>
152-
153-
<!-- Need to write to stdout as the default SDK behavior here.-->
154-
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck"
155-
files="com.azure.identity.DeviceCodeCredentialBuilder.java"/>
156-
157148
<!-- TODO: Synapse access control API does not support PagedResponse and Response. -->
158149
<!-- Checkstyle suppressions for naming issues reported in the Synapse artifacts related clients-->
159150
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files=".*[/\\]synapse[/\\].*"/>
@@ -272,12 +263,6 @@
272263
<!-- Checkstyle suppression for Inference client APIs that use Flux instead of PagedFlux for methods that return a collection -->
273264
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.ai.inference.(ChatCompletionsClient|ChatCompletionsAsyncClient).java"/>
274265

275-
<!-- jdbc sdk suppression -->
276-
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck"
277-
files="com.azure.identity.extensions.jdbc.(mysql|postgresql).(AzureMysqlAuthenticationPlugin|AzurePostgresqlAuthenticationPlugin).java"/>
278-
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck"
279-
files="com.azure.identity.extensions.jdbc.postgresql.AzurePostgresqlAuthenticationPlugin"/>
280-
281266
<!-- ### begin: Spring related suppression -->
282267
<!-- Checkstyle suppressions for azure.spring.data.cosmos package -->
283268
<suppress checks="[a-zA-Z0-9]*" files="[/\\]azure-spring-data-cosmos[/\\]src[/\\]test[/\\]"/>
@@ -345,9 +330,6 @@
345330
<!-- Issue: https://github.com/Azure/azure-sdk-for-java/issues/22117 -->
346331
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files="com.azure.communication.callingserver.CallingServerAsyncClient"/>
347332

348-
<!-- Third party source code files, retained as is. -->
349-
<suppress checks="[a-zA-Z0-9]*" files="com.azure.identity.implementation.intellij.(Aes|HashedBlockInputStream|LittleEndianDataInputStream|Salsa20)"/>
350-
351333
<!-- Checkstyle suppressions to keep HttpPipelinePolicy in implementation folder. -->
352334
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicyCheck"
353335
files="com.azure.communication.callingserver.implementation.RedirectPolicy.java"/>
@@ -377,21 +359,12 @@
377359
<!-- Star import is ok in impl class - it makes it easier to import all parent APIs, etc -->
378360
<suppress checks="AvoidStarImport" files="com.azure.jedis.AzureJedisClient.java"/>
379361

380-
<!-- Field additionallyAllowedTenants is not set in constructor and can be changed using the builder option. -->
381-
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.identity.DefaultAzureCredentialBuilder"/>
382-
383-
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files=".*(DeviceCodeCredential|InteractiveBrowserCredential|AzureCliCredential|AzureDeveloperCliCredential|ClientCertificateCredential|ClientSecretCredential|EnvironmentCredential|OnBehalfOfCredential|WorkloadIdentityCredential|ChainedTokenCredential|ClientAssertionCredential|UsernamePasswordCredential).java"/>
384-
385362
<!-- The build tool plugin checkstyle exceptions -->
386363
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck"
387364
files="com.azure.sdk.build.tool.*\.java"/>
388365
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="ConsoleLogger.java"/>
389366
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck"
390367
files="com.azure.sdk.build.tool.*\.java"/>
391-
<!-- Identity tests use paramaterization which requires a public field -->
392-
<suppress checks="VisibilityModifier" files="com.azure.identity.AzureCliCredentialNegativeTest.java"/>
393-
<suppress checks="VisibilityModifier" files="com.azure.identity.AzureDeveloperCliCredentialNegativeTest.java"/>
394-
<suppress checks="VisibilityModifier" files="com.azure.identity.AzureCliCredentialNegativeTest.java"/>
395368

396369
<!-- Suppress checks for defender Easm -->
397370
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.analytics.defender.easm.models.CountPagedResponse"/>

eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -46,60 +46,6 @@
4646
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
4747
</Match>
4848

49-
<!-- Defines native api, doesn't follow java style.-->
50-
<Match>
51-
<Class name="~com\.azure\.identity\.implementation\.WindowsCredentialApi(.+)"/>
52-
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD,
53-
UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD,
54-
NM_FIELD_NAMING_CONVENTION"/>
55-
</Match>
56-
57-
<!-- Internal implementation details, not at risk.-->
58-
<Match>
59-
<Class name="~com\.azure\.identity\.implementation\.intellij\.IntelliJKdbxMetadata"/>
60-
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
61-
</Match>
62-
63-
<Match>
64-
<Class name="~com\.azure\.identity\.implementation\.intellij\.IntelliJKdbxDatabase"/>
65-
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
66-
</Match>
67-
68-
<!-- Third party source code files, kept as it is.-->
69-
<Match>
70-
<Class name="~com\.azure\.identity\.implementation\.intellij\.LittleEndianDataInputStream"/>
71-
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
72-
</Match>
73-
74-
<Match>
75-
<Class name="~com\.azure\.identity\.implementation\.intellij\.Salsa20"/>
76-
<Bug pattern="DM_DEFAULT_ENCODING"/>
77-
</Match>
78-
79-
<!-- Exception needs to be caught here.-->
80-
<Match>
81-
<Class name="~com\.azure\.identity\.implementation\.VisualStudioCacheAccessor"/>
82-
<Bug pattern="REC_CATCH_EXCEPTION"/>
83-
</Match>
84-
85-
<!-- Exception needs to be caught here.-->
86-
<Match>
87-
<Class name="~com\.azure\.identity\.IntelliJCredential"/>
88-
<Bug pattern="REC_CATCH_EXCEPTION"/>
89-
</Match>
90-
91-
<!-- Accesses native api, doesn't follow java style.-->
92-
<Match>
93-
<Class name="~com\.azure\.identity\.implementation\.LinuxKeyRingAccessor(.+)"/>
94-
<Bug pattern="UWF_UNWRITTEN_FIELD"/>
95-
</Match>
96-
97-
<!-- Accesses native api, doesn't follow java style.-->
98-
<Match>
99-
<Class name="com.azure.identity.implementation.WindowsCredentialAccessor"/>
100-
<Bug pattern="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
101-
</Match>
102-
10349
<!-- Public field already exists in the public API surface. -->
10450
<Match>
10551
<Class name="com.microsoft.azure.batch.auth.BatchUserTokenCredentials"/>
@@ -384,13 +330,6 @@
384330
<Bug pattern="SE_BAD_FIELD"/>
385331
</Match>
386332

387-
<!-- The fields are checked for null in the build method and throw exceptions if values for fields are not specified. -->
388-
<Match>
389-
<Class name="com.azure.identity.InteractiveBrowserCredentialBuilder"/>
390-
<Field name="port"/>
391-
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
392-
</Match>
393-
394333
<!-- The switch cases are encoded version of all SAS query parameters, which will further be appended to a request URL it seems like. A default case wouldn't make sense -->
395334
<Match>
396335
<Class name="com.microsoft.azure.storage.blob.SASQueryParameters"/>
@@ -539,21 +478,6 @@
539478
<Bug pattern="NM_CONFUSING"/>
540479
</Match>
541480

542-
<!-- Retry thus does not throw.
543-
SharedTokenCacheCredential needs to catch any catch exception that gets thrown.-->
544-
<Match>
545-
<Or>
546-
<Class name="com.azure.identity.SharedTokenCacheCredential"/>
547-
<Class name="com.azure.identity.implementation.msalextensions.CacheLock"/>
548-
</Or>
549-
<Bug pattern="REC_CATCH_EXCEPTION"/>
550-
</Match>
551-
<!-- Return value not needed -->
552-
<Match>
553-
<Class name="com.azure.identity.implementation.msalextensions.cachepersister.windows.WindowsDPAPICacheProtector"/>
554-
<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
555-
</Match>
556-
557481
<!-- Disable some spotbugs rules on perf-tests -->
558482
<Match>
559483
<Or>
@@ -610,13 +534,6 @@
610534
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,REC_CATCH_EXCEPTION"/>
611535
</Match>
612536

613-
<!-- Exception needs to be caught here.-->
614-
<Match>
615-
<Class name="~com\.azure\.identity\.implementation\.IdentitySyncClient"/>
616-
<Method name="authenticateWithWorkloadIdentityConfidentialClient"/>
617-
<Bug pattern="REC_CATCH_EXCEPTION"/>
618-
</Match>
619-
620537
<!-- ClassLoader::getResourceAsStream can return null, ref: https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html -->
621538
<Match>
622539
<Class name="com.azure.cosmos.implementation.directconnectivity.RntbdTransportClient$Options$Builder"/>
@@ -1912,50 +1829,6 @@
19121829
<Bug pattern="NP_NULL_PARAM_DEREF"/>
19131830
</Match>
19141831

1915-
<!-- The transient fields are not used if deserialization happens. -->
1916-
<Match>
1917-
<Class name="com.azure.identity.implementation.MsalAuthenticationAccount"/>
1918-
<Field name="authenticationRecord"/>
1919-
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
1920-
</Match>
1921-
1922-
<!-- These fields are designed to be not written. They are for deserializing. -->
1923-
<Match>
1924-
<Class name="com.azure.identity.implementation.LinuxKeyRingAccessor$GError"/>
1925-
<Bug pattern="UWF_UNWRITTEN_FIELD"/>
1926-
</Match>
1927-
1928-
<!-- These fields use File Reader with default encoding, java 8 doesn't support passing in encoding type. -->
1929-
<Match>
1930-
<Class name="com.azure.identity.implementation.IntelliJCacheAccessor"/>
1931-
<Or>
1932-
<Method name="getIntellijServicePrincipalDetails"/>
1933-
<Method name="getKdbxPassword"/>
1934-
<Method name="getCredentialFromKdbx"/>
1935-
<Method name="parseRefreshTokenFromJson"/>
1936-
<Method name="getIntelliJCredentialsFromIdentityMsalCache"/>
1937-
</Or>
1938-
<Bug pattern="DM_DEFAULT_ENCODING,
1939-
REC_CATCH_EXCEPTION"/>
1940-
</Match>
1941-
1942-
<!-- Setup in Identity Test classes, required for the tests to work properly.-->
1943-
<Match>
1944-
<Class name="com.azure.identity.ClientCertificateCredentialTest"/>
1945-
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
1946-
</Match>
1947-
1948-
<Match>
1949-
<Or>
1950-
<Class name="com.azure.identity.implementation.IdentityClientTests"/>
1951-
<Class name="com.azure.identity.implementation.SynchronizedAccessorTests"/>
1952-
</Or>
1953-
<Or>
1954-
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/> <!-- false positive -->
1955-
<Bug pattern="UI_INHERITANCE_UNSAFE_GETRESOURCE"/>
1956-
</Or>
1957-
</Match>
1958-
19591832
<!-- EventGrid swagger naming -->
19601833
<Match>
19611834
<Or>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
3+
<!-- This file is generated by the /eng/scripts/linting_suppression_generator.py script. -->
4+
5+
<suppressions>
6+
<suppress files="com.azure.identity.broker.JavaDocCodeSnippets.java" checks="IllegalImportCheck" />
7+
</suppressions>

sdk/identity/azure-identity-broker-samples/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
<javaModulesSurefireArgLine>
2020
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
2121
</javaModulesSurefireArgLine>
22+
<checkstyle.suppressionsLocation>checkstyle-suppressions.xml</checkstyle.suppressionsLocation>
23+
24+
<spotbugs.skip>false</spotbugs.skip>
25+
<spotbugs.excludeFilterFile>spotbugs-exclude.xml</spotbugs.excludeFilterFile>
2226
</properties>
2327

2428
<parent>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<FindBugsFilter xmlns="https://github.com/spotbugs/filter/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
5+
<Match>
6+
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
7+
<Class name="com.azure.identity.broker.JavaDocCodeSnippets" />
8+
</Match>
9+
</FindBugsFilter>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
3+
<!-- This file is generated by the /eng/scripts/linting_suppression_generator.py script. -->
4+
5+
<suppressions>
6+
<suppress files="com.azure.identity.broker.shr.resources.PopTokenTest.java" checks="IllegalImportCheck" />
7+
</suppressions>

sdk/identity/azure-identity-broker/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
--add-exports com.azure.core/com.azure.core.implementation=com.azure.identity.broker
2323
</javaModulesSurefireArgLine>
2424
<doclintMissingInclusion>-</doclintMissingInclusion>
25+
<checkstyle.suppressionsLocation>checkstyle-suppressions.xml</checkstyle.suppressionsLocation>
26+
27+
<spotbugs.skip>false</spotbugs.skip>
28+
<spotbugs.excludeFilterFile>spotbugs-exclude.xml</spotbugs.excludeFilterFile>
2529
</properties>
2630

2731
<parent>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<FindBugsFilter xmlns="https://github.com/spotbugs/filter/3.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
5+
</FindBugsFilter>
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
33

4+
/**
5+
* Package containing implementation classes for the Identity broker.
6+
*/
47
package com.azure.identity.broker.implementation;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
3+
<!-- This file is generated by the /eng/scripts/linting_suppression_generator.py script. -->
4+
5+
<suppressions>
6+
<suppress files="com.azure.identity.extensions.implementation.credential.TokenCredentialProviderOptions.java" checks="MissingJavadocMethodCheck" />
7+
<suppress files="com.azure.identity.extensions.implementation.credential.provider.TokenCredentialProvider.java" checks="MissingJavadocMethodCheck" />
8+
<suppress files="com.azure.identity.extensions.implementation.credential.provider.TokenCredentialProviders.java" checks="MissingJavadocMethodCheck" />
9+
<suppress files="com.azure.identity.extensions.implementation.token.AccessTokenResolver.java" checks="MissingJavadocMethodCheck" />
10+
<suppress files="com.azure.identity.extensions.implementation.token.AccessTokenResolverImpl.java" checks="MissingJavadocMethodCheck" />
11+
<suppress files="com.azure.identity.extensions.implementation.token.AccessTokenResolverOptions.java" checks="MissingJavadocMethodCheck" />
12+
<suppress files="com.azure.identity.extensions.jdbc.mysql.AzureMysqlAuthenticationPlugin.java" checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck" />
13+
<suppress files="com.azure.identity.extensions.jdbc.postgresql.AzurePostgresqlAuthenticationPlugin.java" checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck" />
14+
<suppress files="com.azure.identity.extensions.implementation.exception.AzureInstantiateException.java" checks="com.azure.tools.checkstyle.checks.JavaDocFormatting" />
15+
<suppress files="com.azure.identity.extensions.jdbc.postgresql.AzurePostgresqlAuthenticationPlugin.java" checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" />
16+
</suppressions>

0 commit comments

Comments
 (0)