Nanocloud/nanocloud

View on GitHub

Showing 292 of 292 total issues

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

      if (user.id !== this.get('session.user.id')) {
        user.set('isTeamAdmin', false);
        user.save()
          .then(() => {
            this.toast.success(user.get('fullName') + ' is now a regular user');
Severity: Major
Found in assets/app/protected/users/teams/index/controller.js and 1 other location - About 4 hrs to fix
assets/app/protected/users/teams/index/controller.js on lines 129..141

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

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

    toAdminTeam(user) {
      user.set('isTeamAdmin', true);
      user.save()
        .then(() => {
          this.toast.success(user.get('fullName') + ' has been promoted to team admin');
Severity: Major
Found in assets/app/protected/users/teams/index/controller.js and 1 other location - About 4 hrs to fix
assets/app/protected/users/teams/index/controller.js on lines 144..156

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

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

  afterDestroy(destroyedRecords, next) {
    if (!destroyedRecords.length) {
      return next();
    }

Severity: Major
Found in api/models/User.js and 1 other location - About 4 hrs to fix
api/models/Group.js on lines 64..76

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

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 (req.user.isAdmin) {
      App.findOne({
        id: req.allParams().id
      })
        .populate('image')
Severity: Major
Found in api/controllers/AppController.js and 1 other location - About 4 hrs to fix
api/controllers/ImageController.js on lines 105..123

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

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 (req.user.isAdmin) {
      Image.findOne({
        id: req.allParams().id
      })
        .populate('apps')
Severity: Major
Found in api/controllers/ImageController.js and 1 other location - About 4 hrs to fix
api/controllers/AppController.js on lines 90..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 116.

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

  afterDestroy(destroyedRecords, next) {
    if (!destroyedRecords.length) {
      return next();
    }

Severity: Major
Found in api/models/Group.js and 1 other location - About 4 hrs to fix
api/models/User.js on lines 238..250

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

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 startProcessAsUser has 126 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func startProcessAsUser(
    argv0 string, argv []string,
    username string, domain string,
    attr *syscall.ProcAttr,
) (pid int, handle uintptr, err error) {
Severity: Major
Found in plaza/windows/startprocess.go - About 4 hrs to fix

    Function updateMachinesPool has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function updateMachinesPool() {
    
      return assert(!!_driver, driverNotInitializedError)
        .then(() => {
    
    
    Severity: Major
    Found in api/services/MachineService.js - About 3 hrs to fix

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

        initialize() {
          this._machines = {};
          this.dummyPrice = new Promise((resolve) => {
            return resolve({
              products : {
      Severity: Major
      Found in api/drivers/dummy/driver.js - About 3 hrs to fix

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

          return knex.schema.table('template', (table) => {
            // There is no method in knex for datatype changes.
            // https://github.com/tgriesser/knex/issues/46
            table.renameColumn('content', 'old_content');
          })
        Severity: Major
        Found in api/migrations/024_fix_template_schema.js and 1 other location - About 3 hrs to fix
        api/migrations/024_fix_template_schema.js on lines 26..47

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

        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 knex.schema.table('template', (table) => {
            // There is no method in knex for datatype changes.
            // https://github.com/tgriesser/knex/issues/46
            table.renameColumn('content', 'old_content');
          })
        Severity: Major
        Found in api/migrations/024_fix_template_schema.js and 1 other location - About 3 hrs to fix
        api/migrations/024_fix_template_schema.js on lines 56..80

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

        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 getMachineForUser has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getMachineForUser(user, image) {
          return assert(!!_driver, driverNotInitializedError)
            .then(() => {
              return ConfigService.get('creditLimit');
            })
        Severity: Major
        Found in api/services/MachineService.js - About 3 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 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              createMachine(options) {
                return ConfigService.get(
                  'openstackImage', 'openstackFlavor', 'openstackSecurityGroups', 'rdpPort',
                  'openstackMachineUsername', 'openstackMachinePassword', 'plazaURI', 'plazaPort'
                )
            Severity: Major
            Found in api/drivers/openstack/driver.js - About 3 hrs to fix

              Function Get has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
              Open

              func Get(c *echo.Context) error {
                  filepath := c.Query("path")
                  showHidden := c.Query("show_hidden") == "true"
                  create := c.Query("create") == "true"
              
              
              Severity: Minor
              Found in plaza/routes/files/files.go - About 3 hrs 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

              File AppController.js has 298 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/controllers/AppController.js - About 3 hrs to fix

                Function startConnection has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  startConnection() {
                
                    if (Ember.isEmpty(this.get('connectionName'))) {
                      return ;
                    }
                Severity: Major
                Found in assets/app/components/remote-session/component.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

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

                                  return PlazaService.exec(machine.ip, machine.plazaport, {
                                    command: [
                                      `C:\\Windows\\System32\\net.exe`,
                                      'use',
                                      'z:',
                    Severity: Major
                    Found in api/services/MachineService.js and 1 other location - About 2 hrs to fix
                    api/services/MachineService.js on lines 811..823

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

                    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 PlazaService.exec(machine.ip, machine.plazaport, {
                                            command: [
                                              `C:\\Windows\\System32\\net.exe`,
                                              'use',
                                              'z:',
                    Severity: Major
                    Found in api/services/MachineService.js and 1 other location - About 2 hrs to fix
                    api/services/MachineService.js on lines 779..791

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language