remotestorage/remotestorage-server

View on GitHub

Showing 37 of 45 total issues

Function condMet has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.prototype.condMet = function(cond, username, path, cb) {
  this.getRevision(username, path, function(err, revision) {
    var i, found;
    if (err) {
      cb(err);
Severity: Minor
Found in lib/main.js - About 4 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

File requests.js has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var url = require('url'),
  sha1 = require('sha1'),
  async = require('async');

module.exports = function(pathPrefix, scopesInstance, mainInstance) {
Severity: Minor
Found in lib/requests.js - About 3 hrs to fix

    Function getFolderDescription has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.prototype.getFolderDescription = function(username, path, folderFormat, cb) {
      this.getContent(username, path, function(err, content) {
        var i, itemNames, revisions = {}, todo = 1, error, errorSent;
        if (content) {
          try {
    Severity: Minor
    Found in lib/main.js - 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 doHead has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.prototype.doHead = function(req, res, release, username, path, folderContentType) {
      if (path.substr(-1) === '/') {
        this.mainInstance.getRevision(username, path, function(err, revision) {
          if (err) {
            this.error(res, err, req.headers.origin);
    Severity: Minor
    Found in lib/requests.js - 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 handleRequest has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.prototype.handleRequest = function(req, res, folderFormat, folderContentType, folder404s) {
      var urlObj = url.parse(req.url, true);
      var path = urlObj.pathname.substring(this.pathPrefix.length);
      var pos = path.indexOf('/');
      var username = path.substring(0, pos);
    Severity: Major
    Found in lib/requests.js - About 2 hrs to fix

      File main.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var sha1 = require('sha1');
      
      module.exports = function(dataStore) {
        this.dataStore = dataStore;
      };
      Severity: Minor
      Found in lib/main.js - About 2 hrs to fix

        Function getFolderDescription has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports.prototype.getFolderDescription = function(username, path, folderFormat, cb) {
          this.getContent(username, path, function(err, content) {
            var i, itemNames, revisions = {}, todo = 1, error, errorSent;
            if (content) {
              try {
        Severity: Minor
        Found in lib/main.js - About 1 hr to fix

          Function revisionsToMap has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports.prototype.revisionsToMap = function(revisions, username, path, cb) {
            var i, items = {}, todo = 1, error, errorSent;
            function doneOne() {
              if (error) {
                if (!errorSent) {
          Severity: Minor
          Found in lib/main.js - About 1 hr to fix

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

            module.exports.prototype.setParents = function(username, pathParts, fileItself, revision, cb) {
              if (pathParts.length <= 1) {
                cb();
              } else {
                var thisPart = pathParts.pop();
            Severity: Minor
            Found in lib/main.js - About 1 hr to fix

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

              module.exports.prototype.getWebfingerLink = function(protocol, host, port, userName, authUrl, webAuthoring) {
                switch (this.specVersion) {
                  case 'draft-dejong-remotestorage-00':
                    return {
                      href: protocol + '://' + host + ':' + port + '/storage/' + userName,
              Severity: Minor
              Found in lib/remotestorage-server.js - About 1 hr to fix

                Function doGet has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports.prototype.doGet = function(req, res, release, username, path, folderFormat, folderContentType) {
                  if (path.substr(-1) === '/') {
                    this.mainInstance.getRevision(username, path, function(err, revision) {
                      if (err) {
                        this.error(res, err, req.headers.origin);
                Severity: Minor
                Found in lib/requests.js - About 1 hr to fix

                  Function may has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports.prototype.may = function(authorizationHeader, username, path, write, cb) {
                    var i, scopeParts, scopes, pathParts;
                    if (write && path.substr(-1) === '/') {
                      cb(null, false);
                    } else if (path[0] !== '/' || username.length === 0) {
                  Severity: Minor
                  Found in lib/scopes.js - About 1 hr to fix

                    Function doHead has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports.prototype.doHead = function(req, res, release, username, path, folderContentType) {
                      if (path.substr(-1) === '/') {
                        this.mainInstance.getRevision(username, path, function(err, revision) {
                          if (err) {
                            this.error(res, err, req.headers.origin);
                    Severity: Minor
                    Found in lib/requests.js - About 1 hr to fix

                      Function condMet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports.prototype.condMet = function(cond, username, path, cb) {
                        this.getRevision(username, path, function(err, revision) {
                          var i, found;
                          if (err) {
                            cb(err);
                      Severity: Minor
                      Found in lib/main.js - About 1 hr to fix

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

                        module.exports.prototype.revisionsToMap = function(revisions, username, path, cb) {
                          var i, items = {}, todo = 1, error, errorSent;
                          function doneOne() {
                            if (error) {
                              if (!errorSent) {
                        Severity: Minor
                        Found in lib/main.js - 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 set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports.prototype.set = function(username, path, dataBuf, contentType, revision, cb) {
                          this.dataStore.set(username, 'content:' + path, dataBuf, function(err1) {
                            if (err1) {
                              cb(err1);
                              return;
                        Severity: Minor
                        Found in lib/main.js - 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

                        Function checkFound has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        module.exports.prototype.checkFound = function(req, res, username, path, folder404s, cb, release) {
                        Severity: Major
                        Found in lib/requests.js - About 50 mins to fix

                          Function doGet has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          module.exports.prototype.doGet = function(req, res, release, username, path, folderFormat, folderContentType) {
                          Severity: Major
                          Found in lib/requests.js - About 50 mins to fix

                            Function checkCondMet has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            module.exports.prototype.checkCondMet = function(req, res, username, path, statusCode, cb, release) {
                            Severity: Major
                            Found in lib/requests.js - About 50 mins to fix

                              Function writeHead has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              module.exports.prototype.writeHead = function(res, status, origin, revision, contentType, contentLength) {
                              Severity: Minor
                              Found in lib/requests.js - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language