lib/fs.js

Summary

Maintainability
F
2 wks
Test Coverage

File fs.js has 1412 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
Severity: Major
Found in lib/fs.js - About 3 days to fix

    Function realpathSync has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    fs.realpathSync = function realpathSync(p, cache) {
      // make p is absolute
      p = pathModule.resolve(p);
    
      if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
    Severity: Minor
    Found in lib/fs.js - About 5 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 realpath has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    fs.realpath = function realpath(p, cache, cb) {
      if (!util.isFunction(cb)) {
        cb = maybeCallback(cache);
        cache = null;
      }
    Severity: Minor
    Found in lib/fs.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

    Function realpath has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    fs.realpath = function realpath(p, cache, cb) {
      if (!util.isFunction(cb)) {
        cb = maybeCallback(cache);
        cache = null;
      }
    Severity: Major
    Found in lib/fs.js - About 3 hrs to fix

      Function readFile has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      fs.readFile = function(path, options, callback_) {
        var callback = maybeCallback(arguments[arguments.length - 1]);
      
        if (util.isFunction(options) || !options) {
          options = { encoding: null, flag: 'r' };
      Severity: Major
      Found in lib/fs.js - About 3 hrs to fix

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

        fs.readFileSync = function(path, options) {
          if (!options) {
            options = { encoding: null, flag: 'r' };
          } else if (util.isString(options)) {
            options = { encoding: options, flag: 'r' };
        Severity: Minor
        Found in lib/fs.js - 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 realpathSync has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        fs.realpathSync = function realpathSync(p, cache) {
          // make p is absolute
          p = pathModule.resolve(p);
        
          if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
        Severity: Major
        Found in lib/fs.js - About 2 hrs to fix

          Function readFileSync has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          fs.readFileSync = function(path, options) {
            if (!options) {
              options = { encoding: null, flag: 'r' };
            } else if (util.isString(options)) {
              options = { encoding: options, flag: 'r' };
          Severity: Major
          Found in lib/fs.js - About 2 hrs to fix

            Function readFile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            fs.readFile = function(path, options, callback_) {
              var callback = maybeCallback(arguments[arguments.length - 1]);
            
              if (util.isFunction(options) || !options) {
                options = { encoding: null, flag: 'r' };
            Severity: Minor
            Found in lib/fs.js - 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 ReadStream has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

            function ReadStream(path, options) {
              if (!(this instanceof ReadStream))
                return new ReadStream(path, options);
            
              // a little bit bigger buffer and water marks by default
            Severity: Minor
            Found in lib/fs.js - 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 _read has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            ReadStream.prototype._read = function(n) {
              if (!util.isNumber(this.fd))
                return this.once('open', function() {
                  this._read(n);
                });
            Severity: Minor
            Found in lib/fs.js - 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 Stats has 14 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                dev,
                mode,
                nlink,
                uid,
                gid,
            Severity: Major
            Found in lib/fs.js - About 1 hr to fix

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

              ReadStream.prototype._read = function(n) {
                if (!util.isNumber(this.fd))
                  return this.once('open', function() {
                    this._read(n);
                  });
              Severity: Minor
              Found in lib/fs.js - About 1 hr to fix

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

                function ReadStream(path, options) {
                  if (!(this instanceof ReadStream))
                    return new ReadStream(path, options);
                
                  // a little bit bigger buffer and water marks by default
                Severity: Minor
                Found in lib/fs.js - About 1 hr to fix

                  Function WriteStream has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function WriteStream(path, options) {
                    if (!(this instanceof WriteStream))
                      return new WriteStream(path, options);
                  
                    options = options || {};
                  Severity: Minor
                  Found in lib/fs.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 write has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  fs.write = function(fd, buffer, offset, length, position, callback) {
                    function strWrapper(err, written) {
                      // Retain a reference to buffer so that it can't be GC'ed too soon.
                      callback(err, written || 0, buffer);
                    }
                  Severity: Minor
                  Found in lib/fs.js - About 1 hr to fix

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

                    fs.read = function(fd, buffer, offset, length, position, callback) {
                    Severity: Minor
                    Found in lib/fs.js - About 45 mins to fix

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

                      fs.write = function(fd, buffer, offset, length, position, callback) {
                      Severity: Minor
                      Found in lib/fs.js - About 45 mins to fix

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

                        function writeAll(fd, buffer, offset, length, position, callback) {
                        Severity: Minor
                        Found in lib/fs.js - About 45 mins to fix

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

                          fs.write = function(fd, buffer, offset, length, position, callback) {
                            function strWrapper(err, written) {
                              // Retain a reference to buffer so that it can't be GC'ed too soon.
                              callback(err, written || 0, buffer);
                            }
                          Severity: Minor
                          Found in lib/fs.js - 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 readSync has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          fs.readSync = function(fd, buffer, offset, length, position) {
                          Severity: Minor
                          Found in lib/fs.js - About 35 mins to fix

                            Function writeSync has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            fs.writeSync = function(fd, buffer, offset, length, position) {
                            Severity: Minor
                            Found in lib/fs.js - About 35 mins to fix

                              Function write has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              SyncWriteStream.prototype.write = function(data, arg1, arg2) {
                                var encoding, cb;
                              
                                // parse arguments
                                if (arg1) {
                              Severity: Minor
                              Found in lib/fs.js - About 35 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 lchmodSync has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                fs.lchmodSync = function(path, mode) {
                                  var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
                              
                                  // prefer to return the chmod error, if one occurs,
                                  // but still try to close, and report closing errors if they occur.
                              Severity: Minor
                              Found in lib/fs.js - 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

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

                              fs.writeFileSync = function(path, data, options) {
                                if (!options) {
                                  options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'w' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, mode: 438, flag: 'w' };
                              Severity: Minor
                              Found in lib/fs.js - 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

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

                              fs.exists = function(path, callback) {
                                if (!nullCheck(path, cb)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = cb;
                                binding.stat(pathModule._makeLong(path), req);
                              Severity: Minor
                              Found in lib/fs.js - 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

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

                                if (util.isFunction(options) || !options) {
                                  options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'w' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, mode: 438, flag: 'w' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 1125..1131

                              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 112.

                              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 (util.isFunction(options) || !options) {
                                  options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'a' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, mode: 438, flag: 'a' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 1070..1076

                              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 112.

                              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

                              fs.rename = function(oldPath, newPath, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(oldPath, callback)) return;
                                if (!nullCheck(newPath, callback)) return;
                                var req = new FSReqWrap();
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 859..870

                              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 104.

                              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

                              fs.link = function(srcpath, dstpath, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(srcpath, callback)) return;
                                if (!nullCheck(dstpath, callback)) return;
                              
                              
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 628..637

                              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 104.

                              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 (!options) {
                                  options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'a' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, mode: 438, flag: 'a' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 1094..1100

                              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 100.

                              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 (!options) {
                                  options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'w' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, mode: 438, flag: 'w' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 3 hrs to fix
                              lib/fs.js on lines 1139..1145

                              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 100.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.readlink = function(path, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 707..713
                              lib/fs.js on lines 757..763
                              lib/fs.js on lines 776..782
                              lib/fs.js on lines 784..790
                              lib/fs.js on lines 879..885

                              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 82.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.readdir = function(path, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 707..713
                              lib/fs.js on lines 776..782
                              lib/fs.js on lines 784..790
                              lib/fs.js on lines 806..812
                              lib/fs.js on lines 879..885

                              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 82.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.lstat = function(path, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 707..713
                              lib/fs.js on lines 757..763
                              lib/fs.js on lines 784..790
                              lib/fs.js on lines 806..812
                              lib/fs.js on lines 879..885

                              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 82.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.stat = function(path, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 707..713
                              lib/fs.js on lines 757..763
                              lib/fs.js on lines 776..782
                              lib/fs.js on lines 806..812
                              lib/fs.js on lines 879..885

                              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 82.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.unlink = function(path, callback) {
                                callback = makeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 707..713
                              lib/fs.js on lines 757..763
                              lib/fs.js on lines 776..782
                              lib/fs.js on lines 784..790
                              lib/fs.js on lines 806..812

                              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 82.

                              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 6 locations. Consider refactoring.
                              Open

                              fs.rmdir = function(path, callback) {
                                callback = maybeCallback(callback);
                                if (!nullCheck(path, callback)) return;
                                var req = new FSReqWrap();
                                req.oncomplete = callback;
                              Severity: Major
                              Found in lib/fs.js and 5 other locations - About 2 hrs to fix
                              lib/fs.js on lines 757..763
                              lib/fs.js on lines 776..782
                              lib/fs.js on lines 784..790
                              lib/fs.js on lines 806..812
                              lib/fs.js on lines 879..885

                              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 82.

                              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

                              fs.renameSync = function(oldPath, newPath) {
                                nullCheck(oldPath);
                                nullCheck(newPath);
                                return binding.rename(pathModule._makeLong(oldPath),
                                                      pathModule._makeLong(newPath));
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 872..877

                              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 60.

                              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

                              fs.linkSync = function(srcpath, dstpath) {
                                nullCheck(srcpath);
                                nullCheck(dstpath);
                                return binding.link(pathModule._makeLong(srcpath),
                                                    pathModule._makeLong(dstpath));
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 639..644

                              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 60.

                              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

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

                                if (!options) {
                                  options = { encoding: null, flag: 'r' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, flag: 'r' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 249..255

                              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 59.

                              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

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

                                if (util.isFunction(options) || !options) {
                                  options = { encoding: null, flag: 'r' };
                                } else if (util.isString(options)) {
                                  options = { encoding: options, flag: 'r' };
                                } else if (!util.isObject(options)) {
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 346..352

                              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 59.

                              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 (size === 0) {
                                  // data was collected into the buffers list.
                                  buffer = Buffer.concat(buffers, pos);
                                } else if (pos < size) {
                                  buffer = buffer.slice(0, pos);
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 332..337

                              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 57.

                              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 (size === 0) {
                                      // collected the data into the buffers list.
                                      buffer = Buffer.concat(buffers, pos);
                                    } else if (pos < size) {
                                      buffer = buffer.slice(0, pos);
                              Severity: Major
                              Found in lib/fs.js and 1 other location - About 1 hr to fix
                              lib/fs.js on lines 411..416

                              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 57.

                              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 3 locations. Consider refactoring.
                              Open

                              fs.fstat = function(fd, callback) {
                                var req = new FSReqWrap();
                                req.oncomplete = makeCallback(callback);
                                binding.fstat(fd, req);
                              };
                              Severity: Major
                              Found in lib/fs.js and 2 other locations - About 1 hr to fix
                              lib/fs.js on lines 720..724
                              lib/fs.js on lines 730..734

                              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 55.

                              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 3 locations. Consider refactoring.
                              Open

                              fs.fdatasync = function(fd, callback) {
                                var req = new FSReqWrap();
                                req.oncomplete = makeCallback(callback);
                                binding.fdatasync(fd, req);
                              };
                              Severity: Major
                              Found in lib/fs.js and 2 other locations - About 1 hr to fix
                              lib/fs.js on lines 730..734
                              lib/fs.js on lines 770..774

                              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 55.

                              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 3 locations. Consider refactoring.
                              Open

                              fs.fsync = function(fd, callback) {
                                var req = new FSReqWrap();
                                req.oncomplete = makeCallback(callback);
                                binding.fsync(fd, req);
                              };
                              Severity: Major
                              Found in lib/fs.js and 2 other locations - About 1 hr to fix
                              lib/fs.js on lines 720..724
                              lib/fs.js on lines 770..774

                              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 55.

                              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

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

                                if (util.isFunction(len)) {
                                  callback = len;
                                  len = 0;
                                } else if (util.isUndefined(len)) {
                                  len = 0;
                              Severity: Minor
                              Found in lib/fs.js and 1 other location - About 50 mins to fix
                              lib/fs.js on lines 650..655

                              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 52.

                              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

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

                                if (util.isFunction(len)) {
                                  callback = len;
                                  len = 0;
                                } else if (util.isUndefined(len)) {
                                  len = 0;
                              Severity: Minor
                              Found in lib/fs.js and 1 other location - About 50 mins to fix
                              lib/fs.js on lines 689..694

                              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 52.

                              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

                              There are no issues that match your filters.

                              Category
                              Status