oleksiyk/binary-protocol

View on GitHub

Showing 45 of 45 total issues

File index.js has 471 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var Long     = require('long');
var Protocol = require('../index');
var pbschema = require('protocol-buffers-schema');
Severity: Minor
Found in lib/protobuf/index.js - About 7 hrs to fix

    Function createProtobufProtocol has 175 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function createProtobufProtocol(proto, options) {
        var _Protocol = ProtobufProtocol.createProtocol();
        var definitions = {};
    
        options = _.defaults(options || {}, {
    Severity: Major
    Found in lib/protobuf/index.js - About 7 hrs to fix

      Function createProtobufProtocol has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function createProtobufProtocol(proto, options) {
          var _Protocol = ProtobufProtocol.createProtocol();
          var definitions = {};
      
          options = _.defaults(options || {}, {
      Severity: Minor
      Found in lib/protobuf/index.js - About 6 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

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

          write: function (value) {
              this.demand(8);
              value = Long.fromValue(value);
              this.buffer.writeInt32LE(value.getHighBits(), this.offset + 4);
              this.buffer.writeInt32LE(value.getLowBits(), this.offset);
      Severity: Major
      Found in lib/index.js and 1 other location - About 3 hrs to fix
      lib/index.js on lines 185..191

      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

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

          write: function (value) {
              this.demand(8);
              value = Long.fromValue(value);
              this.buffer.writeUInt32LE(value.getHighBitsUnsigned(), this.offset + 4);
              this.buffer.writeUInt32LE(value.getLowBitsUnsigned(), this.offset);
      Severity: Major
      Found in lib/index.js and 1 other location - About 3 hrs to fix
      lib/index.js on lines 155..161

      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

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

          write: function (value) {
              this.demand(8);
              value = Long.fromValue(value);
              this.buffer.writeInt32BE(value.getHighBits(), this.offset);
              this.buffer.writeInt32BE(value.getLowBits(), this.offset + 4);
      Severity: Major
      Found in lib/index.js and 1 other location - About 3 hrs to fix
      lib/index.js on lines 170..176

      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

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

          write: function (value) {
              this.demand(8);
              value = Long.fromValue(value);
              this.buffer.writeUInt32BE(value.getHighBitsUnsigned(), this.offset);
              this.buffer.writeUInt32BE(value.getLowBitsUnsigned(), this.offset + 4);
      Severity: Major
      Found in lib/index.js and 1 other location - About 3 hrs to fix
      lib/index.js on lines 140..146

      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

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

          write: function (value) {
              value = Long.fromValue(value);
              this.buffer.writeInt32LE(value.getLowBits(), this.offset);
              this.buffer.writeInt32LE(value.getHighBits(), this.offset + 4);
              this.offset += 8;
      Severity: Major
      Found in lib/protobuf/index.js and 1 other location - About 3 hrs to fix
      lib/protobuf/index.js on lines 373..378

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

      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

          write: function (value) {
              value = Long.fromValue(value);
              this.buffer.writeUInt32LE(value.getLowBitsUnsigned(), this.offset);
              this.buffer.writeUInt32LE(value.getHighBitsUnsigned(), this.offset + 4);
              this.offset += 8;
      Severity: Major
      Found in lib/protobuf/index.js and 1 other location - About 3 hrs to fix
      lib/protobuf/index.js on lines 396..401

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

      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

      Writer.define = function (name, fn, namespace, _proto) {
          _proto = _proto || Writer;
      
          if (!_proto.prototype.__methods) {
              _proto.prototype.__methods = [];
      Severity: Major
      Found in lib/writer.js and 1 other location - About 2 hrs to fix
      lib/reader.js on lines 68..75

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

      Reader.define = function (name, fn, namespace, _proto) {
          _proto = _proto || Reader;
      
          if (!_proto.prototype.__methods) {
              _proto.prototype.__methods = [];
      Severity: Major
      Found in lib/reader.js and 1 other location - About 2 hrs to fix
      lib/writer.js on lines 40..47

      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 defineMessage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function defineMessage(namespace, msg) {
              var fullName = namespace ? namespace + '.' + msg.name : msg.name;
              definitions[fullName] = _.zipObject(_.map(msg.fields, 'tag'), msg.fields);
      
              _Protocol.define(msg.name, {
      Severity: Major
      Found in lib/protobuf/index.js - About 2 hrs to fix

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

            read: function () {
                var l = new Long(this.buffer.readUInt32LE(this.offset), this.buffer.readUInt32LE(this.offset + 4), true);
                this.offset += 8;
                return l;
            },
        Severity: Major
        Found in lib/protobuf/index.js and 1 other location - About 1 hr to fix
        lib/index.js on lines 180..184

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

        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

            read: function () {
                var l = new Long(this.buffer.readUInt32LE(this.offset), this.buffer.readUInt32LE(this.offset + 4), true);
                this.offset += 8;
                return l;
            },
        Severity: Major
        Found in lib/index.js and 1 other location - About 1 hr to fix
        lib/protobuf/index.js on lines 368..372

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

        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 parseProto has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function parseProto(data) {
                var schema = pbschema.parse(data);
        
                _.each(schema.messages, function (msg) {
                    defineMessage(schema.package, msg);
        Severity: Minor
        Found in lib/protobuf/index.js - About 1 hr to fix

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

              read: function () {
                  var l = new Long(this.buffer.readInt32LE(this.offset), this.buffer.readInt32LE(this.offset + 4));
                  this.offset += 8;
                  return l;
              },
          Severity: Major
          Found in lib/protobuf/index.js and 1 other location - About 1 hr to fix
          lib/index.js on lines 150..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 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

              read: function () {
                  var l = new Long(this.buffer.readInt32LE(this.offset), this.buffer.readInt32LE(this.offset + 4));
                  this.offset += 8;
                  return l;
              },
          Severity: Major
          Found in lib/index.js and 1 other location - About 1 hr to fix
          lib/protobuf/index.js on lines 391..395

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 72.

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

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

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

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

          Refactorings

          Further Reading

          Function defaultFieldValue has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function defaultFieldValue(field) {
                  var _default = field.options.default;
                  if (options.typeSpecificDefaults === false && _default === undefined) {
                      return undefined;
                  }
          Severity: Minor
          Found in lib/protobuf/index.js - About 1 hr to fix

            Function _read has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            function _read(fn, path) {
                var r, i, _path = [];
                var args, len = arguments.length;
                if (typeof path === 'string') {
                    _path = [path];
            Severity: Minor
            Found in lib/reader.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

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

            Writer.prototype.define = function (name, fn, namespace) {
                _.set(this, namespace ? namespace + '.' + name : name, _.bind(_write, this, fn));
            };
            Severity: Major
            Found in lib/writer.js and 1 other location - About 1 hr to fix
            lib/reader.js on lines 77..79

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 60.

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

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

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

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

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language