Nanocloud/nanocloud

View on GitHub
api/drivers/aws/driver.js

Summary

Maintainability
F
4 days
Test Coverage

File driver.js has 465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Nanocloud turns any traditional software into a cloud solution, without
 * changing or redeveloping existing source code.
 *
 * Copyright (C) 2016 Nanocloud Software
Severity: Minor
Found in api/drivers/aws/driver.js - About 7 hrs to fix

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

      initialize() {
        return ConfigService.get(
          'awsAccessKeyId', 'awsSecretAccessKey', 'awsRegion',
          'awsKeyName', 'awsPrivateKey', 'awsImage', 'awsMachinePassword'
        )
    Severity: Major
    Found in api/drivers/aws/driver.js - About 3 hrs to fix

      Function createMachine has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        createMachine(machine, image) {
          return ConfigService.get('instancesSize', 'plazaURI', 'awsKeyName', 'plazaPort',
            'awsMachineSubnet', 'awsDiskSize', 'awsMachineUsername', 'rdpPort')
            .then((config) => {
      
      
      Severity: Major
      Found in api/drivers/aws/driver.js - About 3 hrs to fix

        Function refresh has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          refresh(machine) {
            return this.getServer(machine.id)
              .then((res) => {
        
                machine.ip = res.addresses.public[0] || res.addresses.private[0];
        Severity: Minor
        Found in api/drivers/aws/driver.js - About 1 hr to fix

          Function getAwsPrice has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getAwsPrice() {
              let confReg = {
                'us-east-1': 'US East (N.Virginia)',
                'us-west-2': 'US West (Oregon)',
                'ap-southeast-1': 'Asia Pacific (Singapore)',
          Severity: Minor
          Found in api/drivers/aws/driver.js - About 1 hr to fix

            Function createImage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              createImage(imageToCreate) {
            
                return new Promise((resolve, reject) => {
                  this._client.ec2.createImage({
                    Name: imageToCreate.name,
            Severity: Minor
            Found in api/drivers/aws/driver.js - About 1 hr to fix

              Function getUserCredit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getUserCredit(user) {
              
                  return this.awsPrice.then((price) => {
                    return new Promise((resolve, reject) => {
                      var finalPrice = 0;
              Severity: Minor
              Found in api/drivers/aws/driver.js - About 1 hr to fix

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

                        this.awsPrice = new Promise((resolve, reject) => {
                          return Promise.props({
                            conf: ConfigService.get('awsRegion'),
                            keyPrice: Object.keys(price.products)
                          })
                Severity: Minor
                Found in api/drivers/aws/driver.js - About 1 hr to fix

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

                          user.getHistory('aws')
                            .then((machineHistory) => {
                  
                              /**
                               * Here we retrieve all the machines keys of the
                  Severity: Major
                  Found in api/drivers/aws/driver.js and 1 other location - About 6 hrs to fix
                  api/drivers/dummy/driver.js on lines 253..276

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

                  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

                    getServer(id) {
                      return new Promise((resolve, reject) => {
                        this._client.getServer(id, (err, server) => {
                          if (err) {
                            reject(err);
                  Severity: Major
                  Found in api/drivers/aws/driver.js and 1 other location - About 2 hrs to fix
                  api/drivers/openstack/driver.js on lines 225..235

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

                  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

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

                                    return fs.writeFileAsync(
                                      config.awsPrivateKey,
                                      res.KeyMaterial, {
                                        encoding: 'utf8',
                                        mode: 0o600,
                  Severity: Major
                  Found in api/drivers/aws/driver.js and 1 other location - About 1 hr to fix
                  api/drivers/aws/driver.js on lines 97..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 56.

                  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

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

                                          return fs.writeFileAsync(
                                            config.awsPrivateKey,
                                            res.KeyMaterial, {
                                              encoding: 'utf8',
                                              mode: 0o600,
                  Severity: Major
                  Found in api/drivers/aws/driver.js and 1 other location - About 1 hr to fix
                  api/drivers/aws/driver.js on lines 114..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 56.

                  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

                      return new Promise((resolve, reject) => {
                        this._client.destroyServer(machine.id, (err) => {
                          if (err) {
                            reject(err);
                          } else {
                  Severity: Minor
                  Found in api/drivers/aws/driver.js and 1 other location - About 55 mins to fix
                  api/drivers/openstack/driver.js on lines 206..214

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

                  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

                        this._client.ec2.startInstances(params, (err) => {
                          if (err) {
                            return reject(err);
                          }
                  
                  
                  Severity: Minor
                  Found in api/drivers/aws/driver.js and 1 other location - About 35 mins to fix
                  api/drivers/aws/driver.js on lines 383..388

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

                  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

                        this._client.ec2.stopInstances(params, (err) => {
                          if (err) {
                            return reject(err);
                          }
                          return resolve(machine);
                  Severity: Minor
                  Found in api/drivers/aws/driver.js and 1 other location - About 35 mins to fix
                  api/drivers/aws/driver.js on lines 358..364

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

                  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

                          Promise.props({
                            machine: Machine.findOne(imageToCreate.buildFrom),
                            config: ConfigService.get('instancesSize')
                          })
                            .then(({machine, config}) => {
                  Severity: Minor
                  Found in api/drivers/aws/driver.js and 1 other location - About 30 mins to fix
                  api/services/MachineService.js on lines 845..895

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

                  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