Showing 5,781 of 10,536 total issues

Avoid deeply nested control flow statements.
Open

                        for row in rows_meters:
                            meter_dict[row[2]] = {"type": 'meter',
                                                  "id": row[0],
                                                  "name": row[1],
                                                  "uuid": row[2]}
Severity: Major
Found in myems-api/core/combinedequipment.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if numerator_meter is None:
                                numerator_meter = virtual_meter_dict.get(row[5], None)
                            if numerator_meter is None:
    Severity: Major
    Found in myems-api/core/combinedequipment.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if numerator_meter is None:
                                  numerator_meter = virtual_meter_dict.get(row[5], None)
                              if numerator_meter is None:
      Severity: Major
      Found in myems-api/core/combinedequipment.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if parameters['denominator_meter'] is not None and \
                                        isinstance(parameters['denominator_meter']['uuid'], str) and \
                                        len(str.strip(parameters['denominator_meter']['uuid'])) > 0:
                                    denominator_meter_uuid = str.strip(parameters['denominator_meter']['uuid'])
        
        
        Severity: Major
        Found in myems-api/core/combinedequipment.py - About 45 mins to fix

          Function access_control has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def access_control(req):
              """
                  Check user privilege in request headers to protect resources from invalid access
                  :param req: HTTP request
                  :return: HTTPError if invalid else None
          Severity: Minor
          Found in myems-api/core/useractivity.py - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_post(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',
                                             description='API.INVALID_POINT_ID')
          Severity: Minor
          Found in myems-api/core/point.py - About 45 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_get has a Cognitive Complexity of 8 (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/workingcalendar.py - About 45 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 8 (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/workingcalendar.py - About 45 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_get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_get(req, resp):
                  """Handles GET requests"""
                  admin_control(req)
                  cnx = mysql.connector.connect(**config.myems_system_db)
                  cursor = cnx.cursor()
          Severity: Minor
          Found in myems-api/core/point.py - About 45 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_get has a Cognitive Complexity of 8 (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/shopfloor.py - About 45 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_get has a Cognitive Complexity of 8 (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/shopfloor.py - About 45 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 8 (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/gateway.py - About 45 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 row_variable in rows_variables:
                                      if row_variable[2].lower() == 'meter':
                                          query_meter = (" SELECT m.name "
                                                         " FROM tbl_meters m "
                                                         " WHERE m.id = %s ")
          Severity: Major
          Found in myems-api/core/virtualmeter.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if row_meter is not None:
                                        expression['variables'].append({'id': row_variable[0],
                                                                        'name': row_variable[1],
                                                                        'meter_type': row_variable[2],
                                                                        'meter_id': row_variable[3],
            Severity: Major
            Found in myems-api/core/virtualmeter.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if row_meter is not None:
                                          expression['variables'].append({'id': row_variable[0],
                                                                          'name': row_variable[1],
                                                                          'meter_type': row_variable[2],
                                                                          'meter_id': row_variable[3],
              Severity: Major
              Found in myems-api/core/virtualmeter.py - About 45 mins to fix

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

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

                def admin_control(req):
                    """
                    Check administrator privilege in request headers to protect resources from invalid access
                    :param req: HTTP request
                    :return: HTTPError if invalid else None
                Severity: Minor
                Found in myems-api/core/useractivity.py - About 45 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

                                        if row_meter is not None:
                                            expression['variables'].append({'id': row_variable[0],
                                                                            'name': row_variable[1],
                                                                            'meter_type': row_variable[2],
                                                                            'meter_id': row_variable[3],
                Severity: Major
                Found in myems-api/core/virtualmeter.py - About 45 mins to fix

                  Function on_post has a Cognitive Complexity of 8 (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/svg.py - About 45 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

                  Severity
                  Category
                  Status
                  Source
                  Language