Kinvey/js-sdk

View on GitHub

Showing 146 of 349 total issues

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

    Function collection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export function collection(collectionName: string, type = DataStoreType.Cache, options: any = {}) {
      let datastore;
      const tagWasPassed = options && ('tag' in options);
    
      if (collectionName == null || !isString(collectionName)) {
    Severity: Minor
    Found in packages/js-sdk/src/datastore/index.ts - About 1 hr 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 35 lines of code (exceeds 25 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 1 hr to fix

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

      export function loginWithPopup(clientId: string, redirectUri: string, version?: string | number): Promise<string> {
        return new Promise(async (resolve, reject) => {
          const url = formatKinveyAuthUrl(`/${getVersion(version)}/oauth/auth`, {
            client_id: clientId,
            redirect_uri: redirectUri,
      Severity: Minor
      Found in packages/js-sdk/src/user/mic/loginWithPopup.ts - About 1 hr to fix

        Function findById has 32 lines of code (exceeds 25 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/networkstore.ts - About 1 hr to fix

          Function create has a Cognitive Complexity of 11 (exceeds 5 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

          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 matches has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            matches(field: string, expression: any, options: { ignoreCase?: boolean, multiline?: boolean, extended?: boolean, dotMatchesAll?: boolean } = {}) {
              const flags = [];
              let regExp = expression;
          
              if (!(regExp instanceof RegExp)) {
          Severity: Minor
          Found in packages/js-sdk/src/query.ts - About 1 hr 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 31 lines of code (exceeds 25 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 1 hr to fix

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

              Function find has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                find(query?: Query, options: any = {}) {
                  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/datastore/networkstore.ts - About 1 hr to fix

                Function uploadFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export async function uploadFile(url: string, file: any, metadata: any, options: any = {}): Promise<any> {
                  const { count = 0, maxBackoff = MAX_BACKOFF } = options;
                  let { start = 0 } = options;
                
                  const requestHeaders = new HttpHeaders(options.headers);
                Severity: Minor
                Found in packages/js-sdk/src/files/upload.ts - About 1 hr to fix

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

                    Function _createMany has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private async _createMany(docs: any, options: any = {}) {
                        const apiVersion = getApiVersion();
                        if (apiVersion < 5) {
                          throw new KinveyError('Unable to create an array of entities. Please create entities one by one or use API version 5 or newer.');
                        }
                    Severity: Minor
                    Found in packages/js-sdk/src/datastore/cachestore.ts - About 1 hr to fix

                      Function stream has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          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/networkstore.ts - About 1 hr to fix

                        Function count has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          count(query?: Query, options: any = {}) {
                            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/datastore/networkstore.ts - About 1 hr to fix

                          Function update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async update(data: object, options: { timeout?: number } = {}) {
                              const body = Object.assign({}, this.data, data);
                          
                              if (!data) {
                                throw new KinveyError('No user was provided to be updated.');
                          Severity: Minor
                          Found in packages/js-sdk/src/user/user.ts - About 1 hr to fix

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

                              Function stream has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  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/datastore/networkstore.ts - About 1 hr to fix

                                Function constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  constructor(popupWindow: Window) {
                                    super();
                                    this.popupWindow = popupWindow;
                                    this.interval = window.setInterval(() => {
                                      if (popupWindow.closed) {
                                Severity: Minor
                                Found in packages/html5-sdk/src/popup.ts - About 1 hr 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 find has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  find(query?: Query, options: any = {}) {
                                    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/datastore/networkstore.ts - About 1 hr 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

                                Severity
                                Category
                                Status
                                Source
                                Language