mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-12 17:45:49 +08:00
`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>
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
// Copyright 2021 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';
|
|
|
|
const rule = require('../lib/check_enumerated_histograms.js');
|
|
const ruleTester = new (require('eslint').RuleTester)({
|
|
parserOptions: {ecmaVersion: 9, sourceType: 'module'},
|
|
parser: require.resolve('@typescript-eslint/parser'),
|
|
});
|
|
|
|
ruleTester.run('check_enumerated_histograms', rule, {
|
|
valid: [
|
|
{
|
|
code: 'InspectorFrontendHostInstance.recordEnumeratedHistogram(\'someparam\', 1, foo.MaxValue);',
|
|
filename: 'front_end/components/test.ts',
|
|
},
|
|
{
|
|
code:
|
|
'InspectorFrontendHostInstance.recordEnumeratedHistogram(EnumeratedHistogram.IssueCreated, issueCreated, IssueCreated.MaxValue);',
|
|
filename: 'front_end/components/test.ts'
|
|
}
|
|
],
|
|
invalid: [{
|
|
code: 'InspectorFrontendHostInstance.recordEnumeratedHistogram(\'someparam\', 1, 5);',
|
|
filename: 'front_end/components/test.ts',
|
|
errors: [{
|
|
message:
|
|
'When calling \'recordEnumeratedHistogram\' the third argument should be of the form \'SomeEnum.MaxValue\'.'
|
|
}],
|
|
}]
|
|
});
|