Showing 10,536 of 10,536 total issues

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

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

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

          <Card className="bg-light mb-3">
            <CardBody className="p-3">
              <Form>
                <Row form>
                  <Col xs={6} sm={3}>
    myems-web/src/components/MyEMS/Meter/MeterRealtime.js on lines 234..263

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

    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

          <Card className="bg-light mb-3">
            <CardBody className="p-3">
              <Form>
                <Row form>
                  <Col xs={6} sm={3}>
    Severity: Major
    Found in myems-web/src/components/MyEMS/Meter/MeterRealtime.js and 1 other location - About 1 day to fix
    myems-web/src/components/MyEMS/Space/SpaceEnvironmentMonitor.js on lines 234..263

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

    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 $SanitizeProvider has 294 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function $SanitizeProvider() {
      var hasBeenInstantiated = false;
      var svgEnabled = false;
    
      this.$get = ['$$sanitizeUri', function($$sanitizeUri) {
    Severity: Major
    Found in myems-admin/js/angular/angular-sanitize.js - About 1 day to fix

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

              modalInstance.result.then(function(distributionsystem) {
                  distributionsystem.svg_id = distributionsystem.svg.id;
                  let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                  DistributionSystemService.addDistributionSystem(distributionsystem, headers, function (response) {
                      if (angular.isDefined(response.status) && response.status === 201) {
      myems-admin/app/controllers/settings/distributionsystem/distributionsystem.controller.js on lines 95..117

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

      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(modifiedDistributionSystem) {
                  modifiedDistributionSystem.svg_id = modifiedDistributionSystem.svg.id;
                  let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
                  DistributionSystemService.editDistributionSystem(modifiedDistributionSystem, headers, function (response) {
                      if (angular.isDefined(response.status) && response.status === 200) {
      myems-admin/app/controllers/settings/distributionsystem/distributionsystem.controller.js on lines 52..74

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

      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 spaceoutput.py has 654 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/spaceoutput.py - About 1 day to fix

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

                if row is None:
                    raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
                                           description='API.ENERGY_STORAGE_POWER_STATION_NOT_FOUND')
                else:
                    meta_result = {"id": row[0],
        Severity: Major
        Found in myems-api/core/energystoragepowerstation.py and 1 other location - About 1 day to fix
        myems-api/core/energystoragepowerstation.py on lines 72..87

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

        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

                        meta_result = {"id": row[0],
                                       "name": row[1],
                                       "uuid": row[2],
                                       "address": row[3],
                                       "postal_code": row[4],
        Severity: Major
        Found in myems-api/core/energystoragepowerstation.py and 1 other location - About 1 day to fix
        myems-api/core/energystoragepowerstation.py on lines 341..360

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

        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 slimScroll has 290 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            slimScroll: function(options) {
        
              var defaults = {
        
                // width in pixels of the visible scroll area
        Severity: Major
        Found in myems-admin/js/plugins/slimscroll/jquery.slimscroll.js - About 1 day to fix

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

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

              File tariff.py has 646 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                Function Transition has 287 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var Transition = /** @class */ (function () {
                        /**
                         * Creates a new Transition object.
                         *
                         * If the target state is not valid, an error is thrown.
                Severity: Major
                Found in myems-admin/js/ui-router/angular-ui-router.js - About 1 day to fix

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

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

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

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

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