myems-admin/app/controllers/settings/space/space.controller.js

Summary

Maintainability
F
6 days
Test Coverage

File space.controller.js has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

app.controller('SpaceController', function (
    $scope,
    $rootScope,
Severity: Minor
Found in myems-admin/app/controllers/settings/space/space.controller.js - About 5 hrs to fix

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

        $scope.editSpace = function (space) {
            var modalInstance = $uibModal.open({
                windowClass: "animated fadeIn",
                templateUrl: 'views/settings/space/space.model.html',
                controller: 'ModalEditSpaceCtrl',
    Severity: Minor
    Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

      Function addSpace has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $scope.addSpace = function () {
              var modalInstance = $uibModal.open({
                  templateUrl: 'views/settings/space/space.model.html',
                  controller: 'ModalAddSpaceCtrl',
                  windowClass: "animated fadeIn",
      Severity: Minor
      Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

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

            $scope.deleteSpace = function (space) {
                SweetAlert.swal({
                    title: $translate.instant("SWEET.TITLE"),
                    text: $translate.instant("SWEET.TEXT"),
                    type: "warning",
        Severity: Minor
        Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

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

              $scope.importSpace = function() {
                  var modalInstance = $uibModal.open({
                      templateUrl: 'views/common/import.html',
                      controller: 'ModalImportCtrl',
                      windowClass: "animated fadeIn",
          Severity: Minor
          Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

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

                $scope.getAllSpaces = function () {
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    SpaceService.getAllSpaces(headers, function (response) {
                        if (angular.isDefined(response.status) && response.status === 200) {
                            $scope.spaces = response.data;
            Severity: Minor
            Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

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

                  $scope.refreshSpaceTree = function () {
                      let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                      SpaceService.getAllSpaces(headers, function (response) {
                          if (angular.isDefined(response.status) && response.status === 200) {
                              $scope.spaces = response.data;
              Severity: Minor
              Found in myems-admin/app/controllers/settings/space/space.controller.js - About 1 hr to fix

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

                    $scope.importSpace = function() {
                        var modalInstance = $uibModal.open({
                            templateUrl: 'views/common/import.html',
                            controller: 'ModalImportCtrl',
                            windowClass: "animated fadeIn",
                myems-admin/app/controllers/settings/datasource/datasource.controller.js on lines 226..262
                myems-admin/app/controllers/settings/energystoragepowerstation/energystoragepowerstation.controller.js on lines 252..288
                myems-admin/app/controllers/settings/meter/meter.controller.js on lines 337..373
                myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 280..316
                myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 259..295

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

                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 6 locations. Consider refactoring.
                Open

                    $scope.cloneSpace = function(space){
                        let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                        SpaceService.cloneSpace(space, headers, function(response) {
                            if (angular.isDefined(response.status) && response.status === 201) {
                                toaster.pop({
                myems-admin/app/controllers/settings/datasource/datasource.controller.js on lines 204..224
                myems-admin/app/controllers/settings/energystoragepowerstation/energystoragepowerstation.controller.js on lines 230..250
                myems-admin/app/controllers/settings/meter/meter.controller.js on lines 315..335
                myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 258..278
                myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 237..257

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

                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

                    $scope.getSpaceChildren = function (spaceid) {
                        let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                        SpaceService.getSpaceChildren(spaceid, headers, function (response) {
                            if (angular.isDefined(response.status) && response.status === 200) {
                                $scope.currentSpace = response.data["current"];
                myems-admin/app/controllers/settings/menu/menu.controller.js on lines 88..99

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

                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 8 locations. Consider refactoring.
                Open

                app.controller('ModalEditSpaceCtrl', function ($scope, $uibModalInstance, params) {
                    $scope.operation = "SETTING.EDIT_SPACE";
                    $scope.space = params.space;
                    $scope.timezones = params.timezones;
                    $scope.costcenters = params.costcenters;
                myems-admin/app/controllers/settings/energystoragecontainer/energystoragecontainer.controller.js on lines 214..227
                myems-admin/app/controllers/settings/energystoragecontainer/energystoragecontainerpowerconversionsystem.controller.js on lines 699..712
                myems-admin/app/controllers/settings/microgrid/microgridpowerconversionsystem.controller.js on lines 247..260
                myems-admin/app/controllers/settings/photovoltaicpowerstation/photovoltaicpowerstation.controller.js on lines 305..318
                myems-admin/app/controllers/settings/store/store.controller.js on lines 312..325
                myems-admin/app/controllers/settings/virtualpowerplant/virtualpowerplant.controller.js on lines 306..320
                myems-admin/app/controllers/settings/windfarm/windfarm.controller.js on lines 305..318

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

                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