paulgrove/node-syslog-client

View on GitHub

Showing 10 of 17 total issues

Function getTransport has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Client.prototype.getTransport = function getTransport(cb) {
    if (this.transport_ !== undefined)
        return cb(null, this.transport_);

    this.getTransportRequests.push(cb);
Severity: Major
Found in index.js - About 5 hrs to fix

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


// Copyright 2015-2016 Stephen Vickers <stephen.vickers.sv@gmail.com>
// with contributions 2017 by Seth Blumberg <sethb@pobox.com>

var dgram = require("dgram");
Severity: Minor
Found in index.js - About 4 hrs to fix

Function getTransport has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

Client.prototype.getTransport = function getTransport(cb) {
    if (this.transport_ !== undefined)
        return cb(null, this.transport_);

    this.getTransportRequests.push(cb);
Severity: Minor
Found in index.js - About 4 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function log has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Client.prototype.log = function log() {
    var message, options = {}, cb;

    if (typeof arguments[0] === "string")
        message = arguments[0];
Severity: Major
Found in index.js - About 2 hrs to fix

Function buildFormattedMessage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Client.prototype.buildFormattedMessage = function buildFormattedMessage(message, options) {
    // Some applications, like LTE CDR collection, need to be able to
    // back-date log messages based on CDR timestamps across different
    // time zones, because of delayed record collection with 3rd parties.
    // Particular useful in when feeding CDRs to Splunk for indexing.
Severity: Minor
Found in index.js - About 1 hr to fix

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

Client.prototype.log = function log() {
    var message, options = {}, cb;

    if (typeof arguments[0] === "string")
        message = arguments[0];
Severity: Minor
Found in index.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 buildFormattedMessage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

Client.prototype.buildFormattedMessage = function buildFormattedMessage(message, options) {
    // Some applications, like LTE CDR collection, need to be able to
    // back-date log messages based on CDR timestamps across different
    // time zones, because of delayed record collection with 3rd parties.
    // Particular useful in when feeding CDRs to Splunk for indexing.
Severity: Minor
Found in 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

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

function Client(target, options) {
    this.target = target || "127.0.0.1";

    if (!options)
        options = {}
Severity: Minor
Found in 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

Avoid too many return statements within this function.
Open

            return;
Severity: Major
Found in index.js - About 30 mins to fix

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

Client.prototype.close = function close() {
    if (this.transport_) {
        if (this.transport === Transport.Tcp || this.transport === Transport.Tls || this.transport === Transport.Unix)
            this.transport_.destroy();
        if (this.transport === Transport.Udp)
Severity: Minor
Found in index.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

Severity
Category
Status
Source
Language