Showing 10,536 of 10,536 total issues

File tenantenergycategory.py has 620 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
from datetime import datetime, timedelta, timezone
from decimal import Decimal
import falcon
import mysql.connector
Severity: Major
Found in myems-api/reports/tenantenergycategory.py - About 1 day to fix

    File equipmentenergyitem.py has 619 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import base64
    from core.utilities import get_translation
    import os
    import re
    import uuid
    Severity: Major
    Found in myems-api/excelexporters/equipmentenergyitem.py - About 1 day to fix

      Function editEnergyStorageContainerPowerconversionsystem has 270 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            $scope.editEnergyStorageContainerPowerconversionsystem = function(energystoragecontainerpowerconversionsystem) {
                var modalInstance = $uibModal.open({
                    templateUrl: 'views/settings/energystoragecontainer/energystoragecontainerpowerconversionsystem.model.html',
                    controller: 'ModalEditEnergyStorageContainerPowerconversionsystemCtrl',
                  windowClass: "animated fadeIn",

        Function addEnergyStorageContainerPowerconversionsystem has 269 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              $scope.addEnergyStorageContainerPowerconversionsystem = function() {
        
                  var modalInstance = $uibModal.open({
                      templateUrl: 'views/settings/energystoragecontainer/energystoragecontainerpowerconversionsystem.model.html',
                      controller: 'ModalAddEnergyStorageContainerPowerconversionsystemCtrl',

          File distributionsystem.py has 615 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import uuid
          from datetime import datetime, timedelta
          import falcon
          import mysql.connector
          import simplejson as json
          Severity: Major
          Found in myems-api/core/distributionsystem.py - About 1 day to fix

            Function on_get has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
            Open

                def on_get(req, resp):
                    if 'API-KEY' not in req.headers or \
                            not isinstance(req.headers['API-KEY'], str) or \
                            len(str.strip(req.headers['API-KEY'])) == 0:
                        access_control(req)
            Severity: Minor
            Found in myems-api/reports/spaceenvironmentmonitor.py - About 1 day 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

            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

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

                    for (var row=0; row<rowCnt; row++) {
            
                        // first and last cell offset for the row
                        var rowCellOffsetFirst = row * colCnt;
                        var rowCellOffsetLast = rowCellOffsetFirst + colCnt - 1;
            Severity: Major
            Found in myems-admin/js/plugins/fullcalendar/fullcalendar.js and 1 other location - About 1 day to fix
            myems-admin/js/plugins/fullcalendar/fullcalendar.min.js on lines 5044..5079

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

                $scope.cloneDataSource = function(datasource){
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    DataSourceService.cloneDataSource(datasource, headers, function(response) {
                        if (angular.isDefined(response.status) && response.status === 201) {
                            toaster.pop({
            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
            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 6 locations. Consider refactoring.
            Open

                $scope.cloneMeter = function(meter){
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    MeterService.cloneMeter(meter, 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/virtualmeter.controller.js on lines 258..278
            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 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

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

                        for (var row=0; row<rowCnt; row++) {
            
                            // first and last cell offset for the row
                            var rowCellOffsetFirst = row * colCnt;
                            var rowCellOffsetLast = rowCellOffsetFirst + colCnt - 1;
            Severity: Major
            Found in myems-admin/js/plugins/fullcalendar/fullcalendar.min.js and 1 other location - About 1 day to fix
            myems-admin/js/plugins/fullcalendar/fullcalendar.js on lines 7337..7373

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

                $scope.cloneEnergyStoragePowerStation = function(energystoragepowerstation){
                    let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                    EnergyStoragePowerStationService.cloneEnergyStoragePowerStation(energystoragepowerstation, 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/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
            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

            File combinedequipmentoutput.py has 614 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import base64
            from core.utilities import get_translation
            import os
            import re
            import uuid
            Severity: Major
            Found in myems-api/excelexporters/combinedequipmentoutput.py - About 1 day to fix

              File workingcalendar.py has 610 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import falcon
              from datetime import datetime, timedelta
              import mysql.connector
              import simplejson as json
              from core.useractivity import admin_control, access_control, api_key_control
              Severity: Major
              Found in myems-api/core/workingcalendar.py - About 1 day to fix

                Function on_post has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
                Open

                    def on_post(req, resp):
                        """Handles POST requests"""
                        admin_control(req)
                        try:
                            raw_json = req.stream.read().decode('utf-8')
                Severity: Minor
                Found in myems-api/core/meter.py - About 1 day 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 TenantBill.js has 607 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { Fragment, useEffect, useState, useContext } from 'react';
                import PropTypes from 'prop-types';
                import {
                  Breadcrumb,
                  BreadcrumbItem,
                Severity: Major
                Found in myems-web/src/components/MyEMS/Tenant/TenantBill.js - About 1 day to fix

                  Function link has 264 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              link: function (scope, element, attrs, ngModel) {
                                  function prepareViews() {
                                      scope.views = datePickerConfig.views.concat();
                                      scope.view = attrs.view || datePickerConfig.view;
                  
                  
                  Severity: Major
                  Found in myems-admin/js/plugins/datapicker/angular-datepicker.js - About 1 day to fix

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

                              <ul>
                                <li>
                                  <code>.d-print-none</code>
                                </li>
                                <li>
                    Severity: Major
                    Found in myems-web/src/components/utilities/Display.js and 1 other location - About 1 day to fix
                    myems-web/src/components/utilities/Display.js on lines 47..75

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

                    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