Skip to content

Commit 1b9558a

Browse files
committed
Enabled lint rule for 'this' checks
1 parent 9108c26 commit 1b9558a

16 files changed

+63
-72
lines changed

FirebaseAdmin/FirebaseAdmin.Tests/Auth/ServiceAccountSignerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task Signer()
3636
"[email protected]", await signer.GetKeyIdAsync());
3737
byte[] data = Encoding.UTF8.GetBytes("Hello world");
3838
byte[] signature = signer.SignDataAsync(data).Result;
39-
Assert.True(Verify(data, signature));
39+
Assert.True(this.Verify(data, signature));
4040
}
4141

4242
[Fact]

FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAppTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ internal class MockService : IFirebaseService
222222

223223
public void Delete()
224224
{
225-
Deleted = true;
225+
this.Deleted = true;
226226
}
227227
}
228228

FirebaseAdmin/FirebaseAdmin.Tests/MockClock.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public class MockClock : IClock
2424

2525
public MockClock()
2626
{
27-
Now = DateTime.Now;
27+
this.Now = DateTime.Now;
2828
}
2929

3030
public DateTime Now
3131
{
32-
get { return UtcNow.ToLocalTime(); }
33-
set { UtcNow = value.ToUniversalTime(); }
32+
get { return this.UtcNow.ToLocalTime(); }
33+
set { this.UtcNow = value.ToUniversalTime(); }
3434
}
3535

3636
public DateTime UtcNow

FirebaseAdmin/FirebaseAdmin.Tests/MockMessageHandler.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal class MockMessageHandler : CountableMessageHandler
3434
{
3535
public MockMessageHandler()
3636
{
37-
StatusCode = HttpStatusCode.OK;
37+
this.StatusCode = HttpStatusCode.OK;
3838
}
3939

4040
public delegate void SetHeaders(HttpResponseHeaders header);
@@ -52,32 +52,32 @@ protected override async Task<HttpResponseMessage> SendAsyncCore(
5252
{
5353
if (request.Content != null)
5454
{
55-
Request = await request.Content.ReadAsStringAsync();
55+
this.Request = await request.Content.ReadAsStringAsync();
5656
}
5757
else
5858
{
59-
Request = null;
59+
this.Request = null;
6060
}
6161

6262
var resp = new HttpResponseMessage();
6363
string json;
64-
if (Response is byte[])
64+
if (this.Response is byte[])
6565
{
66-
json = Encoding.UTF8.GetString(Response as byte[]);
66+
json = Encoding.UTF8.GetString(this.Response as byte[]);
6767
}
68-
else if (Response is string)
68+
else if (this.Response is string)
6969
{
70-
json = Response as string;
70+
json = this.Response as string;
7171
}
7272
else
7373
{
74-
json = NewtonsoftJsonSerializer.Instance.Serialize(Response);
74+
json = NewtonsoftJsonSerializer.Instance.Serialize(this.Response);
7575
}
7676

77-
resp.StatusCode = StatusCode;
78-
if (ApplyHeaders != null)
77+
resp.StatusCode = this.StatusCode;
78+
if (this.ApplyHeaders != null)
7979
{
80-
ApplyHeaders(resp.Headers);
80+
this.ApplyHeaders(resp.Headers);
8181
}
8282

8383
resp.Content = new StringContent(json, Encoding.UTF8, "application/json");
@@ -104,7 +104,7 @@ protected sealed override Task<HttpResponseMessage> SendAsync(
104104
HttpRequestMessage request, CancellationToken cancellationToken)
105105
{
106106
Interlocked.Increment(ref this.calls);
107-
return SendAsyncCore(request, cancellationToken);
107+
return this.SendAsyncCore(request, cancellationToken);
108108
}
109109

110110
protected abstract Task<HttpResponseMessage> SendAsyncCore(

FirebaseAdmin/FirebaseAdmin/AppOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public AppOptions() { }
3232

3333
internal AppOptions(AppOptions options)
3434
{
35-
Credential = options.Credential;
36-
ProjectId = options.ProjectId;
37-
ServiceAccountId = options.ServiceAccountId;
35+
this.Credential = options.Credential;
36+
this.ProjectId = options.ProjectId;
37+
this.ServiceAccountId = options.ServiceAccountId;
3838
}
3939

4040
/// <summary>

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseAuth.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static FirebaseAuth GetAuth(FirebaseApp app)
111111
/// 128 characters.</param>
112112
public async Task<string> CreateCustomTokenAsync(string uid)
113113
{
114-
return await CreateCustomTokenAsync(uid, default(CancellationToken));
114+
return await this.CreateCustomTokenAsync(uid, default(CancellationToken));
115115
}
116116

117117
/// <summary>
@@ -150,7 +150,7 @@ public async Task<string> CreateCustomTokenAsync(string uid)
150150
public async Task<string> CreateCustomTokenAsync(
151151
string uid, CancellationToken cancellationToken)
152152
{
153-
return await CreateCustomTokenAsync(uid, null, cancellationToken);
153+
return await this.CreateCustomTokenAsync(uid, null, cancellationToken);
154154
}
155155

156156
/// <summary>
@@ -177,7 +177,7 @@ public async Task<string> CreateCustomTokenAsync(
177177
public async Task<string> CreateCustomTokenAsync(
178178
string uid, IDictionary<string, object> developerClaims)
179179
{
180-
return await CreateCustomTokenAsync(uid, developerClaims, default(CancellationToken));
180+
return await this.CreateCustomTokenAsync(uid, developerClaims, default(CancellationToken));
181181
}
182182

183183
/// <summary>
@@ -241,7 +241,7 @@ public async Task<string> CreateCustomTokenAsync(
241241
/// <param name="idToken">A Firebase ID token string to parse and verify.</param>
242242
public async Task<FirebaseToken> VerifyIdTokenAsync(string idToken)
243243
{
244-
return await VerifyIdTokenAsync(idToken, default(CancellationToken));
244+
return await this.VerifyIdTokenAsync(idToken, default(CancellationToken));
245245
}
246246

247247
/// <summary>

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseToken.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public sealed class FirebaseToken
2525
{
2626
internal FirebaseToken(FirebaseTokenArgs args)
2727
{
28-
Issuer = args.Issuer;
29-
Subject = args.Subject;
30-
Audience = args.Audience;
31-
ExpirationTimeSeconds = args.ExpirationTimeSeconds;
32-
IssuedAtTimeSeconds = args.IssuedAtTimeSeconds;
33-
Uid = args.Subject;
34-
Claims = args.Claims;
28+
this.Issuer = args.Issuer;
29+
this.Subject = args.Subject;
30+
this.Audience = args.Audience;
31+
this.ExpirationTimeSeconds = args.ExpirationTimeSeconds;
32+
this.IssuedAtTimeSeconds = args.IssuedAtTimeSeconds;
33+
this.Uid = args.Subject;
34+
this.Claims = args.Claims;
3535
}
3636

3737
/// <summary>

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseTokenFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public async Task<string> CreateCustomTokenAsync(
152152

153153
public void Dispose()
154154
{
155-
signer.Dispose();
155+
this.signer.Dispose();
156156
}
157157

158158
internal class CustomTokenPayload : JsonWebToken.Payload

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseTokenVerifier.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ internal sealed class FirebaseTokenVerifier
3838
private const string FirebaseAudience = "https://identitytoolkit.googleapis.com/"
3939
+ "google.identity.identitytoolkit.v1.IdentityToolkit";
4040

41-
// See http://oid-info.com/get/2.16.840.1.101.3.4.2.1
42-
private const string Sha256Oid = "2.16.840.1.101.3.4.2.1";
43-
4441
private static readonly IReadOnlyList<string> StandardClaims =
4542
ImmutableList.Create<string>("iss", "aud", "exp", "iat", "sub", "uid");
4643

@@ -54,7 +51,7 @@ internal sealed class FirebaseTokenVerifier
5451

5552
internal FirebaseTokenVerifier(FirebaseTokenVerifierArgs args)
5653
{
57-
ProjectId = args.ProjectId.ThrowIfNullOrEmpty(nameof(args.ProjectId));
54+
this.ProjectId = args.ProjectId.ThrowIfNullOrEmpty(nameof(args.ProjectId));
5855
this.shortName = args.ShortName.ThrowIfNullOrEmpty(nameof(args.ShortName));
5956
this.operation = args.Operation.ThrowIfNullOrEmpty(nameof(args.Operation));
6057
this.url = args.Url.ThrowIfNullOrEmpty(nameof(args.Url));
@@ -118,7 +115,7 @@ internal async Task<FirebaseToken> VerifyTokenAsync(
118115
+ "project as the credential used to initialize this SDK.";
119116
var verifyTokenMessage = $"See {this.url} for details on how to retrieve a value "
120117
+ $"{this.shortName}.";
121-
var issuer = this.issuer + ProjectId;
118+
var issuer = this.issuer + this.ProjectId;
122119
string error = null;
123120
if (string.IsNullOrEmpty(header.KeyId))
124121
{
@@ -142,9 +139,9 @@ internal async Task<FirebaseToken> VerifyTokenAsync(
142139
error = $"Firebase {this.shortName} has incorrect algorithm. Expected RS256 but got "
143140
+ $"{header.Algorithm}. {verifyTokenMessage}";
144141
}
145-
else if (ProjectId != payload.Audience)
142+
else if (this.ProjectId != payload.Audience)
146143
{
147-
error = $"{this.shortName} has incorrect audience (aud) claim. Expected {ProjectId} "
144+
error = $"{this.shortName} has incorrect audience (aud) claim. Expected {this.ProjectId} "
148145
+ $"but got {payload.Audience}. {projectIdMessage} {verifyTokenMessage}";
149146
}
150147
else if (payload.Issuer != issuer)
@@ -174,7 +171,7 @@ internal async Task<FirebaseToken> VerifyTokenAsync(
174171
throw new FirebaseException(error);
175172
}
176173

177-
await VerifySignatureAsync(segments, header.KeyId, cancellationToken)
174+
await this.VerifySignatureAsync(segments, header.KeyId, cancellationToken)
178175
.ConfigureAwait(false);
179176
var allClaims = JwtUtils.Decode<Dictionary<string, object>>(segments[1]);
180177

FirebaseAdmin/FirebaseAdmin/Auth/HttpPublicKeySource.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,26 @@ public HttpPublicKeySource(string certUrl, IClock clock, HttpClientFactory clien
6666
public async Task<IReadOnlyList<PublicKey>> GetPublicKeysAsync(
6767
CancellationToken cancellationToken = default(CancellationToken))
6868
{
69-
if (cachedKeys == null || clock.UtcNow >= expirationTime)
69+
if (this.cachedKeys == null || this.clock.UtcNow >= this.expirationTime)
7070
{
71-
await cacheLock.WaitAsync(cancellationToken).ConfigureAwait(false);
71+
await this.cacheLock.WaitAsync(cancellationToken).ConfigureAwait(false);
7272

7373
try
7474
{
75-
var now = clock.UtcNow;
76-
if (cachedKeys == null || now >= expirationTime)
75+
var now = this.clock.UtcNow;
76+
if (this.cachedKeys == null || now >= this.expirationTime)
7777
{
78-
using (var httpClient = clientFactory.CreateDefaultHttpClient())
78+
using (var httpClient = this.clientFactory.CreateDefaultHttpClient())
7979
{
80-
var response = await httpClient.GetAsync(certUrl, cancellationToken)
80+
var response = await httpClient.GetAsync(this.certUrl, cancellationToken)
8181
.ConfigureAwait(false);
8282
response.EnsureSuccessStatusCode();
83-
cachedKeys = ParseKeys(await response.Content.ReadAsStringAsync()
83+
this.cachedKeys = this.ParseKeys(await response.Content.ReadAsStringAsync()
8484
.ConfigureAwait(false));
8585
var cacheControl = response.Headers.CacheControl;
8686
if (cacheControl?.MaxAge != null)
8787
{
88-
expirationTime = now.Add(cacheControl.MaxAge.Value)
88+
this.expirationTime = now.Add(cacheControl.MaxAge.Value)
8989
.Subtract(ClockSkew);
9090
}
9191
}
@@ -97,11 +97,11 @@ public async Task<IReadOnlyList<PublicKey>> GetPublicKeysAsync(
9797
}
9898
finally
9999
{
100-
cacheLock.Release();
100+
this.cacheLock.Release();
101101
}
102102
}
103103

104-
return cachedKeys;
104+
return this.cachedKeys;
105105
}
106106

107107
private IReadOnlyList<PublicKey> ParseKeys(string json)

0 commit comments

Comments
 (0)