Skip to content

Commit fbac22d

Browse files
committed
fix: sonar issues
1 parent ba492ef commit fbac22d

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

src/lib/auth-vue-store-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ export default class AuthStoreManager extends VueAuthStore {
5050
public getToken(): string {
5151
const token = this.allStores
5252
.map((store) => store.getToken())
53-
.filter((token) => !!token)[0];
53+
.filter(Boolean)[0];
5454
return token || this.options.Vue.$data.token;
5555
}
5656

5757
public getUser(): AuthUser {
5858
const user = this.allStores
5959
.map((store) => store.getUser())
60-
.filter((user) => !!user)[0];
60+
.filter(Boolean)[0];
6161
return user || this.options.Vue.$data.user;
6262
}
6363

src/lib/auth.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ export default class Auth {
5353
private readonly http: AuthVueHttp;
5454
private readonly storeManager: AuthStoreManager;
5555

56-
constructor(private readonly Vue: any, options: VueAuthOptions = {} as VueAuthOptions) {
56+
constructor(private readonly VueInstance: any, options: VueAuthOptions = {} as VueAuthOptions) {
5757
this.options = {
5858
...DEFAULT_OPTIONS,
5959
...options,
60-
Vue: new this.Vue({
60+
Vue: new this.VueInstance({
6161
data() {
6262
return {
6363
user: null,
@@ -66,9 +66,9 @@ export default class Auth {
6666
},
6767
}),
6868
};
69-
this.storeManager = new AuthStoreManager(this.Vue, this.options);
70-
const router = new AuthVueRouter(this.Vue, this.options, this.storeManager);
71-
this.http = new AuthVueHttp(this.Vue, this.options, this.storeManager, router);
69+
this.storeManager = new AuthStoreManager(this.VueInstance, this.options);
70+
const router = new AuthVueRouter(this.VueInstance, this.options, this.storeManager);
71+
this.http = new AuthVueHttp(this.VueInstance, this.options, this.storeManager, router);
7272
}
7373

7474
public login(loginInfo: VueAuthLogin) {

src/lib/store/store-cookie.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class StoreCookie extends VueAuthStore {
1515
} else if (typeof document.cookie === 'string') {
1616
this.documentCookie = true;
1717
}
18-
} catch (_) {
18+
} catch {
1919
console.warn('[vue-auth-plugin]: Cookie store not enabled');
2020
this.enabled = false;
2121
}
@@ -62,15 +62,16 @@ export default class StoreCookie extends VueAuthStore {
6262
const cookiePair = document.cookie.replace(/;\s+/g, ';')
6363
.split(';')
6464
.map((str) => str.replace(/\s+=\s+/g, '=').split('='))
65-
.filter((cookiePair) => cookiePair[0] === name)
65+
.filter((cp) => cp[0] === name)
6666
.pop() || [];
6767
result = cookiePair[1] || null;
6868
}
6969
try {
7070
return JSON.parse(result);
71-
} catch (_) {
72-
return result;
71+
} catch {
72+
console.error('[vue-auth-plugin] Invalid cookie value');
7373
}
74+
return result;
7475
}
7576

7677
private setCookie(name: string | undefined, value: any) {

tests/integration/customToken.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('With customToken', () => {
6262
const response = await localVue.$auth.login({ username: 'test', password: 'test' });
6363
expect(response).toBeTruthy();
6464
expect(localVue.$auth.token()).toEqual(sampleToken);
65-
} catch (_) {
65+
} catch {
6666
fail('Login is good');
6767
}
6868
});

tests/integration/functions.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('Functions', () => {
108108
try {
109109
const response = await localVue.$auth.login({ username: 'test', password: 'test' });
110110
expect(response).toBeTruthy();
111-
} catch (_) {
111+
} catch {
112112
fail('Login is good');
113113
}
114114
});
@@ -217,7 +217,7 @@ describe('Functions', () => {
217217
const response = await localVue.$auth.login({ username: 'test', password: 'test' });
218218
expect(response).toBeTruthy();
219219
expect(spyFetch).toHaveBeenCalledTimes(1);
220-
} catch (_) {
220+
} catch {
221221
fail('Login is good');
222222
}
223223
});
@@ -240,7 +240,7 @@ describe('Functions', () => {
240240
const response = await localVue.$auth.login({ username: 'test', password: 'test' });
241241
expect(response).toBeTruthy();
242242
expect(spyFetch).toHaveBeenCalledTimes(1);
243-
} catch (_) {
243+
} catch {
244244
fail('Login is good');
245245
}
246246
});

0 commit comments

Comments
 (0)