Skip to content

Commit

Permalink
refactor(sdk-metrics): fix eslint warning
Browse files Browse the repository at this point in the history
```
/home/runner/work/opentelemetry-js/opentelemetry-js/packages/sdk-metrics/src/state/DeltaMetricProcessor.ts
  96:32  warning  Forbidden non-null assertion  @typescript-eslint/no-non-null-assertion
```

The assertion was intentional, base on the `.has()` check with the
same inputs immediately prior. The surrounding code has the same
patterns and used the eslint magic comment to disable the warning,
this one was just missed.

Ref open-telemetry#5365
  • Loading branch information
chancancode committed Jan 28, 2025
1 parent 199fd8d commit 446df47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/sdk-metrics/src/state/DeltaMetricProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class DeltaMetricProcessor<T extends Maybe<Accumulation>> {
attributes = this._overflowAttributes;
hashCode = this._overflowHashCode;
if (this._cumulativeMemoStorage.has(attributes, hashCode)) {
// has() returned true, previous is present.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const previous = this._cumulativeMemoStorage.get(
attributes,
hashCode
Expand All @@ -103,7 +105,7 @@ export class DeltaMetricProcessor<T extends Maybe<Accumulation>> {
}
// Merge with uncollected active delta.
if (this._activeCollectionStorage.has(attributes, hashCode)) {
// has() returned true, previous is present.
// has() returned true, active is present.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const active = this._activeCollectionStorage.get(
attributes,
Expand Down

0 comments on commit 446df47

Please sign in to comment.