frnjjq/node-q4s

View on GitHub

Showing 46 of 122 total issues

Function constrain has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  constrain(constr) {
    // TODO -> Validate this function, so weird values do not destroy.
    const check = function(parameter, restr, maxDefault) {
      let value;
      if (parameter && restr) {
Severity: Minor
Found in lib/measurement-set.js - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function resTCP has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  async resTCP(res) {
    if (res.statusCode != 200) {
      this.emit('error', new Error(res));
      this.close();
    } else {
Severity: Minor
Found in lib/client.js - About 3 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 constructor has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(store) {
    super();
    /**
     * @param {Collection} store - Session storage
     */
Severity: Major
Found in lib/server-network.js - About 3 hrs to fix

    Function fromOptions has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      fromOptions(opt) {
        if (opt) {
          this.negotiationPingUp = opt.negotiationPingUp ?
            opt.negotiationPingUp : defaults.negotiationPingUp;
          this.negotiationPingDown = opt.negotiationPingDown ?
    Severity: Minor
    Found in lib/default-procedure.js - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function resTCP has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async resTCP(res) {
        if (res.statusCode != 200) {
          this.emit('error', new Error(res));
          this.close();
        } else {
    Severity: Major
    Found in lib/client.js - About 2 hrs to fix

      Function reqTCPHandler has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async reqTCPHandler(req) {
          if (this.state === HANDSHAKE_DONE &&
            req.method === 'READY' &&
            req.headers.Stage === '0') {
            this.pinger = Pinger.genServer(this.session.id,
      Severity: Major
      Found in lib/server-connection.js - About 2 hrs to fix

        Function constructor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor() {
            super();
            /**
             * The handshake socket.
             * @member {net.Socket}
        Severity: Major
        Found in lib/client-network.js - About 2 hrs to fix

          Function fromClientOps has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static async fromClientOps(options) {
              let latency = 0;
              let jitterUp = 0;
              let jitterDown = 0;
              let bandwidthUp = 0;
          Severity: Major
          Found in lib/session.js - About 2 hrs to fix

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

              static async fromClientOps(options) {
                let latency = 0;
                let jitterUp = 0;
                let jitterDown = 0;
                let bandwidthUp = 0;
            Severity: Minor
            Found in lib/session.js - About 2 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

            Function measure has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              measure() {
                return new Promise((resolve, reject) => {
                  this.rejectCallback = reject;
                  this.endFunc = () => {
                    console.log('Calling end func');
            Severity: Minor
            Found in lib/bandwidther.js - About 1 hr to fix

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

                updateFromSDP(sdp) {
                  const lines = sdp.split('\r\n');
                  lines.forEach((line) => {
                    if (line.indexOf('a=public-address:client') === 0) {
                      const type = parseInt(line.substring(24, 26));
              Severity: Minor
              Found in lib/addresses.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (this.negotiationPingUp && this.negotiationPingDown &&
                      this.continuityPingUp && this.continuityPingDown &&
                      this.negotiationBandwidth && this.windowSizeUp &&
                      this.windowSizeDown && this.windowSizePctLssUp &&
                      this.windowSizePctLssDown) {
                Severity: Critical
                Found in lib/default-procedure.js - About 1 hr to fix

                  Function updateWithSDP has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    updateWithSDP(sdp) {
                      const lines = sdp.split('\r\n');
                      lines.forEach((line) => {
                        if (line.indexOf('a=latency:') === 0) {
                          const res = parseInt(line.substring(10), 10);
                  Severity: Minor
                  Found in lib/measurement-set.js - About 1 hr to fix

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

                      measure() {
                        return new Promise((resolve, reject) => {
                          this.endFunc = () => {
                            this.timeoutId = undefined;
                            this.sequence = 0;
                    Severity: Minor
                    Found in lib/pinger.js - About 1 hr to fix

                      Function constrain has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        constrain(constr) {
                          // TODO -> Validate this function, so weird values do not destroy.
                          const check = function(parameter, restr, maxDefault) {
                            let value;
                            if (parameter && restr) {
                      Severity: Minor
                      Found in lib/measurement-set.js - About 1 hr to fix

                        Function doesMetQuality has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          doesMetQuality(measurement) {
                            if (typeof this.latency !== 'undefined'&&
                              typeof measurement.latency !== 'undefined' &&
                              measurement.latency > this.latency) {
                              return false;
                        Severity: Minor
                        Found in lib/measurement-set.js - About 1 hr to fix

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

                            portToSDP() {
                              let sdp = '';
                              if (this.appClientPorts.TCP) {
                                sdp = sdp + 'a=flow:app clientListeningPort TCP/' +
                                  this.appClientPorts.TCP + '\r\n';
                          Severity: Minor
                          Found in lib/addresses.js - About 1 hr to fix

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

                              extractFromPinger(times) {
                                return new Promise( (resolve, reject) => {
                                  let latencies = [];
                                  let lost = 0;
                                  let i = times.length-1;
                            Severity: Minor
                            Found in lib/measure.js - About 1 hr to fix

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

                                validate() { // TODO: Improve this comprobation when you have the class clear
                                  if (!this.q4sVersion) {
                                    throw new Error('Missing an argument in the start line');
                                  }
                                  if (!METHODS.includes(this.method)) {
                              Severity: Minor
                              Found in lib/request.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 handshakeHandler has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                handshakeHandler(res) {
                                  if (this.state == SENT_HANDSHAKE) {
                                    if (res.statusCode != 200) {
                                      this.emit('error', new Error(res.reasonPhrase));
                                      console.log('recieved', res);
                              Severity: Minor
                              Found in lib/client.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language