oleksiyk/binary-protocol

View on GitHub

Showing 45 of 45 total issues

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

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

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

Function createProtocol has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createProtocol(_SuperProtocol, constructor) {
    function _Reader() {
        Reader.apply(this, arguments);
    }

Severity: Minor
Found in lib/index.js - About 1 hr to fix

    Function _read has 30 lines of code (exceeds 25 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

      Function getFieldWireType has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getFieldWireType(field) {
          if (field.repeated && field.options.packed === 'true') {
              return 2;
          }
      
      
      Severity: Minor
      Found in lib/protobuf/index.js - About 1 hr to fix

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

            read: function () {
                var v = varint.read64(this.buffer, this.offset);
                this.offset += v.length;
                return v.value;
            },
        Severity: Major
        Found in lib/index.js and 1 other location - About 1 hr to fix
        lib/index.js on lines 196..200

        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

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

            read: function () {
                var v = varint.read(this.buffer, this.offset);
                this.offset += v.length;
                return v.value;
            },
        Severity: Major
        Found in lib/index.js and 1 other location - About 1 hr to fix
        lib/index.js on lines 241..245

        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

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

        ProtobufProtocol.define('float', {
            read: function () {
                this.FloatLE();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('int64', {
            read: function () {
                this.Varint64();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('sint64', {
            read: function () {
                this.SVarint64();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('uint64', {
            read: function () {
                this.UVarint64();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('int32', {
            read: function () {
                this.Varint();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('sfixed32', {
            read: function () {
                this.Int32LE();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('fixed32', {
            read: function () {
                this.UInt32LE();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('double', {
            read: function () {
                this.DoubleLE();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.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 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('uint32', {
            read: function () {
                this.UVarint();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 303..310
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

        ProtobufProtocol.define('sint32', {
            read: function () {
                this.SVarint();
            },
            write: function (value) {
        Severity: Major
        Found in lib/protobuf/index.js and 9 other locations - About 1 hr to fix
        lib/protobuf/index.js on lines 276..283
        lib/protobuf/index.js on lines 294..301
        lib/protobuf/index.js on lines 312..319
        lib/protobuf/index.js on lines 321..328
        lib/protobuf/index.js on lines 330..337
        lib/protobuf/index.js on lines 339..346
        lib/protobuf/index.js on lines 348..355
        lib/protobuf/index.js on lines 357..364
        lib/protobuf/index.js on lines 381..388

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 55.

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

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

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

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

        Refactorings

        Further Reading

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

                _.each(msg.enums, function (_enum) {
                    defineEnum(namespace ? (namespace + '.' + msg.name) : msg.name, _enum);
                });
        Severity: Minor
        Found in lib/protobuf/index.js and 1 other location - About 50 mins to fix
        lib/protobuf/index.js on lines 200..202

        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

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

                _.each(msg.messages, function (_msg) {
                    defineMessage(namespace ? (namespace + '.' + msg.name) : msg.name, _msg);
                });
        Severity: Minor
        Found in lib/protobuf/index.js and 1 other location - About 50 mins to fix
        lib/protobuf/index.js on lines 204..206

        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

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

        exports.read = function (buffer, offset) {
            var byte;
            var result = 0;
            var position = offset || 0;
            var shift = 0;
        Severity: Minor
        Found in lib/protobuf/varint.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 read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            read: function (field) {
                var self = this;
                var len, i;
        
                if (field.type === 'bytes' || field.type === 'string') {
        Severity: Minor
        Found in lib/protobuf/index.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

        Severity
        Category
        Status
        Source
        Language