Files
react-native-devtools-frontend/scripts/eslint_rules/lib/check_enumerated_histograms.js
T
Wolfgang Beyer b2da5bb358 Allow removal of entries from UMA enums
`recordEnumeratedHistogram()` needs both the actual bucket and the total
number of buckets. The total number of buckets was previously determined
by `Object.keys(someMap).length`. This prevented us from ever removing
keys from `someMap` since its length would change.
By explicitly adding a `LastValidEnumPosition` we can now safely remove
keys.

Bug: 1278403
Change-Id: Ib256fc2cf54123f596aa9c5525cce2aabe28bec0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3329541
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
2021-12-21 08:42:54 +00:00

33 lines
970 B
JavaScript

// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'check arguments when recording enumerated histograms',
category: 'Possible Errors',
},
fixable: 'code',
schema: [] // no options
},
create: function(context) {
return {
CallExpression(node) {
if (node?.callee?.object?.name === 'InspectorFrontendHostInstance' &&
node.callee.property.name === 'recordEnumeratedHistogram') {
if (node?.arguments[2]?.property?.name !== 'MaxValue') {
context.report({
node: node,
message:
'When calling \'recordEnumeratedHistogram\' the third argument should be of the form \'SomeEnum.MaxValue\'.'
});
}
}
}
};
}
};