myems-api/core/distributionsystem.py

Summary

Maintainability
F
2 wks
Test Coverage

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

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

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

        def on_post(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/distributionsystem.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_post has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_post(req, resp):
            """Handles POST requests"""
            admin_control(req)
            try:
                raw_json = req.stream.read().decode('utf-8')
    Severity: Minor
    Found in myems-api/core/distributionsystem.py - About 4 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 26 (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/distributionsystem.py - About 3 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 11 (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/core/distributionsystem.py - About 1 hr 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 10 (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/distributionsystem.py - About 1 hr 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 9 (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/distributionsystem.py - About 55 mins 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_put has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_put(req, resp, id_):
            """Handles PUT requests"""
            admin_control(req)
            try:
                raw_json = req.stream.read().decode('utf-8')
    Severity: Minor
    Found in myems-api/core/distributionsystem.py - About 55 mins 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_post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_post(req, resp):
            """Handles POST requests"""
            admin_control(req)
            try:
                raw_json = req.stream.read().decode('utf-8')
    Severity: Minor
    Found in myems-api/core/distributionsystem.py - About 55 mins 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

    Avoid deeply nested control flow statements.
    Open

                            for point in circuit['points']:
                                cursor.execute(" SELECT name "
                                               " FROM tbl_points "
                                               " WHERE id = %s ", (point['id'],))
                                if cursor.fetchone() is None:
    Severity: Major
    Found in myems-api/core/distributionsystem.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if cursor.fetchone() is None:
                                  cursor.close()
                                  cnx.close()
                                  raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND',
                                                         description='API.POINT_NOT_FOUND')
      Severity: Major
      Found in myems-api/core/distributionsystem.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if cursor.fetchone() is not None:
                                    cursor.close()
                                    cnx.close()
                                    raise falcon.HTTPError(status=falcon.HTTP_400, title='API.ERROR',
                                                           description='API.DISTRIBUTION_CIRCUIT_POINT_RELATION_EXISTS')
        Severity: Major
        Found in myems-api/core/distributionsystem.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for point_row in rows:
                                      point_result = {"id": point_row[0], "name": point_row[1], "address": point_row[2]}
                                      points.append(point_result)
                                  circuit_result['points'] = points
          Severity: Major
          Found in myems-api/core/distributionsystem.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for point_row in rows:
                                        point_result = {"id": point_row[0], "name": point_row[1]}
                                        points.append(point_result)
                                    circuit_result['points'] = points
            Severity: Major
            Found in myems-api/core/distributionsystem.py - About 45 mins to fix

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

                          if meta_result['circuits'] is not None and len(meta_result['circuits']) > 0:
                              for circuit in meta_result['circuits']:
                                  add_values = (" INSERT INTO tbl_distribution_circuits "
                                                "    (name, uuid, distribution_system_id,"
                                                "     distribution_room, switchgear, peak_load, peak_current, customers, meters) "
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 3 days to fix
              myems-api/core/distributionsystem.py on lines 525..564

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

              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 new_values['circuits'] is not None and len(new_values['circuits']) > 0:
                          for circuit in new_values['circuits']:
                              add_values = (" INSERT INTO tbl_distribution_circuits "
                                            "    (name, uuid, distribution_system_id,"
                                            "     distribution_room, switchgear, peak_load, peak_current, customers, meters) "
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 3 days to fix
              myems-api/core/distributionsystem.py on lines 665..705

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

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

                                  if rows is not None and len(rows) > 0:
                                      for point_row in rows:
                                          point_result = {"id": point_row[0], "name": point_row[1], "address": point_row[2]}
                                          points.append(point_result)
                                      circuit_result['points'] = points
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 37 other locations - About 4 hrs to fix
              myems-api/core/combinedequipment.py on lines 2357..2361
              myems-api/core/combinedequipment.py on lines 2371..2375
              myems-api/core/combinedequipment.py on lines 3030..3034
              myems-api/core/combinedequipment.py on lines 3044..3048
              myems-api/core/equipment.py on lines 2174..2180
              myems-api/core/equipment.py on lines 2776..2782
              myems-api/core/shopfloor.py on lines 1998..2002
              myems-api/core/shopfloor.py on lines 2011..2015
              myems-api/core/shopfloor.py on lines 2136..2140
              myems-api/core/shopfloor.py on lines 2149..2153
              myems-api/core/shopfloor.py on lines 2559..2563
              myems-api/core/shopfloor.py on lines 2572..2576
              myems-api/core/shopfloor.py on lines 2697..2701
              myems-api/core/shopfloor.py on lines 2710..2714
              myems-api/core/space.py on lines 3737..3741
              myems-api/core/space.py on lines 3828..3832
              myems-api/core/space.py on lines 3841..3845
              myems-api/core/space.py on lines 3854..3858
              myems-api/core/space.py on lines 3892..3896
              myems-api/core/space.py on lines 3905..3909
              myems-api/core/space.py on lines 3918..3922
              myems-api/core/space.py on lines 3931..3935
              myems-api/core/store.py on lines 1958..1962
              myems-api/core/store.py on lines 2074..2078
              myems-api/core/store.py on lines 2087..2091
              myems-api/core/store.py on lines 2534..2538
              myems-api/core/store.py on lines 2548..2552
              myems-api/core/store.py on lines 2561..2565
              myems-api/core/store.py on lines 2574..2578
              myems-api/core/store.py on lines 2612..2616
              myems-api/core/store.py on lines 2625..2629
              myems-api/core/tenant.py on lines 2082..2086
              myems-api/core/tenant.py on lines 2202..2206
              myems-api/core/tenant.py on lines 2215..2219
              myems-api/core/tenant.py on lines 2710..2714
              myems-api/core/tenant.py on lines 2830..2834
              myems-api/core/tenant.py on lines 2843..2847

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

              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

                      if rows_svgs is not None and len(rows_svgs) > 0:
                          for row in rows_svgs:
                              svg_dict[row[0]] = {"id": row[0],
                                                  "name": row[1],
                                                  "uuid": row[2],
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 4 hrs to fix
              myems-api/core/distributionsystem.py on lines 167..172

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

              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

                      if rows_svgs is not None and len(rows_svgs) > 0:
                          for row in rows_svgs:
                              svg_dict[row[0]] = {"id": row[0],
                                                  "name": row[1],
                                                  "uuid": row[2],
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 4 hrs to fix
              myems-api/core/distributionsystem.py on lines 35..40

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

              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

                                  circuit_result = {"id": row[0], "name": row[1], "uuid": row[2],
                                                    "distribution_room": row[3], "switchgear": row[4],
                                                    "peak_load": row[5], "peak_current": row[6],
                                                    "customers": row[7], "meters": row[8],
                                                    "points": None}
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 4 hrs to fix
              myems-api/core/distributionsystem.py on lines 627..631

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

              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

                                  circuit_result = {"id": row[0], "name": row[1], "uuid": row[2],
                                                    "distribution_room": row[3], "switchgear": row[4],
                                                    "peak_load": row[5], "peak_current": row[6],
                                                    "customers": row[7], "meters": row[8],
                                                    "points": None}
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 4 hrs to fix
              myems-api/core/distributionsystem.py on lines 419..423

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

              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

                              meta_result = {"id": row[0], "name": row[1], "uuid": row[2],
                                             "distribution_room": row[3], "switchgear": row[4],
                                             "peak_load": row[5], "peak_current": row[6],
                                             "customers": row[7], "meters": row[8]}
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 4 hrs to fix
              myems-api/core/energystoragecontainer.py on lines 5960..5968

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

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

                                  if rows is not None and len(rows) > 0:
                                      for point_row in rows:
                                          point_result = {"id": point_row[0], "name": point_row[1]}
                                          points.append(point_result)
                                      circuit_result['points'] = points
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 16 other locations - About 4 hrs to fix
              myems-api/core/meter.py on lines 1422..1426
              myems-api/core/meter.py on lines 1738..1742
              myems-api/core/sensor.py on lines 522..526
              myems-api/core/sensor.py on lines 666..670
              myems-api/core/space.py on lines 4547..4551
              myems-api/core/space.py on lines 4562..4566
              myems-api/core/space.py on lines 4577..4581
              myems-api/core/space.py on lines 4592..4596
              myems-api/core/space.py on lines 4607..4611
              myems-api/core/space.py on lines 4622..4626
              myems-api/core/space.py on lines 4637..4641
              myems-api/core/space.py on lines 4652..4656
              myems-api/core/space.py on lines 4667..4671
              myems-api/core/space.py on lines 4682..4686
              myems-api/core/space.py on lines 4697..4701
              myems-api/core/space.py on lines 4712..4716

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

              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

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

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

              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],
                                             "svg": svg_dict.get(row[3], None),
                                             "description": row[4]}
              Severity: Major
              Found in myems-api/core/distributionsystem.py and 1 other location - About 2 hrs to fix
              myems-api/core/distributionsystem.py on lines 183..191

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

              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

                          cursor.execute(add_values, (new_name,
                                                      str(uuid.uuid4()),
                                                      meta_result['svg_id'],
                                                      meta_result['description']))
              Severity: Minor
              Found in myems-api/core/distributionsystem.py and 1 other location - About 45 mins to fix
              myems-api/core/svg.py on lines 439..442

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

              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

              There are no issues that match your filters.

              Category
              Status