Kinvey/js-sdk

View on GitHub

Showing 146 of 349 total issues

Avoid deeply nested control flow statements.
Open

    } else if (auth === KinveyHttpAuth.All) {
      try {
        return await this.setAuthorization(KinveyHttpAuth.Session);
      } catch (error) {
        try {
Severity: Major
Found in packages/js-sdk/src/http/headers.ts - About 45 mins to fix

    Function init has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function init(config: Config) {
      // Check that an appKey was provided
      if (config.kinveyConfig.appKey === null || config.kinveyConfig.appKey === undefined) {
        throw new KinveyError('No app key was provided to initialize the Kinvey JavaScript SDK.');
      }
    Severity: Minor
    Found in packages/js-sdk/src/init.ts - About 45 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

    Function completeMFALoginRetryable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    async function completeMFALoginRetryable(
      mfaComplete: (authenticator: string, context: MFAContext) => Promise<MFACompleteResult>,
      context: MFAContext,
      maxRetriesCount: number
    ): Promise<any> {
    Severity: Minor
    Found in packages/js-sdk/src/user/loginWithMFA.ts - About 45 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

    Function send has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function send(request: any) {
      const { url, method, headers, body, timeout } = request;
      let response;
    
      // Add kinvey device information headers
    Severity: Minor
    Found in packages/node-sdk/src/httpAdapter.ts - About 45 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

    Avoid deeply nested control flow statements.
    Open

                if (pushResult.error) {
                  count -= 1;
                }
    Severity: Major
    Found in packages/js-sdk/src/datastore/cachestore.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            if (!mfaSessionToken) {
              throw new KinveyError('Missing MFA session token to authorize the request.');
            }
      Severity: Major
      Found in packages/js-sdk/src/http/headers.ts - About 45 mins to fix

        Function _loginWithMFA has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        async function _loginWithMFA(
          username: string,
          password: string,
          selectAuthenticator: (authenticators: object[], context: MFAContext) => Promise<string>,
          mfaComplete: (authenticator: string, context: MFAContext) => Promise<MFACompleteResult>,
        Severity: Minor
        Found in packages/js-sdk/src/user/loginWithMFA.ts - About 45 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

        Function send has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function send(request: any) {
          const { url, method, headers, body, timeout } = request;
          let response;
        
          // Add kinvey device information headers
        Severity: Minor
        Found in packages/react-native-sdk/src/httpAdapter.ts - About 45 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

        Avoid deeply nested control flow statements.
        Open

                  if (currentContent !== defaultInfoPlistFileContent) {
                    fs.writeFileSync(destinationInfoPlistFile, defaultInfoPlistFileContent);
                  }

          Consider simplifying this complex logical expression.
          Open

                  } else if (name === 'EntityNotFound'
                    || name === 'CollectionNotFound'
                    || name === 'AppNotFound'
                    || name === 'UserNotFound'
                    || name === 'BlobNotFound'
          Severity: Major
          Found in packages/js-sdk/src/http/response.ts - About 40 mins to fix

            Function loginWithMFA has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              username: string,
              password: string,
              selectAuthenticator: (authenticators: object[], context: MFAContext) => Promise<string>,
              mfaComplete: (authenticator: string, context: MFAContext) => Promise<MFACompleteResult>,
              options: LoginOptions = {}
            Severity: Minor
            Found in packages/js-sdk/src/user/loginWithMFA.ts - About 35 mins to fix

              Function _loginWithMFA has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                username: string,
                password: string,
                selectAuthenticator: (authenticators: object[], context: MFAContext) => Promise<string>,
                mfaComplete: (authenticator: string, context: MFAContext) => Promise<MFACompleteResult>,
                options: LoginOptions = {}
              Severity: Minor
              Found in packages/js-sdk/src/user/loginWithMFA.ts - About 35 mins to fix

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

                export async function loginWithMICUsingResourceOwnerCredentials(username: string, password: string, options: MICOptions = {}) {
                  const activeUser = await getActiveUser();
                  const { micId } = options;
                  let clientId = getAppKey();
                
                
                Severity: Minor
                Found in packages/js-sdk/src/user/loginWithMICUsingResourceOwnerCredentials.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

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

                  addFilter(field: string, ...args: any) {
                    if (!isString(field)) {
                      throw new QueryError('The field argument must be a string.');
                    }
                
                
                Severity: Minor
                Found in packages/js-sdk/src/query.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

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

                  group(aggregation: Aggregation, options: any = {}) {
                    const stream = Observable.create(async (observer: any) => {
                      try {
                        if (!(aggregation instanceof Aggregation)) {
                          throw new KinveyError('Invalid aggregation. It must be an instance of the Aggregation class.');
                Severity: Minor
                Found in packages/js-sdk/src/datastore/networkstore.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

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

                  private join(operator: string, queries: any) {
                    // Cast, validate, and parse arguments. If `queries` are supplied, obtain
                    // the `filter` for joining. The eventual return function will be the
                    // current query.
                    let result = new Query(this);
                Severity: Minor
                Found in packages/js-sdk/src/query.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

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

                export async function send(request: any) {
                  const { url, method, headers, body, timeout } = request;
                  let response;
                
                  // Add kinvey device information headers
                Severity: Minor
                Found in packages/html5-sdk/src/httpAdapter.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

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

                  async addSyncEvent(event: SyncEvent, docs: any) {
                    const syncCache = new SyncCache(this.tag);
                    let singular = false;
                    let syncDocs: any = [];
                    let docsToSync = docs;
                Severity: Minor
                Found in packages/js-sdk/src/datastore/sync.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

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

                export function lookup(query?: Query, options: LookupOptions = {}) {
                  const stream = Observable.create(async (observer: any) => {
                    try {
                      if (query && !(query instanceof Query)) {
                        throw new KinveyError('Invalid query. It must be an instance of the Query class.');
                Severity: Minor
                Found in packages/js-sdk/src/user/lookup.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

                Avoid too many return statements within this function.
                Open

                          return new BLError(message, debug);
                Severity: Major
                Found in packages/js-sdk/src/http/response.ts - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language