jeansaad/hotel

View on GitHub
src/daemon/group.js

Summary

Maintainability
C
1 day
Test Coverage

File group.js has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require("fs");
const path = require("path");
const EventEmitter = require("events");
const url = require("url");
const once = require("once");
Severity: Minor
Found in src/daemon/group.js - About 3 hrs to fix

    Function add has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      add(id, conf) {
        if (conf.target) {
          log(`Add target ${id}`);
          this._list[id] = conf;
          this._change();
    Severity: Major
    Found in src/daemon/group.js - About 2 hrs to fix

      Function handleConnect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        handleConnect(req, socket, head) {
          if (req.headers.host) {
            const { host } = req.headers;
            const { id, hostname, port } = this.parseHost(host);
      
      
      Severity: Minor
      Found in src/daemon/group.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 handleUpgrade has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        handleUpgrade(req, socket, head) {
          if (req.headers.host) {
            const { host } = req.headers;
            const { id, port } = this.parseHost(host);
            const item = this.find(id);
      Severity: Minor
      Found in src/daemon/group.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 handleConnect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        handleConnect(req, socket, head) {
          if (req.headers.host) {
            const { host } = req.headers;
            const { id, hostname, port } = this.parseHost(host);
      
      
      Severity: Minor
      Found in src/daemon/group.js - About 1 hr to fix

        Replace ········ with ······
        Open

                isWildcardMatch: matcher.isMatch(str, `*.${h}`)
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Delete ··
        Open

              }));
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Delete ··
        Open

                isStrictMatch: matcher.isMatch(str, h),
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Replace ⏎······.concat(data)⏎······.split("\n")⏎······.slice(-100)⏎······ with .concat(data).split("\n").slice(-100)
        Open

            mon.tail = mon.tail
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Replace ········ with ······
        Open

                host: h,
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        Replace ⏎······.sort()⏎······.reverse()⏎······ with .sort().reverse()
        Open

            const arr = Object.keys(this._list)
        Severity: Minor
        Found in src/daemon/group.js by eslint

        For more information visit Source: http://eslint.org/docs/rules/

        There are no issues that match your filters.

        Category
        Status