Showing 10,536 of 10,536 total issues

File spaceenergyitem.py has 706 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/spaceenergyitem.py - About 1 day to fix

    Function highchart has 323 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function highchart(highchartsNGUtils, $timeout) {
    
        // acceptable shared state
        var seriesId = 0;
        var ensureIds = function (series) {
    Severity: Major
    Found in myems-admin/js/angular-highcharts/highcharts-ng.js - About 1 day to fix

      File MicrogridDetails.js has 705 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { Fragment, useState, useEffect, useContext } from 'react';
      import {
        Card,
        CardBody,
        Col,
      Severity: Major
      Found in myems-web/src/components/MyEMS/Microgrid/MicrogridDetails.js - About 1 day to fix

        File equipmentload.py has 702 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/equipmentload.py - About 1 day to fix

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

          const AuthCardRoutes = ({ match: { url } }) => (
            <Switch>
              <Route path={`${url}/login`} exact component={Login} />
              <Route path={`${url}/logout`} exact component={Logout} />
              <Route path={`${url}/register`} exact component={Registration} />
          Severity: Major
          Found in myems-web/src/components/auth/card/AuthCardRoutes.js and 1 other location - About 1 day to fix
          myems-web/src/components/auth/split/AuthSplitRoutes.js on lines 12..25

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

          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

          const AuthSplitRoutes = ({ match: { url } }) => (
            <Switch>
              <Route path={`${url}/login`} exact component={Login} />
              <Route path={`${url}/logout`} exact component={Logout} />
              <Route path={`${url}/register`} exact component={Registration} />
          Severity: Major
          Found in myems-web/src/components/auth/split/AuthSplitRoutes.js and 1 other location - About 1 day to fix
          myems-web/src/components/auth/card/AuthCardRoutes.js on lines 11..24

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

          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

          Function on_get has a Cognitive Complexity of 80 (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/metertrend.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 2 locations. Consider refactoring.
          Open

              value: function _finished(files, responseText, e) {
                var _iteratorNormalCompletion29 = true;
                var _didIteratorError29 = false;
                var _iteratorError29 = undefined;
          
          
          Severity: Major
          Found in myems-admin/js/plugins/dropzone/dropzone.js and 1 other location - About 1 day to fix
          myems-admin/js/plugins/dropzone/dropzone.js on lines 3026..3061

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

          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

              value: function _errorProcessing(files, message, xhr) {
                var _iteratorNormalCompletion30 = true;
                var _didIteratorError30 = false;
                var _iteratorError30 = undefined;
          
          
          Severity: Major
          Found in myems-admin/js/plugins/dropzone/dropzone.js and 1 other location - About 1 day to fix
          myems-admin/js/plugins/dropzone/dropzone.js on lines 2986..3021

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

          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

                  if 'latitude' in new_values['data'].keys():
                      if new_values['data']['latitude'] is not None:
                          if not (isinstance(new_values['data']['latitude'], float) or
                                  isinstance(new_values['data']['latitude'], int)) or \
                                  new_values['data']['latitude'] < -90.0 or \
          Severity: Major
          Found in myems-api/core/space.py and 1 other location - About 1 day to fix
          myems-api/core/space.py on lines 569..581

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

          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

                  if 'longitude' in new_values['data'].keys():
                      if new_values['data']['latitude'] is not None:
                          if not (isinstance(new_values['data']['longitude'], float) or
                                  isinstance(new_values['data']['longitude'], int)) or \
                                  new_values['data']['longitude'] < -180.0 or \
          Severity: Major
          Found in myems-api/core/space.py and 1 other location - About 1 day to fix
          myems-api/core/space.py on lines 555..567

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

          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 angular-message-format.js has 697 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * @license AngularJS v1.8.3
           * (c) 2010-2020 Google LLC. http://angularjs.org
           * License: MIT
           */
          Severity: Major
          Found in myems-admin/js/angular/angular-message-format.js - About 1 day to fix

            Function $get has 317 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                   function($$jqLite,   $rootScope,   $injector,   $$AnimateRunner,   $$Map,   $$rAFScheduler, $$animateCache) {
            
                var animationQueue = [];
                var applyAnimationClasses = applyAnimationClassesFactory($$jqLite);
            
            
            Severity: Major
            Found in myems-admin/js/angular/angular-animate.js - About 1 day to fix

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

              app.factory('TenantWorkingCalendarService', function($http) {
                  return {
                      addPair: function(tenantID, workingcalendarID, headers, callback) {
                          $http.post(getAPI()+'tenants/'+tenantID+'/workingcalendars', {data: {"working_calendar_id": workingcalendarID}}, {headers})
                          .then(function (response) {
              myems-admin/app/services/settings/shopfloor/shopfloorworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/space/spaceworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/store/storeworkingcalendar.service.js on lines 2..30

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

              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

              app.factory('SpaceWorkingCalendarService', function($http) {
                  return {
                      addPair: function(spaceID, workingcalendarID, headers, callback) {
                          $http.post(getAPI()+'spaces/'+spaceID+'/workingcalendars', {data: {"working_calendar_id": workingcalendarID}}, {headers})
                          .then(function (response) {
              myems-admin/app/services/settings/shopfloor/shopfloorworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/store/storeworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/tenant/tenantworkingcalendar.service.js on lines 2..30

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

              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

              app.factory('ShopfloorWorkingCalendarService', function($http) {
                  return {
                      addPair: function(shopfloorID, workingcalendarID, headers, callback) {
                          $http.post(getAPI()+'shopfloors/'+shopfloorID+'/workingcalendars', {data: {"working_calendar_id": workingcalendarID}}, {headers})
                          .then(function (response) {
              myems-admin/app/services/settings/space/spaceworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/store/storeworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/tenant/tenantworkingcalendar.service.js on lines 2..30

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

              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

              app.factory('StoreWorkingCalendarService', function($http) {
                  return {
                      addPair: function(storeID, workingcalendarID, headers, callback) {
                          $http.post(getAPI()+'stores/'+storeID+'/workingcalendars', {data: {"working_calendar_id": workingcalendarID}}, {headers})
                          .then(function (response) {
              myems-admin/app/services/settings/shopfloor/shopfloorworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/space/spaceworkingcalendar.service.js on lines 2..30
              myems-admin/app/services/settings/tenant/tenantworkingcalendar.service.js on lines 2..30

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

              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

              Function on_get has a Cognitive Complexity of 79 (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/energystoragepowerstationitemenergy.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

              Function on_get has a Cognitive Complexity of 79 (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/energystoragepowerstationitemcarbon.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

              Function on_get has a Cognitive Complexity of 79 (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/energystoragepowerstationitembilling.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

              Severity
              Category
              Status
              Source
              Language