src/system/run.js
File run.js
has 376 lines of code (exceeds 250 allowed). Consider refactoring. Open
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';
Function _wait_available
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
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');
Function runProvision
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
runProvision(system, options = {}) {
return async(this, function* () {
var steps = system.provision_steps;
options = _.clone(options);
Function _clean_sync_folder
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
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')) {
Function throwRunError
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) => {
Function runShell
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
runShell(system, options = {}) {
return async(this, function* () {
options = _.defaults(options, {
remove: false,
sequencies: yield this._getSequencies(system)
Function stop
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
stop(system, instances, options = {}) {
options = _.defaults(options, {
kill: false,
remove: true,
});
Function runDaemon
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
runDaemon(system, options = {}) {
return async(this, function* () {
// TODO: add instances and dependencies options
// Prepare options
var image = yield this._check_image(system, options);
Function runProvision
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
runProvision(system, options = {}) {
return async(this, function* () {
var steps = system.provision_steps;
options = _.clone(options);
- Read upRead up
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
Open
_wait_available(system, port_data, container, timeout, options, image_conf) {
Function throwRunError
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
throwRunError(system, container, command, data = null, stop = false, options = {}) {