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

Summary

Maintainability
F
1 wk
Test Coverage

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

'use strict';

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

    Function editTenant has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $scope.editTenant = function (tenant) {
            var modalInstance = $uibModal.open({
                windowClass: "animated fadeIn",
                templateUrl: 'views/settings/tenant/tenant.model.html',
                controller: 'ModalEditTenantCtrl',
    Severity: Minor
    Found in myems-admin/app/controllers/settings/tenant/tenant.controller.js - About 2 hrs to fix

      Function addTenant has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $scope.addTenant = function () {
              var modalInstance = $uibModal.open({
                  templateUrl: 'views/settings/tenant/tenant.model.html',
                  controller: 'ModalAddTenantCtrl',
                  windowClass: "animated fadeIn",
      Severity: Minor
      Found in myems-admin/app/controllers/settings/tenant/tenant.controller.js - About 2 hrs to fix

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

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

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

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

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

                    modalInstance.result.then(function (modifiedTenant) {
                        modifiedTenant.tenant_type_id = modifiedTenant.tenant_type.id;
                        modifiedTenant.cost_center_id = modifiedTenant.cost_center.id;
                        modifiedTenant.contact_id = modifiedTenant.contact.id;
                        if (angular.isDefined(tenant.is_input_counted) == false) {
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 78..110

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

            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

                    modalInstance.result.then(function (tenant) {
                        tenant.tenant_type_id = tenant.tenant_type.id;
                        tenant.cost_center_id = tenant.cost_center.id;
                        tenant.contact_id = tenant.contact.id;
                        if (angular.isDefined(tenant.is_input_counted) == false) {
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 133..165

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

            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.importTenant = 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/space/space.controller.js on lines 331..367

            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.cloneTenant = function(tenant){
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    TenantService.cloneTenant(tenant, 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/space/space.controller.js on lines 309..329

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

                $scope.ok = function () {
                    $scope.tenant.lease_start_datetime = moment($scope.tenant.lease_start_datetime).format().slice(0, 19);
                    $scope.tenant.lease_end_datetime = moment($scope.tenant.lease_end_datetime).format().slice(0, 19);
                    $uibModalInstance.close($scope.tenant);
                };
            myems-admin/app/controllers/settings/tariff/tariff.controller.js on lines 386..390
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 355..359
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 222..226

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

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

                $scope.ok = function () {
                    $scope.tenant.lease_start_datetime = moment($scope.tenant.lease_start_datetime).format().slice(0, 19);
                    $scope.tenant.lease_end_datetime = moment($scope.tenant.lease_end_datetime).format().slice(0, 19);
                    $uibModalInstance.close($scope.tenant);
                };
            myems-admin/app/controllers/settings/tariff/tariff.controller.js on lines 386..390
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 327..331
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 222..226

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

            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.dtOptions = {
                    locale: {
                        format: 'YYYY-MM-DD HH:mm:ss',
                        applyLabel: "OK",
                        cancelLabel: "Cancel",
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 316..326
            myems-admin/app/controllers/settings/workingcalendar/workingcalendarnonworkingday.controller.js on lines 259..269
            myems-admin/app/controllers/settings/workingcalendar/workingcalendarnonworkingday.controller.js on lines 287..297
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 175..185
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 210..220

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

                $scope.dtOptions = {
                    locale: {
                        format: 'YYYY-MM-DD HH:mm:ss',
                        applyLabel: "OK",
                        cancelLabel: "Cancel",
            myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 344..354
            myems-admin/app/controllers/settings/workingcalendar/workingcalendarnonworkingday.controller.js on lines 259..269
            myems-admin/app/controllers/settings/workingcalendar/workingcalendarnonworkingday.controller.js on lines 287..297
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 175..185
            myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 210..220

            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

            There are no issues that match your filters.

            Category
            Status