robojones/z1

View on GitHub

Showing 17 of 27 total issues

Function startWorkers has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
    const workers = []

    if (pack.name === 'z1') {
        throw new Error('the name "z1" is invalid')
Severity: Major
Found in daemon/lib/start-workers.js - About 3 hrs to fix

    Remote has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Remote extends BetterEvents {
        /**
       * Create a new Remote instance.
       * @param {string} socketFile - Path to the socket file of the z1 daemon.
       */
    Severity: Minor
    Found in remote/lib/class/Remote.js - About 2 hrs to fix

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

          constructor(dir, file, name, ports, env) {
              super()
      
              this.dir = dir
              this.file = file
      Severity: Minor
      Found in daemon/lib/class/Worker.js - About 1 hr to fix

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

        function remoteServer(filename, run) {
            const file = path.resolve(filename)
        
            const server = net.createServer(OPT, socket => {
                socket.on('error', handle)
        Severity: Minor
        Found in daemon/lib/remoteServer.js - About 1 hr to fix

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

              setup(id, dir = '') {
                  const streams = this.get(id)
          
                  // End old streams and cancel old log rotation.
                  clearTimeout(streams.timeout)
          Severity: Minor
          Found in daemon/lib/class/LogManager.js - About 1 hr to fix

            Function list has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function list(config) {
                return new Promise(resolve => {
                    const stats = {}
            
                    /**
            Severity: Minor
            Found in daemon/operation/list.js - About 1 hr to fix

              Function sendLogsToCLI has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function sendLogsToCLI(target, connection) {
                  const convert = chunk => Array.from(Buffer.from(chunk))
                  const emit = (ev, chunk) => connection.remoteEmit(ev, convert(chunk))
                  const sendOutToCLI = chunk => emit('stdout', chunk)
                  const sendErrToCLI = chunk => emit('stderr', chunk)
              Severity: Minor
              Found in daemon/lib/send-logs-to-CLI.js - About 1 hr to fix

                Function _send has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async _send(object) {
                        return new Promise((resolve, reject) => {
                            const socket = net.connect(this.socketFile, () => {
                                const connection = new Connection(socket)
                
                
                Severity: Minor
                Found in remote/lib/class/Remote.js - About 1 hr to fix

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

                  function sendLogsToCLI(target, connection) {
                      const convert = chunk => Array.from(Buffer.from(chunk))
                      const emit = (ev, chunk) => connection.remoteEmit(ev, convert(chunk))
                      const sendOutToCLI = chunk => emit('stdout', chunk)
                      const sendErrToCLI = chunk => emit('stderr', chunk)
                  Severity: Minor
                  Found in daemon/lib/send-logs-to-CLI.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 restart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  async function restart(config, command, connection) {
                      // find old app
                      const app = config.apps.find(app => app.name === command.app)
                  
                      if (!app) {
                  Severity: Minor
                  Found in daemon/operation/restart.js - About 1 hr to fix

                    Function start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function start(config, command, connection) {
                        if (global.isResurrectable) {
                            global.isResurrectable = false
                            config.apps = []
                        }
                    Severity: Minor
                    Found in daemon/operation/start.js - About 1 hr to fix

                      Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          constructor(dir, file, name, ports, env) {
                              super()
                      
                              this.dir = dir
                              this.file = file
                      Severity: Minor
                      Found in daemon/lib/class/Worker.js - About 55 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 exports has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
                      Severity: Major
                      Found in daemon/lib/start-workers.js - About 50 mins to fix

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

                        module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
                            const workers = []
                        
                            if (pack.name === 'z1') {
                                throw new Error('the name "z1" is invalid')
                        Severity: Minor
                        Found in daemon/lib/start-workers.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 verifyPorts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function verifyPorts(pack, prop, origin = 'package.json') {
                            const ports = pack[prop]
                        
                            if (Array.isArray(ports)) {
                                if (ports.length) {
                        Severity: Minor
                        Found in daemon/lib/verifyPorts.js - About 35 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 _waitForDisconnect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async _waitForDisconnect() {
                                while (1) {
                                    try {
                                        await this._ping()
                                        await xTime(100)
                        Severity: Minor
                        Found in remote/lib/class/Remote.js - About 35 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 _waitForConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async _waitForConnection() {
                                while (1) {
                                    try {
                                        await this._ping()
                                        return
                        Severity: Minor
                        Found in remote/lib/class/Remote.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