azukiapp/azk

View on GitHub
src/system/run.js

Summary

Maintainability
D
2 days
Test Coverage

File run.js has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { _, t, lazy_require, isBlank } from 'azk';
import { config, log, path } from 'azk';
import { subscribe, publish } from 'azk/utils/postal';
import { defer, async, asyncUnsubscribe, promiseResolve, thenAll } from 'azk/utils/promises';
import { ImageNotAvailable, SystemRunError, RunCommandError, NotBeenImplementedError } from 'azk/utils/errors';
Severity: Minor
Found in src/system/run.js - About 5 hrs to fix

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

      _wait_available(system, port_data, container, timeout, options, image_conf) {
        return async(this, function* () {
          var host;
          if (config('agent:requires_vm')) {
            host = config('agent:vm:ip');
    Severity: Minor
    Found in src/system/run.js - About 1 hr to fix

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

        runProvision(system, options = {}) {
          return async(this, function* () {
            var steps = system.provision_steps;
      
            options = _.clone(options);
      Severity: Minor
      Found in src/system/run.js - About 1 hr to fix

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

          _clean_sync_folder(system, syncs) {
            return async(this, function* () {
              var local_user = config('agent:vm:user');
              var uid, gid;
              if (config('agent:requires_vm')) {
        Severity: Minor
        Found in src/system/run.js - About 1 hr to fix

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

            throwRunError(system, container, command, data = null, stop = false, options = {}) {
              data = data ? promiseResolve(data) : container.inspect();
              return data.then((data) => {
                // Get container log
                var promise = container.logs({stdout: true, stderr: true}).then((stream) => {
          Severity: Minor
          Found in src/system/run.js - About 1 hr to fix

            Function runShell has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              runShell(system, options = {}) {
                return async(this, function* () {
                  options = _.defaults(options, {
                    remove: false,
                    sequencies: yield this._getSequencies(system)
            Severity: Minor
            Found in src/system/run.js - About 1 hr to fix

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

                stop(system, instances, options = {}) {
                  options = _.defaults(options, {
                    kill: false,
                    remove: true,
                  });
              Severity: Minor
              Found in src/system/run.js - About 1 hr to fix

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

                  runDaemon(system, options = {}) {
                    return async(this, function* () {
                      // TODO: add instances and dependencies options
                      // Prepare options
                      var image = yield this._check_image(system, options);
                Severity: Minor
                Found in src/system/run.js - About 1 hr to fix

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

                    runProvision(system, options = {}) {
                      return async(this, function* () {
                        var steps = system.provision_steps;
                  
                        options = _.clone(options);
                  Severity: Minor
                  Found in src/system/run.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 _wait_available has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    _wait_available(system, port_data, container, timeout, options, image_conf) {
                  Severity: Minor
                  Found in src/system/run.js - About 45 mins to fix

                    Function throwRunError has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      throwRunError(system, container, command, data = null, stop = false, options = {}) {
                    Severity: Minor
                    Found in src/system/run.js - About 45 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status