azukiapp/azk

View on GitHub
src/agent/vm.js

Summary

Maintainability
D
2 days
Test Coverage

File vm.js has 466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { _, path, config, log, isBlank, fsAsync } from 'azk';
import { subscribe, publish } from 'azk/utils/postal';
import { async, promisify, thenAll, promisifyModule } from 'azk/utils/promises';
import Utils from 'azk/utils';
import { Tools } from 'azk/agent/tools';
Severity: Minor
Found in src/agent/vm.js - About 7 hrs to fix

    Function config_disks has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function config_disks(name, boot, data) {
      var use_link = true;
    
      var storage_opts = [
        "storagectl"   , name  ,
    Severity: Minor
    Found in src/agent/vm.js - About 1 hr to fix

      Function init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        init(opts = {}) {
          opts = _.defaults(opts, {
            dhcp: false,
          });
      
      
      Severity: Minor
      Found in src/agent/vm.js - About 1 hr to fix

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

          mount(vm_name, share, point, opts = {}) {
            _.defaults(opts, {
              umask: "0000",
              gid  : "vboxsf",
              uid  : config("agent:vm:user"),
        Severity: Minor
        Found in src/agent/vm.js - About 1 hr to fix

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

            stop(vm_name, force = false, timeout = 30) {
              log.debug("[vm] call to stop vm %s", vm_name);
          
              return Tools.async_status("vm", this, function* (status_change) {
                var info = yield vm.info(vm_name);
          Severity: Minor
          Found in src/agent/vm.js - About 1 hr to fix

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

              remove(vm_name) {
                return Tools.async_status("vm", this, function* (status_change) {
                  var info = yield vm.info(vm_name);
            
                  if (info.name == vm_name) {
            Severity: Minor
            Found in src/agent/vm.js - About 1 hr to fix

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

              dhcp.getByNetworkName = function(name) {
                return this.list_servers().then((list) => {
                  return _.find(list, (server) => server.NetworkName == name);
                });
              };
              Severity: Major
              Found in src/agent/vm.js and 1 other location - About 1 hr to fix
              src/agent/vm.js on lines 74..78

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

              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

              hostonly.getByName = function(name) {
                return this.list().then((list) => {
                  return _.find(list, (net) => net.Name == name);
                });
              };
              Severity: Major
              Found in src/agent/vm.js and 1 other location - About 1 hr to fix
              src/agent/vm.js on lines 80..84

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

              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

                copyFile(name, origin, target) {
                  return this.make_ssh(name).then((ssh) => { return ssh.putFile(origin, target); });
                },
              Severity: Minor
              Found in src/agent/vm.js and 1 other location - About 40 mins to fix
              src/agent/vm.js on lines 508..510

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

              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

                copyVMFile(name, origin, target) {
                  return this.make_ssh(name).then((ssh) => { return ssh.getFile(origin, target); });
                },
              Severity: Minor
              Found in src/agent/vm.js and 1 other location - About 40 mins to fix
              src/agent/vm.js on lines 504..506

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

              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

              There are no issues that match your filters.

              Category
              Status