enclose-io/compiler

View on GitHub
current/lib/buffer.js

Summary

Maintainability
F
1 mo
Test Coverage

File buffer.js has 947 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 current/lib/buffer.js - About 2 days to fix

    Function getEncodingOps has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    function getEncodingOps(encoding) {
      encoding += '';
      switch (encoding.length) {
        case 4:
          if (encoding === 'utf8') return encodingOps.utf8;
    Severity: Minor
    Found in current/lib/buffer.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 _fill has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    function _fill(buf, value, offset, end, encoding) {
      if (typeof value === 'string') {
        if (offset === undefined || typeof offset === 'string') {
          encoding = offset;
          offset = 0;
    Severity: Minor
    Found in current/lib/buffer.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 _fill has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _fill(buf, value, offset, end, encoding) {
      if (typeof value === 'string') {
        if (offset === undefined || typeof offset === 'string') {
          encoding = offset;
          offset = 0;
    Severity: Major
    Found in current/lib/buffer.js - About 2 hrs to fix

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

      function _copy(source, target, targetStart, sourceStart, sourceEnd) {
        if (!isUint8Array(source))
          throw new ERR_INVALID_ARG_TYPE('source', ['Buffer', 'Uint8Array'], source);
        if (!isUint8Array(target))
          throw new ERR_INVALID_ARG_TYPE('target', ['Buffer', 'Uint8Array'], target);
      Severity: Minor
      Found in current/lib/buffer.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 from has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      Buffer.from = function from(value, encodingOrOffset, length) {
        if (typeof value === 'string')
          return fromString(value, encodingOrOffset);
      
        if (typeof value === 'object' && value !== null) {
      Severity: Minor
      Found in current/lib/buffer.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 bidirectionalIndexOf has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
        validateBuffer(buffer);
      
        if (typeof byteOffset === 'string') {
          encoding = byteOffset;
      Severity: Minor
      Found in current/lib/buffer.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 getEncodingOps has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getEncodingOps(encoding) {
        encoding += '';
        switch (encoding.length) {
          case 4:
            if (encoding === 'utf8') return encodingOps.utf8;
      Severity: Minor
      Found in current/lib/buffer.js - About 1 hr to fix

        Function fromArrayBuffer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function fromArrayBuffer(obj, byteOffset, length) {
          // Convert byteOffset to integer
          if (byteOffset === undefined) {
            byteOffset = 0;
          } else {
        Severity: Minor
        Found in current/lib/buffer.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 concat has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        Buffer.concat = function concat(list, length) {
          if (!ArrayIsArray(list)) {
            throw new ERR_INVALID_ARG_TYPE('list', 'Array', list);
          }
        
        
        Severity: Minor
        Found in current/lib/buffer.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 a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        Buffer.prototype.write = function write(string, offset, length, encoding) {
          // Buffer#write(string);
          if (offset === undefined) {
            return this.utf8Write(string, 0, this.length);
          }
        Severity: Minor
        Found in current/lib/buffer.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 bidirectionalIndexOf has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
          validateBuffer(buffer);
        
          if (typeof byteOffset === 'string') {
            encoding = byteOffset;
        Severity: Minor
        Found in current/lib/buffer.js - About 1 hr to fix

          Function _copy has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _copy(source, target, targetStart, sourceStart, sourceEnd) {
            if (!isUint8Array(source))
              throw new ERR_INVALID_ARG_TYPE('source', ['Buffer', 'Uint8Array'], source);
            if (!isUint8Array(target))
              throw new ERR_INVALID_ARG_TYPE('target', ['Buffer', 'Uint8Array'], target);
          Severity: Minor
          Found in current/lib/buffer.js - About 1 hr to fix

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

            Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
              const max = INSPECT_MAX_BYTES;
              const actualMax = MathMin(max, this.length);
              const remaining = this.length - max;
              let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
            Severity: Minor
            Found in current/lib/buffer.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 byteLength has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function byteLength(string, encoding) {
              if (typeof string !== 'string') {
                if (isArrayBufferView(string) || isAnyArrayBuffer(string)) {
                  return string.byteLength;
                }
            Severity: Minor
            Found in current/lib/buffer.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 concat has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Buffer.concat = function concat(list, length) {
              if (!ArrayIsArray(list)) {
                throw new ERR_INVALID_ARG_TYPE('list', 'Array', list);
              }
            
            
            Severity: Minor
            Found in current/lib/buffer.js - About 1 hr to fix

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

              Buffer.prototype.compare = function compare(target,
                                                          targetStart,
                                                          targetEnd,
                                                          sourceStart,
                                                          sourceEnd) {
              Severity: Minor
              Found in current/lib/buffer.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 compare has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Buffer.prototype.compare = function compare(target,
                                                          targetStart,
                                                          targetEnd,
                                                          sourceStart,
                                                          sourceEnd) {
              Severity: Minor
              Found in current/lib/buffer.js - About 1 hr to fix

                Function write has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Buffer.prototype.write = function write(string, offset, length, encoding) {
                  // Buffer#write(string);
                  if (offset === undefined) {
                    return this.utf8Write(string, 0, this.length);
                  }
                Severity: Minor
                Found in current/lib/buffer.js - About 1 hr to fix

                  Function from has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Buffer.from = function from(value, encodingOrOffset, length) {
                    if (typeof value === 'string')
                      return fromString(value, encodingOrOffset);
                  
                    if (typeof value === 'object' && value !== null) {
                  Severity: Minor
                  Found in current/lib/buffer.js - About 1 hr to fix

                    Function fromString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function fromString(string, encoding) {
                      let ops;
                      if (typeof encoding !== 'string' || encoding.length === 0) {
                        if (string.length === 0)
                          return new FastBuffer();
                    Severity: Minor
                    Found in current/lib/buffer.js - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

                    Buffer.prototype.toString = function toString(encoding, start, end) {
                      if (arguments.length === 0) {
                        return this.utf8Slice(0, this.length);
                      }
                    
                    
                    Severity: Minor
                    Found in current/lib/buffer.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 _fill has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function _fill(buf, value, offset, end, encoding) {
                    Severity: Minor
                    Found in current/lib/buffer.js - About 35 mins to fix

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

                      Buffer.prototype.compare = function compare(target,
                                                                  targetStart,
                                                                  targetEnd,
                                                                  sourceStart,
                                                                  sourceEnd) {
                      Severity: Minor
                      Found in current/lib/buffer.js - About 35 mins to fix

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

                        function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
                        Severity: Minor
                        Found in current/lib/buffer.js - About 35 mins to fix

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

                          function _copy(source, target, targetStart, sourceStart, sourceEnd) {
                          Severity: Minor
                          Found in current/lib/buffer.js - About 35 mins to fix

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

                            function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
                            Severity: Minor
                            Found in current/lib/buffer.js - About 35 mins to fix

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

                                transcode = function transcode(source, fromEncoding, toEncoding) {
                                  if (!isUint8Array(source)) {
                                    throw new ERR_INVALID_ARG_TYPE('source',
                                                                   ['Buffer', 'Uint8Array'], source);
                                  }
                              Severity: Minor
                              Found in current/lib/buffer.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

                              Avoid too many return statements within this function.
                              Open

                                      return encodingOps.utf16le;
                              Severity: Major
                              Found in current/lib/buffer.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      if (encoding === 'ucs-2') return encodingOps.ucs2;
                                Severity: Major
                                Found in current/lib/buffer.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        if (encoding === 'ascii') return encodingOps.ascii;
                                  Severity: Major
                                  Found in current/lib/buffer.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                          if (encoding === 'utf-8') return encodingOps.utf8;
                                    Severity: Major
                                    Found in current/lib/buffer.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            if (encoding === 'ascii') return encodingOps.ascii;
                                      Severity: Major
                                      Found in current/lib/buffer.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              if (encoding === 'utf-8') return encodingOps.utf8;
                                        Severity: Major
                                        Found in current/lib/buffer.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                if (encoding === 'ucs-2') return encodingOps.ucs2;
                                          Severity: Major
                                          Found in current/lib/buffer.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return fromString(primitive, encodingOrOffset);
                                            Severity: Major
                                            Found in current/lib/buffer.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                    if (encoding === 'base64') return encodingOps.base64;
                                              Severity: Major
                                              Found in current/lib/buffer.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return encodingOps.utf16le;
                                                Severity: Major
                                                Found in current/lib/buffer.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                    return ops.byteLength(string);
                                                  Severity: Major
                                                  Found in current/lib/buffer.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          if (encoding === 'base64') return encodingOps.base64;
                                                    Severity: Major
                                                    Found in current/lib/buffer.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                              return encodingOps.hex;
                                                      Severity: Major
                                                      Found in current/lib/buffer.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                          return ops.slice(this, start, end);
                                                        Severity: Major
                                                        Found in current/lib/buffer.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return encodingOps.latin1;
                                                          Severity: Major
                                                          Found in current/lib/buffer.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                    return encodingOps.latin1;
                                                            Severity: Major
                                                            Found in current/lib/buffer.js - About 30 mins to fix

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

                                                              function adjustOffset(offset, length) {
                                                                // Use Math.trunc() to convert offset to an integer value that can be larger
                                                                // than an Int32. Hence, don't use offset | 0 or similar techniques.
                                                                offset = MathTrunc(offset);
                                                                if (offset === 0) {
                                                              Severity: Minor
                                                              Found in current/lib/buffer.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

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

                                                              const encodingOps = {
                                                                utf8: {
                                                                  encoding: 'utf8',
                                                                  encodingVal: encodingsMap.utf8,
                                                                  byteLength: byteLengthUtf8,
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 4 days to fix
                                                              lts/lib/buffer.js on lines 600..676

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

                                                              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

                                                              function _fill(buf, value, offset, end, encoding) {
                                                                if (typeof value === 'string') {
                                                                  if (offset === undefined || typeof offset === 'string') {
                                                                    encoding = offset;
                                                                    offset = 0;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 days to fix
                                                              lts/lib/buffer.js on lines 969..1038

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

                                                              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

                                                              function getEncodingOps(encoding) {
                                                                encoding += '';
                                                                switch (encoding.length) {
                                                                  case 4:
                                                                    if (encoding === 'utf8') return encodingOps.utf8;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 days to fix
                                                              lts/lib/buffer.js on lines 677..718

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

                                                              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

                                                              function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
                                                                validateBuffer(buffer);
                                                              
                                                                if (typeof byteOffset === 'string') {
                                                                  encoding = byteOffset;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 904..947

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

                                                              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

                                                              Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
                                                                const max = INSPECT_MAX_BYTES;
                                                                const actualMax = MathMin(max, this.length);
                                                                const remaining = this.length - max;
                                                                let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 823..852

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

                                                              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

                                                              Buffer.concat = function concat(list, length) {
                                                                if (!ArrayIsArray(list)) {
                                                                  throw new ERR_INVALID_ARG_TYPE('list', 'Array', list);
                                                                }
                                                              
                                                              
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 546..587

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

                                                              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

                                                              function _copy(source, target, targetStart, sourceStart, sourceEnd) {
                                                                if (!isUint8Array(source))
                                                                  throw new ERR_INVALID_ARG_TYPE('source', ['Buffer', 'Uint8Array'], source);
                                                                if (!isUint8Array(target))
                                                                  throw new ERR_INVALID_ARG_TYPE('target', ['Buffer', 'Uint8Array'], target);
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 206..246

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

                                                              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

                                                              Buffer.prototype.write = function write(string, offset, length, encoding) {
                                                                // Buffer#write(string);
                                                                if (offset === undefined) {
                                                                  return this.utf8Write(string, 0, this.length);
                                                                }
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 1040..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 279.

                                                              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

                                                              Buffer.prototype.compare = function compare(target,
                                                                                                          targetStart,
                                                                                                          targetEnd,
                                                                                                          sourceStart,
                                                                                                          sourceEnd) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 855..893

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

                                                              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

                                                              Buffer.from = function from(value, encodingOrOffset, length) {
                                                                if (typeof value === 'string')
                                                                  return fromString(value, encodingOrOffset);
                                                              
                                                                if (typeof value === 'object' && value !== null) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 304..336

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

                                                              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 (internalBinding('config').hasIntl) {
                                                                const {
                                                                  icuErrName,
                                                                  transcode: _transcode
                                                                } = internalBinding('icu');
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 1173..1201

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

                                                              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

                                                              Buffer.prototype.toString = function toString(encoding, start, end) {
                                                                if (arguments.length === 0) {
                                                                  return this.utf8Slice(0, this.length);
                                                                }
                                                              
                                                              
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 day to fix
                                                              lts/lib/buffer.js on lines 774..804

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

                                                              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

                                                              function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
                                                                if (sourceEnd - sourceStart > target.length - targetStart)
                                                                  sourceEnd = sourceStart + target.length - targetStart;
                                                              
                                                                let nb = sourceEnd - sourceStart;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 7 hrs to fix
                                                              lts/lib/buffer.js on lines 248..266

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

                                                              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

                                                              function byteLength(string, encoding) {
                                                                if (typeof string !== 'string') {
                                                                  if (isArrayBufferView(string) || isAnyArrayBuffer(string)) {
                                                                    return string.byteLength;
                                                                  }
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 7 hrs to fix
                                                              lts/lib/buffer.js on lines 720..743

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

                                                              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

                                                              function fromArrayBuffer(obj, byteOffset, length) {
                                                                // Convert byteOffset to integer
                                                                if (byteOffset === undefined) {
                                                                  byteOffset = 0;
                                                                } else {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 6 hrs to fix
                                                              lts/lib/buffer.js on lines 459..488

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

                                                              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

                                                              Buffer.prototype.swap64 = function swap64() {
                                                                // For Buffer.length < 192, it's generally faster to
                                                                // do the swap in javascript. For larger buffers,
                                                                // dropping down to the native code is faster.
                                                                const len = this.length;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 6 hrs to fix
                                                              lts/lib/buffer.js on lines 1151..1168

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

                                                              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

                                                              function fromStringFast(string, ops) {
                                                                const length = ops.byteLength(string);
                                                              
                                                                if (length >= (Buffer.poolSize >>> 1))
                                                                  return createFromString(string, ops.encodingVal);
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 5 hrs to fix
                                                              lts/lib/buffer.js on lines 423..440

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

                                                              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

                                                              function fromString(string, encoding) {
                                                                let ops;
                                                                if (typeof encoding !== 'string' || encoding.length === 0) {
                                                                  if (string.length === 0)
                                                                    return new FastBuffer();
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 4 hrs to fix
                                                              lts/lib/buffer.js on lines 442..457

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

                                                              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

                                                              Buffer.prototype.swap32 = function swap32() {
                                                                // For Buffer.length < 192, it's generally faster to
                                                                // do the swap in javascript. For larger buffers,
                                                                // dropping down to the native code is faster.
                                                                const len = this.length;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 4 hrs to fix
                                                              lts/lib/buffer.js on lines 1134..1149

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

                                                              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

                                                              function fromArrayLike(obj) {
                                                                if (obj.length <= 0)
                                                                  return new FastBuffer();
                                                                if (obj.length < (Buffer.poolSize >>> 1)) {
                                                                  if (obj.length > (poolSize - poolOffset))
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 4 hrs to fix
                                                              lts/lib/buffer.js on lines 490..503

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

                                                              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

                                                              Buffer.prototype.toJSON = function toJSON() {
                                                                if (this.length > 0) {
                                                                  const data = new Array(this.length);
                                                                  for (let i = 0; i < this.length; ++i)
                                                                    data[i] = this[i];
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 4 hrs to fix
                                                              lts/lib/buffer.js on lines 1078..1086

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

                                                              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

                                                              Buffer.prototype.swap16 = function swap16() {
                                                                // For Buffer.length < 128, it's generally faster to
                                                                // do the swap in javascript. For larger buffers,
                                                                // dropping down to the native code is faster.
                                                                const len = this.length;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 1119..1132

                                                              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

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

                                                              Buffer.prototype.slice = function slice(start, end) {
                                                                const srcLength = this.length;
                                                                start = adjustOffset(start, srcLength);
                                                                end = end !== undefined ? adjustOffset(end, srcLength) : srcLength;
                                                                const newLength = end > start ? end - start : 0;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 1105..1111

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

                                                              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

                                                              function fromObject(obj) {
                                                                if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
                                                                  if (typeof obj.length !== 'number') {
                                                                    return new FastBuffer();
                                                                  }
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 505..516

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

                                                              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

                                                              Buffer.prototype.equals = function equals(otherBuffer) {
                                                                if (!isUint8Array(otherBuffer)) {
                                                                  throw new ERR_INVALID_ARG_TYPE(
                                                                    'otherBuffer', ['Buffer', 'Uint8Array'], otherBuffer);
                                                                }
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 806..819

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

                                                              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

                                                              function allocate(size) {
                                                                if (size <= 0) {
                                                                  return new FastBuffer();
                                                                }
                                                                if (size < (Buffer.poolSize >>> 1)) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 408..421

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

                                                              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

                                                              const {
                                                                Array,
                                                                ArrayIsArray,
                                                                Error,
                                                                MathFloor,
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 2 other locations - About 3 hrs to fix
                                                              current/lib/repl.js on lines 45..64
                                                              lts/lib/buffer.js on lines 24..43

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

                                                              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

                                                              function adjustOffset(offset, length) {
                                                                // Use Math.trunc() to convert offset to an integer value that can be larger
                                                                // than an Int32. Hence, don't use offset | 0 or similar techniques.
                                                                offset = MathTrunc(offset);
                                                                if (offset === 0) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 3 hrs to fix
                                                              lts/lib/buffer.js on lines 1088..1103

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

                                                              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

                                                              Buffer.alloc = function alloc(size, fill, encoding) {
                                                                assertSize(size);
                                                                if (fill !== undefined && fill !== 0 && size > 0) {
                                                                  const buf = createUnsafeBuffer(size);
                                                                  return _fill(buf, fill, 0, buf.length, encoding);
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 370..377

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

                                                              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

                                                              Buffer.compare = function compare(buf1, buf2) {
                                                                if (!isUint8Array(buf1)) {
                                                                  throw new ERR_INVALID_ARG_TYPE('buf1', ['Buffer', 'Uint8Array'], buf1);
                                                                }
                                                              
                                                              
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 524..538

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

                                                              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

                                                              function base64ByteLength(str, bytes) {
                                                                // Handle padding
                                                                if (str.charCodeAt(bytes - 1) === 0x3D)
                                                                  bytes--;
                                                                if (bytes > 1 && str.charCodeAt(bytes - 1) === 0x3D)
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 589..598

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

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

                                                              const {
                                                                byteLengthUtf8,
                                                                compare: _compare,
                                                                compareOffset,
                                                                createFromString,
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 3 other locations - About 2 hrs to fix
                                                              current/lib/perf_hooks.js on lines 14..29
                                                              lts/lib/buffer.js on lines 45..60
                                                              lts/lib/perf_hooks.js on lines 14..29

                                                              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

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

                                                              function Buffer(arg, encodingOrOffset, length) {
                                                                showFlaggedDeprecation();
                                                                // Common case.
                                                                if (typeof arg === 'number') {
                                                                  if (typeof encodingOrOffset === 'string') {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 278..288

                                                              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

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

                                                              const of = (...items) => {
                                                                const newObj = createUnsafeBuffer(items.length);
                                                                for (let k = 0; k < items.length; k++)
                                                                  newObj[k] = items[k];
                                                                return newObj;
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 344..349

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

                                                              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

                                                              function showFlaggedDeprecation() {
                                                                if (bufferWarningAlreadyEmitted ||
                                                                    ++nodeModulesCheckCounter > 10000 ||
                                                                    (!require('internal/options').getOptionValue('--pending-deprecation') &&
                                                                     isInsideNodeModules())) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 178..194

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

                                                              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

                                                              const assertSize = hideStackFrames((size) => {
                                                                if (typeof size !== 'number') {
                                                                  throw new ERR_INVALID_ARG_TYPE('size', 'number', size);
                                                                }
                                                                if (!(size >= 0 && size <= kMaxLength)) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 357..364

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

                                                              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

                                                              ObjectDefineProperties(module.exports, {
                                                                constants: {
                                                                  configurable: false,
                                                                  enumerable: true,
                                                                  value: constants
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 2 hrs to fix
                                                              lts/lib/buffer.js on lines 1212..1224

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

                                                              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

                                                              function toInteger(n, defaultVal) {
                                                                n = +n;
                                                                if (!NumberIsNaN(n) &&
                                                                    n >= NumberMIN_SAFE_INTEGER &&
                                                                    n <= NumberMAX_SAFE_INTEGER) {
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 hr to fix
                                                              lts/lib/buffer.js on lines 196..204

                                                              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

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

                                                              const constants = ObjectDefineProperties({}, {
                                                                MAX_LENGTH: {
                                                                  value: kMaxLength,
                                                                  writable: false,
                                                                  enumerable: true
                                                              Severity: Major
                                                              Found in current/lib/buffer.js and 1 other location - About 1 hr to fix
                                                              lts/lib/buffer.js on lines 121..132

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

                                                              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

                                                              Buffer.isEncoding = function isEncoding(encoding) {
                                                                return typeof encoding === 'string' && encoding.length !== 0 &&
                                                                       normalizeEncoding(encoding) !== undefined;
                                                              };
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 50 mins to fix
                                                              lts/lib/buffer.js on lines 540..543

                                                              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

                                                              Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
                                                                return this.indexOf(val, byteOffset, encoding) !== -1;
                                                              };
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 40 mins to fix
                                                              lts/lib/buffer.js on lines 957..959

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

                                                              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

                                                              ObjectDefineProperty(Buffer.prototype, 'parent', {
                                                                enumerable: true,
                                                                get() {
                                                                  if (!(this instanceof Buffer))
                                                                    return undefined;
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 40 mins to fix
                                                              lts/lib/buffer.js on lines 748..755

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

                                                              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

                                                              function createUnsafeBuffer(size) {
                                                                zeroFill[0] = 0;
                                                                try {
                                                                  return new FastBuffer(size);
                                                                } finally {
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 40 mins to fix
                                                              lts/lib/buffer.js on lines 147..154

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

                                                              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

                                                              function swap(b, n, m) {
                                                                const i = b[n];
                                                                b[n] = b[m];
                                                                b[m] = i;
                                                              }
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 40 mins to fix
                                                              lts/lib/buffer.js on lines 1113..1117

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

                                                              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

                                                              ObjectDefineProperty(Buffer.prototype, 'offset', {
                                                                enumerable: true,
                                                                get() {
                                                                  if (!(this instanceof Buffer))
                                                                    return undefined;
                                                              Severity: Minor
                                                              Found in current/lib/buffer.js and 1 other location - About 35 mins to fix
                                                              lts/lib/buffer.js on lines 756..763

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

                                                              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