remotestorage/remotestorage.js

View on GitHub
src/remotestorage.ts

Summary

Maintainability
D
1 day
Test Coverage

RemoteStorage has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

class RemoteStorage {
  /**
   * Pending get/put/delete calls
   * @private
   */
Severity: Minor
Found in src/remotestorage.ts - About 4 hrs to fix

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

      constructor (cfg?: object) {
        // Initial configuration property settings.
        // TODO use modern JS to merge object properties
        if (typeof cfg === 'object') { extend(config, cfg); }
    
    
    Severity: Minor
    Found in src/remotestorage.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

    Function constructor has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor (cfg?: object) {
        // Initial configuration property settings.
        // TODO use modern JS to merge object properties
        if (typeof cfg === 'object') { extend(config, cfg); }
    
    
    Severity: Major
    Found in src/remotestorage.ts - About 2 hrs to fix

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

        connect (userAddress: string, token?: string): void {
          this.setBackend('remotestorage');
          if (userAddress.indexOf('@') < 0 && !userAddress.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/)) {
            this._emit('error', new RemoteStorage.DiscoveryError("Not a valid user address or URL."));
            return;
      Severity: Minor
      Found in src/remotestorage.ts - About 1 hr to fix

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

          disconnect (): void {
            if (this.remote) {
              this.remote.configure({
                userAddress: null,
                href: null,
        Severity: Minor
        Found in src/remotestorage.ts - About 1 hr to fix

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

            setApiKeys (apiKeys: {[key in ApiKeyType]?: string}): void | boolean {
              const validTypes: string[] = [ApiKeyType.GOOGLE, ApiKeyType.DROPBOX];
              if (typeof apiKeys !== 'object' || !Object.keys(apiKeys).every(type => validTypes.includes(type))) {
                console.error('setApiKeys() was called with invalid arguments') ;
                return false;
          Severity: Minor
          Found in src/remotestorage.ts - About 1 hr to fix

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

              connect (userAddress: string, token?: string): void {
                this.setBackend('remotestorage');
                if (userAddress.indexOf('@') < 0 && !userAddress.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/)) {
                  this._emit('error', new RemoteStorage.DiscoveryError("Not a valid user address or URL."));
                  return;
            Severity: Minor
            Found in src/remotestorage.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 authorize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              authorize (options: AuthorizeOptions): void {
                this.access.setStorageType(this.remote.storageApi);
                if (typeof options.scope === 'undefined') {
                  options.scope = this.access.scopeParameter;
                }
            Severity: Minor
            Found in src/remotestorage.ts - About 25 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

            There are no issues that match your filters.

            Category
            Status