Showing 10,536 of 10,536 total issues

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

app.controller('ModalEditEnergyStoragePowerStationCtrl', function($scope, $uibModalInstance, params) {
    $scope.operation = "SETTING.EDIT_ENERGY_STORAGE_POWER_STATION";
    $scope.energystoragepowerstation = params.energystoragepowerstation;
    $scope.costcenters=params.costcenters;
    $scope.contacts=params.contacts;
myems-admin/app/controllers/settings/microgrid/microgrid.controller.js on lines 318..332

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

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(compare=="trend"){
            if(idx==len-1){
                output=val.toFixed(4);
            }else{
                output=val.toFixed(2);
Severity: Major
Found in myems-admin/app/filters/filter.js and 1 other location - About 6 hrs to fix
myems-admin/app/filters/filter.js on lines 177..192

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

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

app.controller('ModalEditMicrogridCtrl', function($scope, $uibModalInstance, params) {
    $scope.operation = "SETTING.EDIT_MICROGRID";
    $scope.microgrid = params.microgrid;
    $scope.costcenters=params.costcenters;
    $scope.contacts=params.contacts;
myems-admin/app/controllers/settings/energystoragepowerstation/energystoragepowerstation.controller.js on lines 318..332

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

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(compare=="trend"){
            if(idx==len-1){
                output=val.toFixed(4);
            }else{
                output=val.toFixed(2);
Severity: Major
Found in myems-admin/app/filters/filter.js and 1 other location - About 6 hrs to fix
myems-admin/app/filters/filter.js on lines 150..165

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

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-route.js has 435 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: Minor
Found in myems-admin/js/angular/angular-route.js - About 6 hrs to fix

    Function ProductAdd has 161 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ProductAdd = () => {
      const { products, productsDispatch } = useContext(ProductContext);
      const [title, setTitle] = useState('');
      const [category, setCategory] = useState('Camera');
      const [files, setFiles] = useState([]);
    Severity: Major
    Found in myems-web/src/components/e-commerce/ProductAdd.js - About 6 hrs to fix

      Function on_get has 161 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def on_get(req, resp):
              # todo: change this procedure from space to store
              if 'API-KEY' not in req.headers or \
                      not isinstance(req.headers['API-KEY'], str) or \
                      len(str.strip(req.headers['API-KEY'])) == 0:
      Severity: Major
      Found in myems-api/reports/storedashboard.py - About 6 hrs to fix

        Function on_get has 161 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def on_get(req, resp):
                # todo: change this procedure from space to shopfloor
                if 'API-KEY' not in req.headers or \
                        not isinstance(req.headers['API-KEY'], str) or \
                        len(str.strip(req.headers['API-KEY'])) == 0:
        Severity: Major
        Found in myems-api/reports/shopfloordashboard.py - About 6 hrs to fix

          Function on_get has 161 lines of code (exceeds 25 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: Major
          Found in myems-api/reports/dashboard.py - About 6 hrs to fix

            Function on_get has 161 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def on_get(req, resp):
                    # todo: change this procedure from space to tenant
                    if 'API-KEY' not in req.headers or \
                            not isinstance(req.headers['API-KEY'], str) or \
                            len(str.strip(req.headers['API-KEY'])) == 0:
            Severity: Major
            Found in myems-api/reports/tenantdashboard.py - About 6 hrs to fix

              Function MicrogridListItem has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

              const MicrogridListItem = ({
                id,
                uuid,
                files,
                name,
              Severity: Minor
              Found in myems-web/src/components/MyEMS/Microgrid/MicrogridListItem.js - About 6 hrs 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 42 (exceeds 5 allowed). Consider refactoring.
              Open

                  def on_get(req, resp):
                      """Handles GET requests"""
                      access_control(req)
                      # Verify User Session
                      token = req.headers.get('TOKEN')
              Severity: Minor
              Found in myems-api/core/webmessage.py - About 6 hrs 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

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

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

              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],
                                             "area": row[3],
                                             "is_input_counted": bool(row[4]),
              Severity: Major
              Found in myems-api/core/shopfloor.py and 1 other location - About 6 hrs to fix
              myems-api/core/shopfloor.py on lines 251..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 103.

              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 'lower_limit' not in new_values.keys() or \
                              new_values['lower_limit'] is None:
                          lower_limit = None
                      elif not (isinstance(new_values['lower_limit'], float) or
                                isinstance(new_values['lower_limit'], int)):
              Severity: Major
              Found in myems-api/core/point.py and 1 other location - About 6 hrs to fix
              myems-api/core/point.py on lines 1061..1069

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

              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 'higher_limit' not in new_values.keys() or \
                              new_values['higher_limit'] is None:
                          higher_limit = None
                      elif not (isinstance(new_values['higher_limit'], float) or
                                isinstance(new_values['higher_limit'], int)):
              Severity: Major
              Found in myems-api/core/point.py and 1 other location - About 6 hrs to fix
              myems-api/core/point.py on lines 1072..1080

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

              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 rows_meters is not None and len(rows_meters) > 0:
                          for row in rows_meters:
                              virtual_meter_dict[row[0]] = {"virtual_meter_name": row[1],
                                                            "energy_category_id": row[2],
                                                            "space_name": row[3],
              Severity: Major
              Found in myems-api/reports/virtualmeterbatch.py and 1 other location - About 6 hrs to fix
              myems-api/reports/offlinemeterbatch.py on lines 157..165

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

              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 rows_offline_meters is not None and len(rows_offline_meters) > 0:
                          for row in rows_offline_meters:
                              offline_meter_dict[row[0]] = {"offline_meter_name": row[1],
                                                            "energy_category_id": row[2],
                                                            "space_name": row[3],
              Severity: Major
              Found in myems-api/reports/offlinemeterbatch.py and 1 other location - About 6 hrs to fix
              myems-api/reports/virtualmeterbatch.py on lines 157..165

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

              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 160 lines of code (exceeds 25 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: Major
              Found in myems-api/reports/spaceproduction.py - About 6 hrs to fix

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

                        setStartDate: function(startDate) {
                            if (typeof startDate === 'string')
                                this.startDate = moment(startDate, this.format).utcOffset(this.timeZone);
                
                            if (typeof startDate === 'object')
                Severity: Major
                Found in myems-admin/js/plugins/daterangepicker/daterangepicker.js and 1 other location - About 6 hrs to fix
                myems-admin/js/plugins/daterangepicker/daterangepicker.js on lines 474..489

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

                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