Kinvey/js-sdk

View on GitHub

Showing 146 of 349 total issues

Function push has 205 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async push(providedQuery?: Query, options?: any) {
    if (this.isPushInProgress()) {
      throw new SyncError('Data is already being pushed to the backend. Please wait for it to complete before pushing new data to the backend.');
    }

Severity: Major
Found in packages/js-sdk/src/datastore/sync.ts - About 1 day to fix

    Function exports has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function (hookArgs) {
      return new Promise((resolve, reject) => {
        const appDirectoryPath = ((hookArgs && hookArgs.checkForChangesOpts && hookArgs.checkForChangesOpts.projectData && hookArgs.checkForChangesOpts.projectData) || hookArgs.projectData).appDirectoryPath;
        if (!appDirectoryPath) {
          reject(new Error('Unable to get path to app directory'));

    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

    File query.ts has 457 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { isString, isNumber, isPlainObject, isObject, isEmpty, isArray, cloneDeep, pick } from 'lodash-es';
    import sift from 'sift';
    import { QueryError } from './errors/query';
    
    const UNSUPPORTED_CONDITIONS = ['$nearSphere'];
    Severity: Minor
    Found in packages/js-sdk/src/query.ts - About 7 hrs to fix

      File cachestore.ts has 435 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { isArray, times } from 'lodash-es';
      import { Observable } from 'rxjs';
      import { Query } from '../query';
      import { KinveyError } from '../errors/kinvey';
      import { MissingConfigurationError } from '../errors/missingConfiguration';
      Severity: Minor
      Found in packages/js-sdk/src/datastore/cachestore.ts - About 6 hrs to fix

        Function setAuthorization has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

          async setAuthorization(auth: KinveyHttpAuth): Promise<void> {
            const appKey = getAppKey();
            const appSecret = getAppSecret();
            const masterSecret = getMasterSecret();
            const session = await getSession();
        Severity: Minor
        Found in packages/js-sdk/src/http/headers.ts - About 6 hrs 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 push has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

          async push(providedQuery?: Query, options?: any) {
            if (this.isPushInProgress()) {
              throw new SyncError('Data is already being pushed to the backend. Please wait for it to complete before pushing new data to the backend.');
            }
        
        
        Severity: Minor
        Found in packages/js-sdk/src/datastore/sync.ts - About 5 hrs 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 error has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

          get error() {
            if (!this.isSuccess()) {
              if (isPlainObject(this.data)) {
                const message = this.data.message || this.data.description;
                const name = this.data.name || this.data.error;
        Severity: Minor
        Found in packages/js-sdk/src/http/response.ts - About 5 hrs 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

        Query has 39 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class Query {
          private _parent?: Query;
          public filter: any;
          private _fields?: string[];
          private _sort?: any;
        Severity: Minor
        Found in packages/js-sdk/src/query.ts - About 5 hrs to fix

          Function _pullInternal has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

            async _pullInternal(query: Query = new Query(), pullOptions: any = {}, options: { paginationCountsOnly?: boolean } = {}) : Promise<any[]|number> {
              const network = new NetworkStore(this.collectionName);
              const cache = new DataStoreCache(this.collectionName, this.tag);
              const queryCache = new QueryCache(this.tag);
              const useDeltaSet = pullOptions.useDeltaSet === true || this.useDeltaSet;
          Severity: Minor
          Found in packages/js-sdk/src/datastore/cachestore.ts - About 4 hrs 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

          File networkstore.ts has 335 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { isArray, cloneDeep } from 'lodash-es';
          import { Observable } from 'rxjs';
          import { getDeviceId } from '../device';
          import { Aggregation } from '../aggregation';
          import { Query } from '../query';
          Severity: Minor
          Found in packages/js-sdk/src/datastore/networkstore.ts - About 4 hrs to fix

            Function execute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

              async execute(retry = true): Promise<HttpResponse> {
                if (this.auth) {
                  await this.headers.setAuthorization(this.auth);
                }
            
            
            Severity: Minor
            Found in packages/js-sdk/src/http/request.ts - About 3 hrs 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

            File sync.ts has 320 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Query } from '../query';
            import { SyncError } from '../errors/sync';
            import { NotFoundError } from '../errors/notFound';
            import { NetworkStore } from './networkstore';
            import { DataStoreCache, SyncCache, SyncEvent } from './cache';
            Severity: Minor
            Found in packages/js-sdk/src/datastore/sync.ts - About 3 hrs to fix

              Function error has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                get error() {
                  if (!this.isSuccess()) {
                    if (isPlainObject(this.data)) {
                      const message = this.data.message || this.data.description;
                      const name = this.data.name || this.data.error;
              Severity: Major
              Found in packages/js-sdk/src/http/response.ts - About 3 hrs to fix

                Function _pullInternal has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async _pullInternal(query: Query = new Query(), pullOptions: any = {}, options: { paginationCountsOnly?: boolean } = {}) : Promise<any[]|number> {
                    const network = new NetworkStore(this.collectionName);
                    const cache = new DataStoreCache(this.collectionName, this.tag);
                    const queryCache = new QueryCache(this.tag);
                    const useDeltaSet = pullOptions.useDeltaSet === true || this.useDeltaSet;
                Severity: Major
                Found in packages/js-sdk/src/datastore/cachestore.ts - About 3 hrs to fix

                  User has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export class User {
                    public data: UserData;
                  
                    constructor(data: UserData = {}) {
                      this.data = data;
                  Severity: Minor
                  Found in packages/js-sdk/src/user/user.ts - About 3 hrs to fix

                    CacheStore has 26 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    export class CacheStore {
                      public collectionName: string;
                      public tag?: string;
                      public useDeltaSet: boolean;
                      public useAutoPagination: boolean;
                    Severity: Minor
                    Found in packages/js-sdk/src/datastore/cachestore.ts - About 3 hrs to fix

                      Function execute has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function execute(dbName: string, tableName: string, sqlQueries: any, write = false): Promise<any> {
                        const escapedTableName = `"${tableName}"`;
                        const isMaster = tableName === MASTER_TABLE_NAME;
                      
                        return new Promise((resolve, reject) => {
                      Severity: Major
                      Found in packages/html5-sdk/src/storage/websql.ts - About 2 hrs to fix

                        File user.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { isArray } from 'lodash-es';
                        import { Acl } from '../acl';
                        import { Kmd } from '../kmd';
                        import { getDeviceId } from '../device';
                        import {
                        Severity: Minor
                        Found in packages/js-sdk/src/user/user.ts - About 2 hrs to fix

                          Function open has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                          Open

                            async open(url = '/', options: PopupOptions = {}) {
                              if (this._open !== true) {
                                const activity = Application.android.startActivity || Application.android.foregroundActivity;
                                let shouldClose = false;
                                let success = false;
                          Severity: Minor
                          Found in packages/nativescript-sdk/src/nativescript/popup/popup.android.ts - About 2 hrs 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 setAuthorization has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async setAuthorization(auth: KinveyHttpAuth): Promise<void> {
                              const appKey = getAppKey();
                              const appSecret = getAppSecret();
                              const masterSecret = getMasterSecret();
                              const session = await getSession();
                          Severity: Major
                          Found in packages/js-sdk/src/http/headers.ts - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language