myems-admin/app/controllers/settings/meter/virtualmeter.controller.js

Summary

Maintainability
F
2 wks
Test Coverage

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

'use strict';

app.controller('VirtualMeterController', function($scope, $rootScope, $window, $uibModal, $translate,
    MeterService,
    VirtualMeterService,
Severity: Major
Found in myems-admin/app/controllers/settings/meter/virtualmeter.controller.js - About 1 day to fix

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

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

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

          $scope.addVirtualMeter = function() {
              var modalInstance = $uibModal.open({
                  templateUrl: 'views/settings/meter/virtualmeter.model.html',
                  controller: 'ModalAddVirtualMeterCtrl',
                  windowClass: 'animated fadeIn',

        Function deleteVirtualMeter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            $scope.deleteVirtualMeter = function(virtualmeter) {
                SweetAlert.swal({
                        title: $translate.instant("SWEET.TITLE"),
                        text: $translate.instant("SWEET.TEXT"),
                        type: "warning",

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

              $scope.importVirtualMeter = function() {
                  var modalInstance = $uibModal.open({
                      templateUrl: 'views/common/import.html',
                      controller: 'ModalImportCtrl',
                      windowClass: "animated fadeIn",

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

                    modalInstance.result.then(function(modifiedVirtualMeter) {
                        modifiedVirtualMeter.energy_category_id = modifiedVirtualMeter.energy_category.id;
                        if (modifiedVirtualMeter.energy_item != null && modifiedVirtualMeter.energy_item.id != null ) {
                            modifiedVirtualMeter.energy_item_id = modifiedVirtualMeter.energy_item.id;
                        } else {
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 130..160

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

            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(virtualmeter) {
                        virtualmeter.energy_category_id = virtualmeter.energy_category.id;
                        if(angular.isDefined(virtualmeter.energy_item)) {
                            virtualmeter.energy_item_id = virtualmeter.energy_item.id;
                        } else {
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 78..108

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

            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.importVirtualMeter = 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/space/space.controller.js on lines 331..367
            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.cloneVirtualMeter = function(virtualmeter){
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    VirtualMeterService.cloneVirtualMeter(virtualmeter, 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/space/space.controller.js on lines 309..329
            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.add = function() {
                    var variable = {
                        name: 'x' + ($scope.counter),
                        meter_type: $scope.currentMeterType.selected.sid,
                        meter_id: $scope.currentMeter.selected.id,
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 538..558

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

            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.add = function() {
                    var variable = {
                        name: 'x' + ($scope.counter),
                        meter_type: $scope.currentMeterType.selected.sid,
                        meter_id: $scope.currentMeter.selected.id,
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 406..427

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

            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

                $scope.changeMeterType = function() {
                    switch ($scope.currentMeterType.selected.sid) {
                        case 'meter':
                            $scope.currentmeters = $scope.meters;
                            break;
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 568..590

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

            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

                $scope.changeMeterType = function() {
                    switch ($scope.currentMeterType.selected.sid) {
                        case 'meter':
                            $scope.currentmeters = $scope.meters;
                            break;
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 437..459

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

            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.change_energyitems = function(selected_energy_category_id) {
                    var i = 0;
                    var j = 0;
                    $scope.energyitems = [];
                    for (; i < params.energyitems.length; i++){
            myems-admin/app/controllers/settings/meter/meter.controller.js on lines 405..425
            myems-admin/app/controllers/settings/meter/meter.controller.js on lines 445..465
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 317..337
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 358..378
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 510..530

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

            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.change_energyitems = function(selected_energy_category_id) {
                    var i = 0;
                    var j = 0;
                    $scope.energyitems = [];
                    for (; i < params.energyitems.length; i++){
            myems-admin/app/controllers/settings/meter/meter.controller.js on lines 405..425
            myems-admin/app/controllers/settings/meter/meter.controller.js on lines 445..465
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 317..337
            myems-admin/app/controllers/settings/meter/offlinemeter.controller.js on lines 358..378
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 384..404

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

            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

                $scope.delete = function(key) {
                    $scope.virtualmeter.expression.variables.splice(key, 1);
                    $timeout(function() {
                        angular.element('#variablesTable').trigger('footable_redraw');
                    }, 10);
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 428..434

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

            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

                $scope.delete = function(key) {
                    $scope.virtualmeter.expression.variables.splice(key, 1);
                    $timeout(function() {
                        angular.element('#variablesTable').trigger('footable_redraw');
                    }, 10);
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 559..565

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

            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

                $scope.metertypes = [{
                    sid: 'meter',
                    name: 'SETTING.METER'
                }, {
                    sid: 'virtual_meter',
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 358..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 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

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

                $scope.metertypes = [{
                    sid: 'meter',
                    name: 'SETTING.METER'
                }, {
                    sid: 'virtual_meter',
            myems-admin/app/controllers/settings/meter/virtualmeter.controller.js on lines 473..482

            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