Showing 10,536 of 10,536 total issues

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

        if battery_state_point_id is not None:
            point_values = []
            point_timestamps = []
            query = (" SELECT utc_date_time, actual_value "
                     " FROM tbl_digital_value "
Severity: Major
Found in myems-api/reports/energystoragepowerstationdetails.py and 1 other location - About 1 day to fix
myems-api/reports/microgriddetails.py on lines 832..855

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

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 storeplan.py has 743 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    File storesaving.py has 743 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

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

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

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

              let onSpaceCascaderChange = (value, selectedOptions) => {
                setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
                let selectedSpaceID = value[value.length - 1];
                setSpinnerHidden(false);
                //begin of getting meters of the selected space
            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 146..182

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

            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

              let onSpaceCascaderChange = (value, selectedOptions) => {
                setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
                let selectedSpaceID = value[value.length - 1];
                setSpinnerHidden(false);
                //begin of getting sensors of the selected space
            myems-web/src/components/MyEMS/Meter/MeterRealtime.js on lines 146..182

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

            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

                        for item in formdata:
                            start_datetime_local = datetime(year=int(item[0][0:4]),
                                                            month=int(item[0][5:7]),
                                                            day=int(item[0][8:10]))
                            start_datetime_utc = start_datetime_local - timedelta(minutes=timezone_offset)
            Severity: Major
            Found in myems-api/reports/enterproduction.py and 1 other location - About 1 day to fix
            myems-api/reports/offlinemeterinput.py on lines 42..52

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

            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

                        for onepieces in formdata:
                            start_datetime_local = datetime(year=int(onepieces[0][0:4]),
                                                            month=int(onepieces[0][5:7]),
                                                            day=int(onepieces[0][8:10]))
                            start_datetime_utc = start_datetime_local - timedelta(minutes=timezone_offset)
            Severity: Major
            Found in myems-api/reports/offlinemeterinput.py and 1 other location - About 1 day to fix
            myems-api/reports/enterproduction.py on lines 242..252

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

            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 datasource.py has 733 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

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

                  def on_get(req, resp, id_):
                      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/core/tenant.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 tenantstatistics.py has 732 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/tenantstatistics.py - About 1 day to fix

                File spacestatistics.py has 730 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import base64
                from core.utilities import get_translation
                import os
                import uuid
                import openpyxl.utils.cell as format_cell
                Severity: Major
                Found in myems-api/excelexporters/spacestatistics.py - About 1 day to fix

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

                      @staticmethod
                      def on_delete(req, resp, id_):
                          admin_control(req)
                          if not id_.isdigit() or int(id_) <= 0:
                              raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
                  Severity: Major
                  Found in myems-api/core/apikey.py and 1 other location - About 1 day to fix
                  myems-api/core/workingcalendar.py on lines 423..448

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

                  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

                      @staticmethod
                      def on_delete(req, resp, id_):
                          admin_control(req)
                          if not id_.isdigit() or int(id_) <= 0:
                              raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
                  Severity: Major
                  Found in myems-api/core/workingcalendar.py and 1 other location - About 1 day to fix
                  myems-api/core/apikey.py on lines 225..250

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

                  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 84 (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/energystoragepowerstationdashboard.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 shopfloorstatistics.py has 722 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/shopfloorstatistics.py - About 1 day to fix

                    Function $$AnimationProvider has 333 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var $$AnimationProvider = ['$animateProvider', /** @this */ function($animateProvider) {
                      var NG_ANIMATE_REF_ATTR = 'ng-animate-ref';
                    
                      var drivers = this.drivers = [];
                    
                    
                    Severity: Major
                    Found in myems-admin/js/angular/angular-animate.js - About 1 day to fix

                      File equipmentplan.py has 721 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/equipmentplan.py - About 1 day to fix
                        Severity
                        Category
                        Status
                        Source
                        Language