robojones/z1

View on GitHub

Showing 27 of 27 total issues

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

program
    .command('restart [appname]')
    .description('restart the app specified by the appname')
    .option('-t, --timeout <timeout>', 'time until the old workers get killed')
    .option('-s, --signal <signal>', 'kill signal for the old workers')
Severity: Major
Found in cli/main.js and 1 other location - About 5 hrs to fix
cli/main.js on lines 75..90

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 149.

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

program
    .command('stop [appname]')
    .description('stop the app specified by the appname')
    .option('-t, --timeout <timeout>', 'time until the workers get killed')
    .option('-s, --signal <signal>', 'kill signal')
Severity: Major
Found in cli/main.js and 1 other location - About 5 hrs to fix
cli/main.js on lines 92..107

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 149.

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

        if (features.hasOwnProperty(feature)) {
            const file = path.join(folder, feature)
            const uninstaller = spawn(file, [], {
                cwd: folder,
                stdio: 'inherit',
Severity: Major
Found in cli/main.js and 1 other location - About 4 hrs to fix
cli/main.js on lines 238..251

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 117.

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

        } else if (features.hasOwnProperty(feature)) {
            const file = path.join(folder, feature)
            const installer = spawn(file, [], {
                cwd: folder,
                stdio: 'inherit',
Severity: Major
Found in cli/main.js and 1 other location - About 4 hrs to fix
cli/main.js on lines 260..273

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 117.

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 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

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

                          async stop(app, opt = {}, immediate = false) {
                              opt.timeout = parseTimeout(opt.timeout)
                              return this._connectAndSend({
                                  name: 'stop',
                                  app,
                      Severity: Major
                      Found in remote/lib/class/Remote.js and 1 other location - About 1 hr to fix
                      remote/lib/class/Remote.js on lines 142..150

                      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

                          async restart(app, opt = {}, immediate = false) {
                              opt.timeout = parseTimeout(opt.timeout)
                              return this._connectAndSend({
                                  name: 'restart',
                                  app,
                      Severity: Major
                      Found in remote/lib/class/Remote.js and 1 other location - About 1 hr to fix
                      remote/lib/class/Remote.js on lines 116..124

                      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

                              if (target.w && target.w.isConnected()) {
                                  const w = target.w
                      
                                  w.process.stdout.on('data', sendOutToCLI)
                                  w.process.stderr.on('data', sendErrToCLI)
                      Severity: Major
                      Found in daemon/lib/send-logs-to-CLI.js and 1 other location - About 1 hr to fix
                      daemon/lib/send-logs-to-CLI.js on lines 41..45

                      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

                                  if (target && target.w && target.w.process && target.w.process.stdout) {
                                      const w = target.w
                                      w.process.stdout.removeListener('data', sendOutToCLI)
                                      w.process.stderr.removeListener('data', sendErrToCLI)
                                  }
                      Severity: Major
                      Found in daemon/lib/send-logs-to-CLI.js and 1 other location - About 1 hr to fix
                      daemon/lib/send-logs-to-CLI.js on lines 22..27

                      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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language