bruslim/peerface

View on GitHub

Showing 39 of 39 total issues

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

var HaveMessage = module.exports = function(bytes) {
  PeerMessage.call(this, bytes);
  Object.defineProperties(this,{
    _pieceIndex: {
      value: new Buffer(4)
Severity: Major
Found in lib/dto/HaveMessage.js and 1 other location - About 1 day to fix
lib/dto/PortMessage.js on lines 8..34

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

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

var PortMessage = module.exports = function(bytes) {
  PeerMessage.call(this, bytes);
  Object.defineProperties(this, {
    _listenPort: {
      value: new Buffer(2)
Severity: Major
Found in lib/dto/PortMessage.js and 1 other location - About 1 day to fix
lib/dto/HaveMessage.js on lines 8..34

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

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

var UnchokeMessage = module.exports = function(bytes) {
  PeerMessage.call(this, bytes);
  if (!bytes) {
    this.id = UnchokeMessage.Id;
  } else {
Severity: Major
Found in lib/dto/UnchokeMessage.js and 4 other locations - About 2 hrs to fix
lib/dto/CancelMessage.js on lines 8..17
lib/dto/ChokeMessage.js on lines 8..17
lib/dto/InterestedMessage.js on lines 8..17
lib/dto/NotInterestedMessage.js on lines 8..17

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

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

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

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

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

Refactorings

Further Reading

Function Handshake has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Handshake = module.exports = function Handshake(bytes) {
  TcpMessage.call(this, bytes);
  Object.defineProperties(this, {
    _pstrlen: {
      get: function() {
Severity: Major
Found in lib/dto/Handshake.js - About 2 hrs to fix

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

    var NotInterestedMessage = module.exports = function(bytes) {
      PeerMessage.call(this, bytes);
      if (!bytes) {
        this.id = NotInterestedMessage.Id;
      } else {
    Severity: Major
    Found in lib/dto/NotInterestedMessage.js and 4 other locations - About 2 hrs to fix
    lib/dto/CancelMessage.js on lines 8..17
    lib/dto/ChokeMessage.js on lines 8..17
    lib/dto/InterestedMessage.js on lines 8..17
    lib/dto/UnchokeMessage.js on lines 8..17

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

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

    var InterestedMessage = module.exports = function(bytes) {
      PeerMessage.call(this, bytes);
      if (!bytes) {
        this.id = InterestedMessage.Id;
      } else {
    Severity: Major
    Found in lib/dto/InterestedMessage.js and 4 other locations - About 2 hrs to fix
    lib/dto/CancelMessage.js on lines 8..17
    lib/dto/ChokeMessage.js on lines 8..17
    lib/dto/NotInterestedMessage.js on lines 8..17
    lib/dto/UnchokeMessage.js on lines 8..17

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

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

    var CancelMessage = module.exports = function(bytes) {
      BaseRequestMessage.call(this, bytes);
      if (!bytes) {
        this.id = CancelMessage.Id;
      } else {
    Severity: Major
    Found in lib/dto/CancelMessage.js and 4 other locations - About 2 hrs to fix
    lib/dto/ChokeMessage.js on lines 8..17
    lib/dto/InterestedMessage.js on lines 8..17
    lib/dto/NotInterestedMessage.js on lines 8..17
    lib/dto/UnchokeMessage.js on lines 8..17

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

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

    var ChokeMessage = module.exports = function(bytes) {
      PeerMessage.call(this, bytes);
      if (!bytes) {
        this.id = ChokeMessage.Id;
      } else {
    Severity: Major
    Found in lib/dto/ChokeMessage.js and 4 other locations - About 2 hrs to fix
    lib/dto/CancelMessage.js on lines 8..17
    lib/dto/InterestedMessage.js on lines 8..17
    lib/dto/NotInterestedMessage.js on lines 8..17
    lib/dto/UnchokeMessage.js on lines 8..17

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

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

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

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

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

    Refactorings

    Further Reading

    Function exports has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var KeepAlive = module.exports = function(bytes) {
      TcpMessage.call(this, bytes);
      if (!!bytes) {
        Object.defineProperties(this, {
          len: {
    Severity: Minor
    Found in lib/dto/KeepAlive.js - About 1 hr to fix

      Function exports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var BaseRequestMessage = module.exports = function(bytes) {
        PeerMessage.call(this, bytes);
        Object.defineProperties(this, {
          _index: {
            value: new Buffer(4)
      Severity: Minor
      Found in lib/dto/BaseRequestMessage.js - About 1 hr to fix

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

        var PieceMessage = module.exports = function(bytes) {
          PeerMessage.call(this, bytes);
          Object.defineProperties(this, {
            _index: {
              value: new Buffer(4)
        Severity: Minor
        Found in lib/dto/PieceMessage.js - About 1 hr to fix

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

              length: {
                enumerable: true,
                get: function() {
                  return this._length.readInt32BE(0);
                },
          Severity: Major
          Found in lib/dto/BaseRequestMessage.js and 4 other locations - About 1 hr to fix
          lib/dto/BaseRequestMessage.js on lines 14..22
          lib/dto/BaseRequestMessage.js on lines 26..34
          lib/dto/PieceMessage.js on lines 14..22
          lib/dto/PieceMessage.js on lines 26..34

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

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

              begin: {
                enumerable: true,
                get: function() {
                  return this._begin.readInt32BE(0);
                },
          Severity: Major
          Found in lib/dto/BaseRequestMessage.js and 4 other locations - About 1 hr to fix
          lib/dto/BaseRequestMessage.js on lines 14..22
          lib/dto/BaseRequestMessage.js on lines 38..46
          lib/dto/PieceMessage.js on lines 14..22
          lib/dto/PieceMessage.js on lines 26..34

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

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

              index: {
                enumerable: true,
                get: function() {
                  return this._index.readInt32BE(0);
                },
          Severity: Major
          Found in lib/dto/BaseRequestMessage.js and 4 other locations - About 1 hr to fix
          lib/dto/BaseRequestMessage.js on lines 26..34
          lib/dto/BaseRequestMessage.js on lines 38..46
          lib/dto/PieceMessage.js on lines 14..22
          lib/dto/PieceMessage.js on lines 26..34

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

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

              index: {
                enumerable: true,
                get: function() {
                  return this._index.readInt32BE(0);
                },
          Severity: Major
          Found in lib/dto/PieceMessage.js and 4 other locations - About 1 hr to fix
          lib/dto/BaseRequestMessage.js on lines 14..22
          lib/dto/BaseRequestMessage.js on lines 26..34
          lib/dto/BaseRequestMessage.js on lines 38..46
          lib/dto/PieceMessage.js on lines 26..34

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

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

              begin: {
                enumerable: true,
                get: function() {
                  return this._begin.readInt32BE(0);
                },
          Severity: Major
          Found in lib/dto/PieceMessage.js and 4 other locations - About 1 hr to fix
          lib/dto/BaseRequestMessage.js on lines 14..22
          lib/dto/BaseRequestMessage.js on lines 26..34
          lib/dto/BaseRequestMessage.js on lines 38..46
          lib/dto/PieceMessage.js on lines 14..22

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

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

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

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

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

          Refactorings

          Further Reading

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

          var PeerConnection = module.exports = function(socket){
            events.EventEmitter.call(this);
            this.setMaxListeners(0);
            Object.defineProperties(this,{
              infoHash: {
          Severity: Minor
          Found in lib/PeerConnection.js - About 1 hr to fix

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

            PeerConnection.prototype.port = function(listenPort) {
              return this.write((new Messages.Port()).init({
                listenPort : listenPort
              }));
            };
            Severity: Major
            Found in lib/PeerConnection.js and 2 other locations - About 55 mins to fix
            lib/PeerConnection.js on lines 260..264
            lib/PeerConnection.js on lines 266..270

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

            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

            PeerConnection.prototype.have = function(pieceIndex) {
              return this.write((new Messages.Have()).init({
                pieceIndex : pieceIndex
              }));
            };
            Severity: Major
            Found in lib/PeerConnection.js and 2 other locations - About 55 mins to fix
            lib/PeerConnection.js on lines 266..270
            lib/PeerConnection.js on lines 296..300

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

            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

            PeerConnection.prototype.bitfield = function(bitfield) {
              return this.write((new Messages.Bitfield()).init({
                bitfield : bitfield
              }));
            };
            Severity: Major
            Found in lib/PeerConnection.js and 2 other locations - About 55 mins to fix
            lib/PeerConnection.js on lines 260..264
            lib/PeerConnection.js on lines 296..300

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

            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

            Severity
            Category
            Status
            Source
            Language