myems-admin/app/controllers/users/apikey/apikey.controller.js

Summary

Maintainability
C
1 day
Test Coverage

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

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

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

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

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

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

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

            $scope.ok = function () {
                $scope.apiKey.created_datetime_utc = moment($scope.apiKey.created_datetime_utc).format().slice(0,19);
                $scope.apiKey.expires_datetime_utc = moment($scope.apiKey.expires_datetime_utc).format().slice(0,19);
                $uibModalInstance.close($scope.apiKey);
            };
        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/settings/tenant/tenant.controller.js on lines 355..359

        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

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

            $scope.isButtonDisabled = function() {
                if ($scope.apiKey.name && $scope.apiKey.expires_datetime_utc > $scope.apiKey.created_datetime_utc) {
                    return false;
                } else {
                    return true;
        myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 162..168

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

        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.isButtonDisabled = function() {
                if ($scope.apiKey.name && $scope.apiKey.expires_datetime_utc > $scope.apiKey.created_datetime_utc) {
                    return false;
                } else {
                    return true;
        myems-admin/app/controllers/users/apikey/apikey.controller.js on lines 200..206

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

        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",
        Severity: Major
        Found in myems-admin/app/controllers/users/apikey/apikey.controller.js and 5 other locations - About 55 mins to fix
        myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 316..326
        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 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",
        Severity: Major
        Found in myems-admin/app/controllers/users/apikey/apikey.controller.js and 5 other locations - About 55 mins to fix
        myems-admin/app/controllers/settings/tenant/tenant.controller.js on lines 316..326
        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

        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