remotestorage/remotestorage-server

View on GitHub

Showing 45 of 45 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module.exports.prototype.checkMayWrite = function(req, res, username, path, cb, release) {
  this.scopesInstance.mayWrite(req.headers.authorization, username, path, function(err, answer) {
    if (err) {
      this.error(res, err, req.headers.origin);
      //console.log('checkMayWrite:err calling release');
Severity: Major
Found in lib/requests.js and 1 other location - About 6 hrs to fix
lib/requests.js on lines 93..107

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 160.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module.exports.prototype.checkMayRead = function(req, res, username, path, cb, release) {
  this.scopesInstance.mayRead(req.headers.authorization, username, path, function(err, answer) {
    if (err) {
      this.error(res, err, req.headers.origin);
      //console.log('checkMayRead:err calling release');
Severity: Major
Found in lib/requests.js and 1 other location - About 6 hrs to fix
lib/requests.js on lines 108..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 160.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            } else if (write) {
              cb(null, false);
            } else {
              pathParts = path.split('/');//e.g. ['public', 'foo', 'bar', '']
              cb(null, (pathParts[1] === 'public') && (path.substr(-1) !== '/'));
          Severity: Major
          Found in lib/scopes.js and 1 other location - About 1 hr to fix
          lib/scopes.js on lines 41..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                if (write) {
                  cb(null, false);
                } else {
                  pathParts = path.split('/');//e.g. ['public', 'foo', 'bar', '']
                  cb(null, (pathParts[1] === 'public') && (path.substr(-1) !== '/'));
          Severity: Major
          Found in lib/scopes.js and 1 other location - About 1 hr to fix
          lib/scopes.js on lines 49..54

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    this.mainInstance.set(username, path, body, contentType, revision, function(err) {
                      if (err) {
                        this.error(res, err, req.headers.origin);
                      } else {
                        this.writeRaw(res, undefined, undefined, req.headers.origin, revision);
                Severity: Major
                Found in lib/requests.js and 1 other location - About 1 hr to fix
                lib/requests.js on lines 261..269

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 69.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            this.mainInstance.getContent(username, path, function(err3, content) {
                              if (err) {
                                this.error(res, err, req.headers.origin);
                              } else {
                                this.writeRaw(res, contentType, content, req.headers.origin, revision);
                Severity: Major
                Found in lib/requests.js and 1 other location - About 1 hr to fix
                lib/requests.js on lines 291..299

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 69.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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
                        Severity
                        Category
                        Status
                        Source
                        Language