remotestorage/remotestorage.js

View on GitHub
src/cachinglayer.ts

Summary

Maintainability
D
2 days
Test Coverage

Function getLatest has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function getLatest (node: RSNode): any {
  if (typeof (node) !== 'object' || typeof (node.path) !== 'string') {
    return;
  }
  if (isFolder(node.path)) {
Severity: Minor
Found in src/cachinglayer.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 put has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  async put (path: string, body: unknown, contentType: string): Promise<RSNodes> {
    const paths = pathsFromRoot(path);

    function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
      try {
Severity: Minor
Found in src/cachinglayer.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 _doUpdateNodes has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private _doUpdateNodes(paths: string[], _processNodes: ProcessNodes, promise) {
    if (this._updateNodesRunning) {
      this._updateNodesQueued.push({
        paths: paths,
        cb: _processNodes,
Severity: Major
Found in src/cachinglayer.ts - About 2 hrs to fix

    Function get has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async get (path: string, maxAge: number, queueGetRequest: (path2: string) => Promise<QueuedRequestResponse>): Promise<QueuedRequestResponse> {
    
        if (typeof (maxAge) === 'number') {
          return this.getNodes(pathsFromRoot(path))
            .then((objs) => {
    Severity: Minor
    Found in src/cachinglayer.ts - About 1 hr to fix

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

        async put (path: string, body: unknown, contentType: string): Promise<RSNodes> {
          const paths = pathsFromRoot(path);
      
          function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
            try {
      Severity: Minor
      Found in src/cachinglayer.ts - About 1 hr to fix

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

          delete (path: string): unknown {
            const paths = pathsFromRoot(path);
        
            return this._updateNodes(paths, function (nodePaths, nodes) {
              for (let i = 0, len = nodePaths.length; i < len; i++) {
        Severity: Minor
        Found in src/cachinglayer.ts - About 1 hr to fix

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

          function getLatest (node: RSNode): any {
            if (typeof (node) !== 'object' || typeof (node.path) !== 'string') {
              return;
            }
            if (isFolder(node.path)) {
          Severity: Minor
          Found in src/cachinglayer.ts - About 1 hr to fix

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

              migrate(node: RSNode): RSNode {
                if (typeof (node) === 'object' && !node.common) {
                  node.common = {};
                  if (typeof (node.path) === 'string') {
                    if (node.path.substr(-1) === '/' && typeof (node.body) === 'object') {
            Severity: Minor
            Found in src/cachinglayer.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 _processNodes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _processNodes(nodePaths: string[], nodes: RSNodes): RSNodes {
                  try {
                    for (let i = 0, len = nodePaths.length; i < len; i++) {
                      const nodePath = nodePaths[i];
                      let node = nodes[nodePath];
            Severity: Minor
            Found in src/cachinglayer.ts - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                              if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) {
                                delete node.itemsMap[i];
                              }
              Severity: Major
              Found in src/cachinglayer.ts - About 45 mins to fix

                Avoid too many return statements within this function.
                Open

                      return node.common;
                Severity: Major
                Found in src/cachinglayer.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return {
                          body: node.body,
                          contentType: node.contentType
                        };
                  Severity: Major
                  Found in src/cachinglayer.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return;
                    Severity: Major
                    Found in src/cachinglayer.ts - About 30 mins to fix

                      Function isOutdated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function isOutdated (nodes: RSNodes, maxAge: number): boolean {
                        for (const path in nodes) {
                          if (nodes[path] && nodes[path].remote) {
                            return true;
                          }
                      Severity: Minor
                      Found in src/cachinglayer.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