Kinvey/js-sdk

View on GitHub

Showing 146 of 349 total issues

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

  async find(query?: Query, options: any = {}) {
    if (query && !(query instanceof Query)) {
      throw new KinveyError('query is not an instance of the Query class.')
    }

Severity: Minor
Found in packages/js-sdk/src/datastore/autostore.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 count has a Cognitive Complexity of 10 (exceeds 5 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

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 uploadFile has a Cognitive Complexity of 10 (exceeds 5 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

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 getTokenWithCode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function getTokenWithCode(code: string, clientId: string, redirectUri: string, options: GetTokenWithCodeOptions = {}) {
  const request = new KinveyHttpRequest({
    method: HttpRequestMethod.POST,
    headers: new KinveyHttpHeaders({
      'Content-Type': () => 'application/x-www-form-urlencoded',
Severity: Minor
Found in packages/js-sdk/src/user/mic/getTokenWithCode.ts - About 1 hr to fix

    Function findById has 27 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/cachestore.ts - About 1 hr to fix

      Function createEntity has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const createEntity = async (syncDocId, entityId): Promise<any> => {
            let doc: any = await cache.findById(entityId);
            let local = false;
      
            try {
      Severity: Minor
      Found in packages/js-sdk/src/datastore/sync.ts - About 1 hr to fix

        Function send has 27 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/react-native-sdk/src/httpAdapter.ts - About 1 hr to fix

          Function process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            process(docs: any = []) {
              // eslint-disable-next-line no-new-func
              const reduceFn = new Function('doc', 'out', this.reduceFn.replace(/function[\s\S]*?\([\s\S]*?\)/, ''));
              let filteredDocs = docs;
          
          
          Severity: Minor
          Found in packages/js-sdk/src/aggregation.ts - About 1 hr to fix

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

              async find(query?: Query, options: any = {}) {
                if (query && !(query instanceof Query)) {
                  throw new KinveyError('query is not an instance of the Query class.')
                }
            
            
            Severity: Minor
            Found in packages/js-sdk/src/datastore/autostore.ts - About 1 hr to fix

              Function getTokenWithUsernamePassword has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function getTokenWithUsernamePassword(username: string, password: string, clientId: string, options: GetTokenWithUsernamePasswordOptions = {}) {
                const request = new KinveyHttpRequest({
                  method: HttpRequestMethod.POST,
                  headers: new KinveyHttpHeaders({
                    'Content-Type': () => 'application/x-www-form-urlencoded',
              Severity: Minor
              Found in packages/js-sdk/src/user/mic/getTokenWithUsernamePassword.ts - About 1 hr to fix

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

                function uploadFile(url: string, file: File, metadata: any, options: any = {}): Promise<any> {
                  return new Promise((resolve, reject) => {
                    const session = bghttp.session('file-upload');
                    const request = {
                      url,
                Severity: Minor
                Found in packages/nativescript-sdk/src/nativescript/files/upload.ts - About 1 hr to fix

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

                    Function matches has 26 lines of code (exceeds 25 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

                      Function stream has 26 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 save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          save(docs: any): Promise<any> {
                            return queue.add(async () => {
                              let docsToSave = docs;
                              let singular = false;
                        
                        
                        Severity: Minor
                        Found in packages/js-sdk/src/storage.ts - About 1 hr to fix

                          Function send has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export async function send(request: any): Promise<any> {
                            const { url, method, headers, body, timeout } = request;
                            const kinveyUrlRegex = /kinvey\.com/gm;
                          
                            // Add kinvey device information headers
                          Severity: Minor
                          Found in packages/nativescript-sdk/src/nativescript/httpAdapter.ts - About 1 hr to fix

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

                                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 findById has a Cognitive Complexity of 9 (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/networkstore.ts - About 55 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 !== micInfoPlistFileContent) {
                                          fs.writeFileSync(destinationInfoPlistFile, micInfoPlistFileContent);
                                        }

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

                                export async function signup(data?: object | User, options: { timeout?: number } = {}) {
                                  if (data && !isPlainObject(data)) {
                                    throw new KinveyError('The provided data must be an object.');
                                  }
                                
                                
                                Severity: Minor
                                Found in packages/js-sdk/src/user/signup.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

                                Severity
                                Category
                                Status
                                Source
                                Language