dappros/ethora

View on GitHub
client-reactnative/src/helpers/login/socialLoginHandle.ts

Summary

Maintainability
C
1 day
Test Coverage

Function handleAppleLogin has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const handleAppleLogin = async (
  defaultToken: string,
  loginUser: any,
  registerSocialUser: any,
  type: string,
Severity: Major
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts - About 2 hrs to fix

Function loginOrRegisterSocialUser has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const loginOrRegisterSocialUser = async (
  user: any,

  defaultToken: string,
  loginUser: any,
Severity: Minor
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts - About 1 hr to fix

Function handleFaceBookLogin has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const handleFaceBookLogin = async (
  defaultToken: string,
  loginUser: any,
  registerSocialUser: any,
  type: string,
Severity: Minor
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts - About 1 hr to fix

Function loginOrRegisterSocialUser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const loginOrRegisterSocialUser = async (
  user: any,

  defaultToken: string,
  loginUser: any,
Severity: Minor
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts - About 35 mins to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    let user = {
      loginType: 'apple',
      authToken: id_token,
      displayName: '',
      uid: hashUID,
Severity: Major
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts and 1 other location - About 1 hr to fix
client-reactnative/src/helpers/login/socialLoginHandle.ts on lines 280..288

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    let user = {
      loginType: 'apple',
      authToken: identityToken,
      displayName: '',
      uid: hashUID,
Severity: Major
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts and 1 other location - About 1 hr to fix
client-reactnative/src/helpers/login/socialLoginHandle.ts on lines 248..256

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      ) {
        Alert.alert(
          'No Internet Connection',
          'Connect your phone to the Internet by using an available Wi-Fi or cellular network.',
          [
Severity: Major
Found in client-reactnative/src/helpers/login/socialLoginHandle.ts and 1 other location - About 1 hr to fix
client-reactnative/src/Screens/Chat/ChatDetailsScreen.tsx on lines 154..165

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Throwing plain strings (not instances of Error) gives no stack traces
Open

    throw 'User cancelled the login process';

Rule: no-string-throw

Flags throwing plain strings or concatenations of strings.

Rationale

Example – Doing it right

// throwing an Error from typical function, whether sync or async
if (!productToAdd) {
    throw new Error("How can I add new product when no value provided?");
}

Example – Anti Pattern

// throwing a string lacks any stack trace information and other important data properties
if (!productToAdd) {
    throw ("How can I add new product when no value provided?");
}

Only Error objects contain a .stack member equivalent to the current stack trace. Primitives such as strings do not.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-throw": true

For more information see this page.

Throwing plain strings (not instances of Error) gives no stack traces
Open

    throw 'Something went wrong obtaining access token';

Rule: no-string-throw

Flags throwing plain strings or concatenations of strings.

Rationale

Example – Doing it right

// throwing an Error from typical function, whether sync or async
if (!productToAdd) {
    throw new Error("How can I add new product when no value provided?");
}

Example – Anti Pattern

// throwing a string lacks any stack trace information and other important data properties
if (!productToAdd) {
    throw ("How can I add new product when no value provided?");
}

Only Error objects contain a .stack member equivalent to the current stack trace. Primitives such as strings do not.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-throw": true

For more information see this page.

Identifier 'user' is never reassigned; use 'const' instead of 'let'.
Open

    let user = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Identifier 'user' is never reassigned; use 'const' instead of 'let'.
Open

    let user = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Identifier 'user' is never reassigned; use 'const' instead of 'let'.
Open

  let user = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Identifier 'appleUser' is never reassigned; use 'const' instead of 'let'.
Open

  let appleUser = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Expected property shorthand in object literal ('{loginType}').
Open

              loginType: loginType,

Rule: object-literal-shorthand

Enforces/disallows use of ES6 object literal shorthand.

Notes
  • Has Fix

Config

"always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

Examples
"object-literal-shorthand": true
"object-literal-shorthand": true,never
"object-literal-shorthand": true,[object Object]
Schema
{
  "oneOf": [
    {
      "type": "string",
      "enum": [
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "property": {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        "method": {
          "type": "string",
          "enum": [
            "never"
          ]
        }
      },
      "minProperties": 1,
      "maxProperties": 2
    }
  ]
}

For more information see this page.

Identifier 'hashUID' is never reassigned; use 'const' instead of 'let'.
Open

    let hashUID = await sha256(data.user.uid);

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Identifier 'facebookUser' is never reassigned; use 'const' instead of 'let'.
Open

  let facebookUser = await auth().signInWithCredential(facebookCredential);

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Identifier 'user' is never reassigned; use 'const' instead of 'let'.
Open

  let user = {

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

Throwing plain strings (not instances of Error) gives no stack traces
Open

      throw 'Apple Sign-In failed - no identify token returned';

Rule: no-string-throw

Flags throwing plain strings or concatenations of strings.

Rationale

Example – Doing it right

// throwing an Error from typical function, whether sync or async
if (!productToAdd) {
    throw new Error("How can I add new product when no value provided?");
}

Example – Anti Pattern

// throwing a string lacks any stack trace information and other important data properties
if (!productToAdd) {
    throw ("How can I add new product when no value provided?");
}

Only Error objects contain a .stack member equivalent to the current stack trace. Primitives such as strings do not.

Notes
  • Has Fix

Config

Not configurable.

Examples
"no-string-throw": true

For more information see this page.

Identifier 'hashUID' is never reassigned; use 'const' instead of 'let'.
Open

    let hashUID = await sha256(data.user.uid);

Rule: prefer-const

Requires that variable declarations use const instead of let and var if possible.

If a variable is only assigned to once when it is declared, it should be declared using 'const'

Notes
  • Has Fix

Config

An optional object containing the property "destructuring" with two possible values:

  • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
  • "all" - Only warns if all variables in destructuring can be const.
Examples
"prefer-const": true
"prefer-const": true,[object Object]
Schema
{
  "type": "object",
  "properties": {
    "destructuring": {
      "type": "string",
      "enum": [
        "all",
        "any"
      ]
    }
  }
}

For more information see this page.

There are no issues that match your filters.

Category
Status