Skip to content

Commit 6fc9690

Browse files
alzimmermsftbillwert
authored andcommitted
Migrate Identity libraries to new linting format (#42833)
Migrate Identity libraries to new linting format
1 parent b964943 commit 6fc9690

31 files changed

+934
-1033
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,21 @@
132132
<!-- Requires static access to logger to report errors while loading i18n messages (from within a static initializer )-->
133133
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="Messages.java"/>
134134

135+
<!-- TODO: Synapse access control API does not support PagedResponse and Response. -->
136+
<!-- Checkstyle suppressions for naming issues reported in the Synapse artifacts related clients-->
137+
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientCheck" files=".*[/\\]synapse[/\\].*"/>
138+
<!-- Suppress the check on synapse code-gen classes -->
139+
<suppress checks="Indentation" files="com.azure.analytics.synapse.accesscontrol.implementation..*Impl" /> <!-- *Impl infers *ClientImpl -->
140+
<suppress checks="Indentation" files="com.azure.analytics.synapse.artifacts.implementation..*Impl" /> <!-- *Impl infers *ClientImpl -->
141+
<suppress checks="Indentation" files="com.azure.analytics.synapse.spark.implementation..*Impl" /> <!-- *Impl infers *ClientImpl -->
142+
<suppress checks="Indentation" files="com.azure.analytics.synapse.managedprivateendpoints.implementation..*Impl" /> <!-- *Impl infers *ClientImpl -->
143+
<suppress checks="Indentation" files="com.azure.analytics.synapse.monitoring.implementation..*Impl" /> <!-- *Impl infers *ClientImpl -->
144+
145+
<!-- Suppress the long package name in Synapse managed private endpoints -->
146+
<suppress checks="PackageName" files="com.azure.analytics.synapse.managedprivateendpoints.*" />
147+
<!-- Suppress the long line in endpoint path -->
148+
<suppress checks="LineLength" files="com.azure.analytics.synapse.managedprivateendpoints.implementation.ManagedPrivateEndpointsImpl.java"/>
149+
135150
<!-- Allows the HttpPipelinePolicy derived class in Implementation folder -->
136151
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicy" files="com.azure.containers.containerregistry.implementation.authentication.ContainerRegistryCredentialsPolicy.java"/>
137152
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicy" files="com.azure.messaging.eventgrid.implementation.CloudEventTracingPipelinePolicy.java"/>

sdk/identity/azure-identity/checkstyle-suppressions.xml

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

sdk/identity/azure-identity/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
--add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
2121
</javaModulesSurefireArgLine>
2222

23+
<checkstyle.suppressionsLocation>checkstyle-suppressions.xml</checkstyle.suppressionsLocation>
24+
25+
<spotbugs.skip>false</spotbugs.skip>
26+
<spotbugs.excludeFilterFile>spotbugs-exclude.xml</spotbugs.excludeFilterFile>
2327
<spotbugs.includeTests>true</spotbugs.includeTests>
2428
</properties>
2529

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
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="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
7+
<Or>
8+
<Class name="com.azure.jedis.ApiManager" />
9+
<Class name="com.azure.redisson.sample.AuthenticateWithTokenCache" />
10+
<Class name="com.azure.redisson.sample.HandleReauthentication" />
11+
<Class name="com.azure.redisson.sample.HelloWorld" />
12+
</Or>
13+
</Match>
14+
<Match>
15+
<Bug pattern="CT_CONSTRUCTOR_THROW" />
16+
<Or>
17+
<Class name="com.azure.identity.AzurePipelinesCredential" />
18+
<Class name="com.azure.identity.implementation.IdentityClient" />
19+
<Class name="com.azure.identity.implementation.IdentitySyncClient" />
20+
</Or>
21+
</Match>
22+
<Match>
23+
<Bug pattern="DE_MIGHT_IGNORE" />
24+
<Class name="com.azure.identity.implementation.IdentitySyncClient" />
25+
</Match>
26+
<Match>
27+
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
28+
<Or>
29+
<Class name="com.azure.identity.credential.JavaDocCodeSnippets" />
30+
<Class name="com.azure.lettuce.sample.HandleReauthentication" />
31+
<Class name="com.azure.lettuce.sample.withcredentialprovider.HandleReauthentication" />
32+
<Class name="com.azure.redisson.sample.AuthenticateWithTokenCache" />
33+
<Class name="com.azure.redisson.sample.HandleReauthentication" />
34+
<Class name="com.azure.redisson.sample.HelloWorld" />
35+
</Or>
36+
</Match>
37+
<Match>
38+
<Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME" />
39+
<Or>
40+
<Class name="com.azure.identity.implementation.ValidationUtilTests" />
41+
<Class name="com.azure.identity.implementation.util.ValidationUtil" />
42+
</Or>
43+
</Match>
44+
<Match>
45+
<Bug pattern="DM_DEFAULT_ENCODING" />
46+
<Or>
47+
<Class name="LiveManagedIdentityTests" />
48+
<Class name="com.azure.identity.AuthenticationRecordTest" />
49+
<Class name="com.azure.identity.implementation.PowershellManager" />
50+
</Or>
51+
</Match>
52+
<Match>
53+
<Bug pattern="DM_STRING_TOSTRING" />
54+
<Class name="com.azure.redisson.sample.AuthenticateWithTokenCache" />
55+
</Match>
56+
<Match>
57+
<Bug pattern="EI_EXPOSE_REP" />
58+
<Or>
59+
<Class name="com.azure.identity.implementation.IdentityClient" />
60+
<Class name="com.azure.identity.implementation.IdentityClientOptions" />
61+
<Class name="com.azure.identity.implementation.IdentitySyncClient" />
62+
<Class name="com.azure.identity.implementation.MsalAuthenticationAccount" />
63+
<Class name="com.azure.identity.util.EmptyEnvironmentConfigurationSource" />
64+
</Or>
65+
</Match>
66+
<Match>
67+
<Bug pattern="EI_EXPOSE_REP2" />
68+
<Or>
69+
<Class name="com.azure.identity.implementation.IdentityClientBuilder" />
70+
<Class name="com.azure.identity.implementation.IdentityClientOptions" />
71+
<Class name="com.azure.identity.implementation.MsalAuthenticationAccount" />
72+
<Class name="com.azure.jedis.sample.AuthenticateWithTokenCache$TokenRefreshCache" />
73+
</Or>
74+
</Match>
75+
<Match>
76+
<Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS" />
77+
<Class name="com.azure.identity.implementation.ValidationUtilTests$TestFile" />
78+
</Match>
79+
<Match>
80+
<Bug pattern="MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR" />
81+
<Or>
82+
<Class name="com.azure.identity.DeviceCodeCredentialBuilder" />
83+
<Class name="com.azure.identity.implementation.IdentityClient" />
84+
<Class name="com.azure.identity.implementation.IdentitySyncClient" />
85+
<Class name="com.azure.identity.implementation.LinuxKeyRingAccessor$GError" />
86+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL" />
87+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$PCREDENTIAL" />
88+
</Or>
89+
</Match>
90+
<Match>
91+
<Bug pattern="NM_FIELD_NAMING_CONVENTION" />
92+
<Or>
93+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL" />
94+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL_ATTRIBUTE" />
95+
</Or>
96+
</Match>
97+
<Match>
98+
<Bug pattern="NP_NULL_ON_SOME_PATH" />
99+
<Or>
100+
<Class name="com.azure.identity.implementation.IdentityClient" />
101+
<Class name="com.azure.identity.implementation.ValidationUtilTests" />
102+
</Or>
103+
</Match>
104+
<Match>
105+
<Bug pattern="NP_NULL_ON_SOME_PATH_EXCEPTION" />
106+
<Class name="com.azure.identity.implementation.IdentityClient" />
107+
</Match>
108+
<Match>
109+
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
110+
<Or>
111+
<Class name="com.azure.identity.implementation.IdentityClientTests" />
112+
<Class name="com.azure.identity.implementation.SynchronizedAccessorTests" />
113+
<Class name="com.azure.identity.implementation.util.ValidationUtil" />
114+
<Class name="com.azure.jedis.Authenticator" />
115+
<Class name="com.azure.lettuce.sample.HellloWorld" />
116+
<Class name="com.azure.lettuce.sample.withcredentialprovider.AuthenticateWithTokenCache$AzureRedisCredentials" />
117+
<Class name="com.azure.lettuce.sample.withcredentialprovider.HandleReauthentication$AzureRedisCredentials" />
118+
<Class name="com.azure.lettuce.sample.withcredentialprovider.HelloWorld$AzureRedisCredentials" />
119+
<Class name="com.azure.redisson.sample.HelloWorld" />
120+
</Or>
121+
</Match>
122+
<Match>
123+
<Bug pattern="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" />
124+
<Class name="com.azure.identity.implementation.WindowsCredentialAccessor" />
125+
</Match>
126+
<Match>
127+
<Bug pattern="OBL_UNSATISFIED_OBLIGATION" />
128+
<Class name="com.azure.identity.credential.JavaDocCodeSnippets" />
129+
</Match>
130+
<Match>
131+
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
132+
<Class name="com.azure.identity.implementation.IdentityClient" />
133+
</Match>
134+
<Match>
135+
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" />
136+
<Class name="com.azure.identity.implementation.IdentityClient" />
137+
</Match>
138+
<Match>
139+
<Bug pattern="REC_CATCH_EXCEPTION" />
140+
<Or>
141+
<Class name="com.azure.identity.DeviceCodeCredential" />
142+
<Class name="com.azure.identity.InteractiveBrowserCredential" />
143+
<Class name="com.azure.identity.UsernamePasswordCredential" />
144+
<Class name="com.azure.identity.implementation.IdentitySyncClient" />
145+
</Or>
146+
</Match>
147+
<Match>
148+
<Bug pattern="SE_NO_SERIALVERSIONID" />
149+
<Class name="com.azure.identity.implementation.ValidationUtilTests$TestFile" />
150+
</Match>
151+
<Match>
152+
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
153+
<Class name="com.azure.identity.implementation.MsalAuthenticationAccount" />
154+
</Match>
155+
<Match>
156+
<Bug pattern="UI_INHERITANCE_UNSAFE_GETRESOURCE" />
157+
<Class name="com.azure.identity.implementation.IdentityClientTests" />
158+
</Match>
159+
<Match>
160+
<Bug pattern="UL_UNRELEASED_LOCK_EXCEPTION_PATH" />
161+
<Class name="com.azure.jedis.Authenticator" />
162+
</Match>
163+
<Match>
164+
<Bug pattern="UPM_UNCALLED_PRIVATE_METHOD" />
165+
<Or>
166+
<Class name="com.azure.identity.implementation.IdentityClient" />
167+
<Class name="com.azure.jedis.implementation.authentication.AccessTokenCache" />
168+
</Or>
169+
</Match>
170+
<Match>
171+
<Bug pattern="UUF_UNUSED_FIELD" />
172+
<Class name="com.azure.identity.implementation.IdentityClientOptions" />
173+
</Match>
174+
<Match>
175+
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD" />
176+
<Or>
177+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL" />
178+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL_ATTRIBUTE" />
179+
</Or>
180+
</Match>
181+
<Match>
182+
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" />
183+
<Or>
184+
<Class name="com.azure.identity.implementation.PersistentTokenCacheImpl" />
185+
<Class name="com.azure.jedis.AzureJedisClientBuilder" />
186+
</Or>
187+
</Match>
188+
<Match>
189+
<Bug pattern="UWF_UNWRITTEN_FIELD" />
190+
<Class name="com.azure.identity.implementation.LinuxKeyRingAccessor$GError" />
191+
</Match>
192+
<Match>
193+
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD" />
194+
<Or>
195+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$CREDENTIAL" />
196+
<Class name="com.azure.identity.implementation.WindowsCredentialApi$PCREDENTIAL" />
197+
</Or>
198+
</Match>
199+
<Match>
200+
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE" />
201+
<Class name="com.azure.identity.implementation.models.AzureCliTokenTests" />
202+
</Match>
203+
</FindBugsFilter>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
/**
5+
* Package containing implementation model classes.
6+
*/
7+
package com.azure.identity.implementation.models;

sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Jedis/java/com/azure/jedis/ApiManager.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* Manages Api calls for Azure Redis Client.
1818
*/
1919
class ApiManager {
20-
private final ClientLogger clientLogger = new ClientLogger(ApiManager.class);
21-
private Authenticator authenticator;
22-
private RetryStrategy retryStrategy;
20+
private static final ClientLogger LOGGER = new ClientLogger(ApiManager.class);
21+
private final Authenticator authenticator;
22+
private final RetryStrategy retryStrategy;
2323

2424
/**
2525
* Creates an instance of ApiManager class.
@@ -43,23 +43,24 @@ <T> T execute(Supplier<T> supplier, AzureJedisClient jedisClient, RetryStrategy
4343
authenticator.authenticateIfRequired(jedisClient);
4444
T out = supplier.get();
4545
String methodName = getMethodName(4);
46-
clientLogger.log(LogLevel.INFORMATIONAL, () -> "Successfully executed API call: " + methodName);
46+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Successfully executed API call: " + methodName);
4747
return out;
4848
} catch (Exception e) {
4949
retries++;
5050
if (retries >= retryStrategy.getMaxRetries()) {
51-
throw clientLogger.logThrowableAsError((e instanceof JedisException ? (JedisException) e : new RuntimeException(e)));
51+
throw LOGGER.logThrowableAsError((e instanceof JedisException ? (JedisException) e : new RuntimeException(e)));
5252
}
53-
clientLogger.logThrowableAsWarning((e instanceof JedisException ? (JedisException) e : new RuntimeException(e)));
54-
clientLogger.log(LogLevel.INFORMATIONAL, () -> "Retrying to execute the command.");
53+
LOGGER.logThrowableAsWarning((e instanceof JedisException ? (JedisException) e : new RuntimeException(e)));
54+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Retrying to execute the command.");
5555
try {
5656
Thread.sleep(retryStrategy.calculateRetryDelay(retries).toMillis());
5757
} catch (InterruptedException ex) {
58-
throw clientLogger.logExceptionAsError(new RuntimeException(ex));
58+
e.addSuppressed(ex);
59+
throw LOGGER.logExceptionAsError(new RuntimeException(ex));
5960
}
6061
}
6162
}
62-
throw clientLogger.logExceptionAsError(new IllegalStateException("Failed to execute the command"));
63+
throw LOGGER.logExceptionAsError(new IllegalStateException("Failed to execute the command"));
6364
}
6465

6566
private RetryStrategy getRetryStrategy(RetryOptions retryOptions) {

sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Jedis/java/com/azure/jedis/Authenticator.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package com.azure.jedis;
55

66
import com.azure.core.credential.TokenRequestContext;
7-
import com.azure.core.util.logging.ClientLogger;
87
import com.azure.jedis.implementation.authentication.AccessTokenCache;
98
import com.azure.jedis.implementation.authentication.AccessTokenResult;
109
import com.azure.jedis.implementation.authentication.AuthenticationInfo;
@@ -19,11 +18,10 @@
1918
* Authenticator manages authentication for Jedis client connection.
2019
*/
2120
class Authenticator {
22-
private final ClientLogger clientLogger = new ClientLogger(Authenticator.class);
23-
private AccessTokenCache tokenCache;
24-
private TokenRequestContext tokenRequestContext;
21+
private final AccessTokenCache tokenCache;
22+
private final TokenRequestContext tokenRequestContext;
2523
private volatile boolean authenticated;
26-
ReentrantLock lock;
24+
private final ReentrantLock lock;
2725

2826
Authenticator(AccessTokenCache tokenCache) {
2927
this.tokenCache = tokenCache;

0 commit comments

Comments
 (0)