Showing 5,781 of 10,536 total issues

Avoid deeply nested control flow statements.
Open

                        if parameters['constant'] is None:
                            raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
                                                   description='API.INVALID_CONSTANT_VALUE')

Severity: Major
Found in myems-api/core/equipment.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if meter_dict.get(numerator_meter_uuid) is None and \
                                    virtual_meter_dict.get(numerator_meter_uuid) is None and \
                                    offline_meter_dict.get(numerator_meter_uuid) is None:
                                raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
                                                       description='API.INVALID_NUMERATOR_METER_UUID')
    Severity: Major
    Found in myems-api/core/equipment.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if numerator_meter is None:
                                  numerator_meter = offline_meter_dict.get(row[5], None)
                              # find denominator meter by uuid
                              denominator_meter = meter_dict.get(row[6], None)
      Severity: Major
      Found in myems-api/core/equipment.py - About 45 mins to fix

        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/store.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 denominator_meter is None:
                                    denominator_meter = offline_meter_dict.get(row[6], None)
        
        
        Severity: Major
        Found in myems-api/core/equipment.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

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

            Avoid deeply nested control flow statements.
            Open

                                    if denominator_meter_uuid not in meter_dict and \
                                            denominator_meter_uuid not in virtual_meter_dict and \
                                            denominator_meter_uuid not in offline_meter_dict:
                                        raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
                                                               description='API.INVALID_DENOMINATOR_METER_UUID')
            Severity: Major
            Found in myems-api/core/equipment.py - About 45 mins to fix

              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/equipment.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if rows_offline_meters is not None and len(rows_offline_meters) > 0:
                                            for row in rows_offline_meters:
                                                offline_meter_dict[row[2]] = {"type": 'offline_meter',
                                                                              "id": row[0],
                                                                              "name": row[1],
                Severity: Major
                Found in myems-api/core/equipment.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

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

                    Avoid deeply nested control flow statements.
                    Open

                                            if rows_virtual_meters is not None and len(rows_virtual_meters) > 0:
                                                for row in rows_virtual_meters:
                                                    virtual_meter_dict[row[2]] = {"type": 'virtual_meter',
                                                                                  "id": row[0],
                                                                                  "name": row[1],
                    Severity: Major
                    Found in myems-api/core/equipment.py - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                    if (r == -2 || r == 2 || c == -2 || c == 2
                                        || (r == 0 && c == 0) ) {
                                      _modules[row + r][col + c] = true;
                                    } else {
                                      _modules[row + r][col + c] = false;
                      Severity: Major
                      Found in myems-admin/js/angular/qrcode.js - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                          "pluralCat": function(n, opt_precision) {  var vf = getVF(n, opt_precision);  if (n % 10 == 0 || n % 100 >= 11 && n % 100 <= 19 || vf.v == 2 && vf.f % 100 >= 11 && vf.f % 100 <= 19) {    return PLURAL_CATEGORY.ZERO;  }  if (n % 10 == 1 && n % 100 != 11 || vf.v == 2 && vf.f % 10 == 1 && vf.f % 100 != 11 || vf.v != 2 && vf.f % 10 == 1) {    return PLURAL_CATEGORY.ONE;  }  return PLURAL_CATEGORY.OTHER;}
                        Severity: Major
                        Found in myems-admin/js/angular/i18n/angular-locale_lv-lv.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                            "pluralCat": function(n, opt_precision) {  var vf = getVF(n, opt_precision);  if (n % 10 == 0 || n % 100 >= 11 && n % 100 <= 19 || vf.v == 2 && vf.f % 100 >= 11 && vf.f % 100 <= 19) {    return PLURAL_CATEGORY.ZERO;  }  if (n % 10 == 1 && n % 100 != 11 || vf.v == 2 && vf.f % 10 == 1 && vf.f % 100 != 11 || vf.v != 2 && vf.f % 10 == 1) {    return PLURAL_CATEGORY.ONE;  }  return PLURAL_CATEGORY.OTHER;}
                          Severity: Major
                          Found in myems-admin/js/angular/i18n/angular-locale_lv.js - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                              if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
                                if (!("classList" in document.createElement("a"))) {
                                  capableBrowser = false;
                                } else {
                                  // The browser supports the API, but may be blacklisted.
                            Severity: Major
                            Found in myems-admin/js/plugins/dropzone/dropzone.js - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if (ignoreTimezone || !m[13]) {
                                          var check = new Date(m[1], 0, 1, 9, 0);
                                          if (m[3]) {
                                              date.setMonth(m[3] - 1);
                                              check.setMonth(m[3] - 1);
                              Severity: Major
                              Found in myems-admin/js/plugins/fullcalendar/fullcalendar.min.js - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                                    if (s.bars.show || (s.lines.show && s.lines.fill)) {
                                                        var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
                                                        format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
                                                        if (s.bars.horizontal) {
                                                            delete format[format.length - 1].y;
                                Severity: Major
                                Found in myems-admin/js/plugins/flot/jquery.flot.js - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if ("footable_row_expanded" == a.type && (u = a.row, u && (p = t(e.table).data("expanded_rows"), c = [], p && (c = p.split(",")), c.push(u.rowIndex), t(e.table).data("expanded_rows", c.join(",")))), "footable_row_collapsed" == a.type && (u = a.row)) {
                                              p = t(e.table).data("expanded_rows"), c = [], p && (c = p.split(","));
                                              var g = [];
                                              for (var b in c)
                                                  if (c[b] == u.rowIndex) {
                                  Severity: Major
                                  Found in myems-admin/js/plugins/footable/footable.all.min.js - About 40 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                            if (
                                              b.options.enabled &&
                                              a &&
                                              ((a = U.getData()),
                                              a.source || (a.source = b.getDnDSource(d)),
                                    Severity: Major
                                    Found in myems-admin/js/jcui/angular.integralui.treeview.min.js - About 40 mins to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                              if (
                                                d &&
                                                a &&
                                                c &&
                                                (d =
                                      Severity: Major
                                      Found in myems-admin/js/jcui/angular.integralui.treeview.min.js - About 40 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language