Kinvey/js-sdk

View on GitHub

Showing 146 of 349 total issues

Function batchCreateEntities has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const batchCreateEntities = async (): Promise<any> => {
      const localIdsToRemove = [];
      const entitiesForInsert = await Promise.all(
        syncDocsForInsert.map(async (doc, index) => {
          const entity = await cache.findById(doc.entityId);
Severity: Major
Found in packages/js-sdk/src/datastore/sync.ts - About 2 hrs to fix

    Function removeById has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      async removeById(id: string, options: any = {}) {
        const autoSync = options.autoSync === true || this.autoSync;
        const cache = new DataStoreCache(this.collectionName, this.tag);
        const sync = new Sync(this.collectionName, this.tag);
        let count = 0;
    Severity: Minor
    Found in packages/js-sdk/src/datastore/cachestore.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 process has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      process(docs: object[] = []) {
        const queryPlainObject = this.toPlainObject();
    
        if (!Array.isArray(docs)) {
          throw new Error('data argument must be of type: Array.');
    Severity: Major
    Found in packages/js-sdk/src/query.ts - About 2 hrs to fix

      UserService has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Injectable({
        providedIn: 'root'
      })
      export class UserService {
        constructor(@Inject(KinveyConfigToken) config: any) {
      Severity: Minor
      Found in packages/nativescript-sdk/src/angular/user.service.ts - About 2 hrs to fix

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

        export class User extends KinveyUser {
          static exists(username: string, options?: ExistsOptions) {
            return exists(username, options);
          }
        
        
        Severity: Minor
        Found in packages/js-sdk/src/user/index.ts - About 2 hrs to fix

          UserService has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Injectable({
            providedIn: 'root'
          })
          export class UserService {
            constructor(@Inject(KinveyConfigToken) config: any) {
          Severity: Minor
          Found in packages/angular-sdk/src/user.service.ts - About 2 hrs to fix

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

              open(objectStoreName: string, write = false, success: any, error: any, force = false) {
                try {
                  if (this.db) {
                    if (this.db.objectStoreNames.contains(objectStoreName)) {
                      const mode = write ? IndexedDBTransactionMode.readWrite : IndexedDBTransactionMode.readOnly;
            Severity: Minor
            Found in packages/html5-sdk/src/storage/indexeddb.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 process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              process(docs: object[] = []) {
                const queryPlainObject = this.toPlainObject();
            
                if (!Array.isArray(docs)) {
                  throw new Error('data argument must be of type: Array.');
            Severity: Minor
            Found in packages/js-sdk/src/query.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 open has 56 lines of code (exceeds 25 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: Major
            Found in packages/nativescript-sdk/src/nativescript/popup/popup.android.ts - About 2 hrs to fix

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

              function execute(dbName, tableName, sqlQueries, write = false) {
                const escapedTableName = `"${tableName}"`;
                const isMaster = tableName === MASTER_TABLE_NAME;
              
                return new SQLite(dbName)
              Severity: Major
              Found in packages/nativescript-sdk/src/nativescript/storage/sqlite.ts - About 2 hrs to fix

                Function findById has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  findById(id: string, options: any = {}) {
                    const stream = Observable.create(async (observer: any) => {
                      try {
                        // if (!id) {
                        //   throw new Error('No id was provided. A valid id is required.');
                Severity: Minor
                Found in packages/js-sdk/src/datastore/cachestore.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 open has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  open(url = '/') {
                    if (this._open !== true) {
                      const webViewIntercept = (webview: any, error: any, url: string): boolean => {
                        let urlStr = '';
                
                
                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 _refreshMICSession has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async _refreshMICSession(micSession) {
                    const kinveyMICIdentityKey = 'kinveyAuth';
                
                    try {
                      // Refresh the MIC session
                Severity: Major
                Found in packages/js-sdk/src/http/request.ts - About 2 hrs to fix

                  File indexeddb.ts has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  const DB_CACHE: any = {};
                  
                  const IndexedDBTransactionMode = {
                    readWrite: 'readwrite',
                    readOnly: 'readonly',
                  Severity: Minor
                  Found in packages/html5-sdk/src/storage/indexeddb.ts - About 2 hrs to fix

                    Function exports has 50 lines of code (exceeds 25 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'));

                      Function open has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        open(objectStoreName: string, write = false, success: any, error: any, force = false) {
                          try {
                            if (this.db) {
                              if (this.db.objectStoreNames.contains(objectStoreName)) {
                                const mode = write ? IndexedDBTransactionMode.readWrite : IndexedDBTransactionMode.readOnly;
                      Severity: Minor
                      Found in packages/html5-sdk/src/storage/indexeddb.ts - About 1 hr to fix

                        Function create has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async create(docs: any, options: any = {}) {
                            const batchSize = 100;
                            const apiVersion = getApiVersion();
                        
                            if (isArray(docs)) {
                        Severity: Minor
                        Found in packages/js-sdk/src/datastore/networkstore.ts - About 1 hr to fix

                          Function _loginWithMFA has 42 lines of code (exceeds 25 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 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                if (!appDirectoryPath) {
                                  reject(new Error('Unable to get path to app directory'));
                                } else {
                                  const platform = (((hookArgs && hookArgs.checkForChangesOpts) || hookArgs.prepareData).platform || '').toLowerCase();
                                  const pathToPackageJson = path.join(appDirectoryPath, 'package.json');

                              Function execute has 36 lines of code (exceeds 25 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 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language