src/services/google/oauth.ts
Function fetchRefreshToken
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function fetchRefreshToken(): Promise<boolean> {
Log.d('fetchRefreshToken')
return new Promise(async (resolve) => {
const S = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const state = Array.from(crypto.getRandomValues(new Uint8Array(12)))
Function logout
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async logout(): Promise<boolean> {
let logoutResult
const tokenType = await Storage.get(STORAGE_KEY.TOKEN_TYPE)
if (tokenType === TOKEN_TYPE.WEB) {
Function ensureToken
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async ensureToken(): Promise<string> {
const token = (await Storage.get(STORAGE_KEY.ACCESS_TOKEN)) as string
try {
const response = await fetch(
`https://oauth2.googleapis.com/tokeninfo?access_token=${token}`,
Function updateToken
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
async updateToken(): Promise<boolean> {
try {
// Remove cached AuthToken if exists.
const tokenType = await Storage.get(STORAGE_KEY.TOKEN_TYPE)
const token = (await Storage.get(STORAGE_KEY.ACCESS_TOKEN)) as string
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ensureToken
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
async ensureToken(): Promise<string> {
const token = (await Storage.get(STORAGE_KEY.ACCESS_TOKEN)) as string
try {
const response = await fetch(
`https://oauth2.googleapis.com/tokeninfo?access_token=${token}`,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"