From 4a9964675e8c550cae22f9532a03b4b5027beaa3 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Mon, 1 Mar 2021 09:31:35 +0100 Subject: [PATCH 1/3] chore: don't disable rule eqeqeq --- eslint.config.js | 5 ++++- .../src/baggage/propagation/HttpBaggage.ts | 8 +++++--- packages/opentelemetry-core/src/utils/environment.ts | 2 +- .../test/common/transformMetrics.test.ts | 2 +- packages/opentelemetry-instrumentation-fetch/src/fetch.ts | 2 +- packages/opentelemetry-metrics/test/Meter.test.ts | 2 +- .../opentelemetry-propagator-b3/src/B3SinglePropagator.ts | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 663e6b32adf..41a00792995 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,7 +12,10 @@ module.exports = { }, rules: { "@typescript-eslint/no-this-alias": "off", - "eqeqeq": "off", + "eqeqeq": [ + "error", + "smart" + ], "prefer-rest-params": "off", "@typescript-eslint/naming-convention": [ "error", diff --git a/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts b/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts index 6b40dcf66e8..8b2b309ac33 100644 --- a/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts +++ b/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts @@ -63,7 +63,9 @@ export class HttpBaggage implements TextMapPropagator { private _serializeKeyPairs(keyPairs: string[]) { return keyPairs.reduce((hValue: string, current: string) => { - const value = `${hValue}${hValue != '' ? ITEMS_SEPARATOR : ''}${current}`; + const value = `${hValue}${ + hValue !== '' ? ITEMS_SEPARATOR : '' + }${current}`; return value.length > MAX_TOTAL_LENGTH ? hValue : value; }, ''); } @@ -81,7 +83,7 @@ export class HttpBaggage implements TextMapPropagator { const headerValue: string = getter.get(carrier, BAGGAGE_HEADER) as string; if (!headerValue) return context; const baggage: Record = {}; - if (headerValue.length == 0) { + if (headerValue.length === 0) { return context; } const pairs = headerValue.split(ITEMS_SEPARATOR); @@ -107,7 +109,7 @@ export class HttpBaggage implements TextMapPropagator { const keyPairPart = valueProps.shift(); if (!keyPairPart) return; const keyPair = keyPairPart.split(KEY_PAIR_SEPARATOR); - if (keyPair.length != 2) return; + if (keyPair.length !== 2) return; const key = decodeURIComponent(keyPair[0].trim()); const value = decodeURIComponent(keyPair[1].trim()); let metadata; diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index ad67f440a3b..c353a386731 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -173,7 +173,7 @@ function setLogLevelFromEnv( const value = values[key]; if (typeof value === 'string') { const theLevel = logLevelMap[value.toUpperCase()]; - if (theLevel != undefined) { + if (theLevel != null) { environment[key] = theLevel; } } diff --git a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts index 30ede3ffd2f..14203f5d604 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transformMetrics.test.ts @@ -66,7 +66,7 @@ describe('transformMetrics', () => { let count3 = 0; function getValue(count: number) { - if (count % 2 == 0) { + if (count % 2 === 0) { return 3; } return -1; diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 033b6b92eeb..5aa369d82b9 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -112,7 +112,7 @@ export class FetchInstrumentation extends InstrumentationBase< ): void { const parsedUrl = web.parseUrl(response.url); span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, response.status); - if (response.statusText != undefined) { + if (response.statusText != null) { span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, response.statusText); } span.setAttribute(HttpAttribute.HTTP_HOST, parsedUrl.host); diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index aafbb610959..dc6cf471f0f 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -808,7 +808,7 @@ describe('Meter', () => { function getValue() { console.log('getting value, counter:', counter); - if (++counter % 2 == 0) { + if (++counter % 2 === 0) { return 3; } return -1; diff --git a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts index 91f8d7d00db..8e751cfb799 100644 --- a/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts +++ b/packages/opentelemetry-propagator-b3/src/B3SinglePropagator.ts @@ -37,7 +37,7 @@ const SAMPLED_VALUES = new Set(['d', '1']); const DEBUG_STATE = 'd'; function convertToTraceId128(traceId: string): string { - return traceId.length == 32 ? traceId : `${PADDING}${traceId}`; + return traceId.length === 32 ? traceId : `${PADDING}${traceId}`; } function convertToTraceFlags(samplingState: string | undefined): TraceFlags { From 31f88c3d3e4860843614c12a69dc9c1c6f52e0c7 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Tue, 2 Mar 2021 00:07:46 +0100 Subject: [PATCH 2/3] chore: more strict eqeqeq --- eslint.config.js | 4 ---- .../src/AsyncLocalStorageContextManager.ts | 3 ++- packages/opentelemetry-core/src/common/attributes.ts | 6 +++--- packages/opentelemetry-core/src/utils/environment.ts | 2 +- packages/opentelemetry-instrumentation-fetch/src/fetch.ts | 2 +- .../test/integrations/http-enable.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../test/utils/httpRequest.ts | 2 +- .../test/utils/httpsRequest.ts | 2 +- .../test/functionals/http-package.test.ts | 2 +- .../test/integrations/http-enable.test.ts | 2 +- .../opentelemetry-plugin-http/test/utils/httpRequest.ts | 2 +- .../test/functionals/https-package.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../opentelemetry-plugin-https/test/utils/httpsRequest.ts | 2 +- packages/opentelemetry-tracing/src/Span.ts | 3 ++- 16 files changed, 19 insertions(+), 21 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 41a00792995..5eb52ccf048 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,10 +12,6 @@ module.exports = { }, rules: { "@typescript-eslint/no-this-alias": "off", - "eqeqeq": [ - "error", - "smart" - ], "prefer-rest-params": "off", "@typescript-eslint/naming-convention": [ "error", diff --git a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts index 0af8695911b..a1f4df09c10 100644 --- a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts @@ -36,7 +36,8 @@ export class AsyncLocalStorageContextManager extends AbstractAsyncHooksContextMa thisArg?: ThisParameterType, ...args: A ): ReturnType { - const cb = thisArg == null ? fn : fn.bind(thisArg); + const cb = + thisArg === null || thisArg === undefined ? fn : fn.bind(thisArg); return this._asyncLocalStorage.run(context, cb as never, ...args); } diff --git a/packages/opentelemetry-core/src/common/attributes.ts b/packages/opentelemetry-core/src/common/attributes.ts index df6b8f7a57f..ae887437852 100644 --- a/packages/opentelemetry-core/src/common/attributes.ts +++ b/packages/opentelemetry-core/src/common/attributes.ts @@ -18,7 +18,7 @@ import { SpanAttributeValue, SpanAttributes } from '@opentelemetry/api'; export function sanitizeAttributes(attributes: unknown): SpanAttributes { const out: SpanAttributes = {}; - if (attributes == null || typeof attributes !== 'object') { + if (attributes === null || typeof attributes !== 'object') { return out; } @@ -36,7 +36,7 @@ export function sanitizeAttributes(attributes: unknown): SpanAttributes { } export function isAttributeValue(val: unknown): val is SpanAttributeValue { - if (val == null) { + if (val === null || val === undefined) { return true; } @@ -52,7 +52,7 @@ function isHomogeneousAttributeValueArray(arr: unknown[]): boolean { for (const element of arr) { // null/undefined elements are allowed - if (element == null) continue; + if (element === null || element === undefined) continue; if (!type) { if (isValidPrimitiveAttributeValue(element)) { diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index c353a386731..2fd5ccc2370 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -173,7 +173,7 @@ function setLogLevelFromEnv( const value = values[key]; if (typeof value === 'string') { const theLevel = logLevelMap[value.toUpperCase()]; - if (theLevel != null) { + if (typeof theLevel === 'number') { environment[key] = theLevel; } } diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 5aa369d82b9..6b6bb2961dd 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -112,7 +112,7 @@ export class FetchInstrumentation extends InstrumentationBase< ): void { const parsedUrl = web.parseUrl(response.url); span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, response.status); - if (response.statusText != null) { + if (typeof response.statusText === 'string') { span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, response.statusText); } span.setAttribute(HttpAttribute.HTTP_HOST, parsedUrl.host); diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index 9995cd985c9..7c0346fb8ea 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -68,7 +68,7 @@ describe('HttpInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index 7df9f3e771b..8894ecdcff3 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -80,7 +80,7 @@ describe('HttpsInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts index f507b7f1f17..0c2da0c113c 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts index f75cf1e5663..3cd346953fc 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts index be05279d9a4..748eb9ebf0a 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -58,7 +58,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts index 65b0040eabe..0dbf568f356 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -63,7 +63,7 @@ describe('HttpPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts index f507b7f1f17..0c2da0c113c 100644 --- a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts index e742977e867..8d13bd9802a 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -72,7 +72,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index 74a247e909e..804711ed4bd 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -76,7 +76,7 @@ describe('HttpsPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr == null) { + if (addr === null || addr === undefined) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts index f75cf1e5663..3cd346953fc 100644 --- a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options != null + options !== null && options !== undefined ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index ea6ebce1823..f56bd01f169 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -89,7 +89,8 @@ export class Span implements api.Span, ReadableSpan { setAttribute(key: string, value?: SpanAttributeValue): this; setAttribute(key: string, value: unknown): this { - if (value == null || this._isSpanEnded()) return this; + if (value === null || value === undefined || this._isSpanEnded()) + return this; if (key.length === 0) { api.diag.warn(`Invalid attribute key: ${key}`); return this; From b9f35388e7d14518c8788d36f2223abf9a5b3941 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Tue, 2 Mar 2021 17:36:26 +0100 Subject: [PATCH 3/3] Revert "chore: more strict eqeqeq" This reverts commit 31f88c3d3e4860843614c12a69dc9c1c6f52e0c7. --- eslint.config.js | 4 ++++ .../src/AsyncLocalStorageContextManager.ts | 3 +-- packages/opentelemetry-core/src/common/attributes.ts | 6 +++--- packages/opentelemetry-core/src/utils/environment.ts | 2 +- packages/opentelemetry-instrumentation-fetch/src/fetch.ts | 2 +- .../test/integrations/http-enable.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../test/utils/httpRequest.ts | 2 +- .../test/utils/httpsRequest.ts | 2 +- .../test/functionals/http-package.test.ts | 2 +- .../test/integrations/http-enable.test.ts | 2 +- .../opentelemetry-plugin-http/test/utils/httpRequest.ts | 2 +- .../test/functionals/https-package.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../opentelemetry-plugin-https/test/utils/httpsRequest.ts | 2 +- packages/opentelemetry-tracing/src/Span.ts | 3 +-- 16 files changed, 21 insertions(+), 19 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 5eb52ccf048..41a00792995 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -12,6 +12,10 @@ module.exports = { }, rules: { "@typescript-eslint/no-this-alias": "off", + "eqeqeq": [ + "error", + "smart" + ], "prefer-rest-params": "off", "@typescript-eslint/naming-convention": [ "error", diff --git a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts index a1f4df09c10..0af8695911b 100644 --- a/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AsyncLocalStorageContextManager.ts @@ -36,8 +36,7 @@ export class AsyncLocalStorageContextManager extends AbstractAsyncHooksContextMa thisArg?: ThisParameterType, ...args: A ): ReturnType { - const cb = - thisArg === null || thisArg === undefined ? fn : fn.bind(thisArg); + const cb = thisArg == null ? fn : fn.bind(thisArg); return this._asyncLocalStorage.run(context, cb as never, ...args); } diff --git a/packages/opentelemetry-core/src/common/attributes.ts b/packages/opentelemetry-core/src/common/attributes.ts index ae887437852..df6b8f7a57f 100644 --- a/packages/opentelemetry-core/src/common/attributes.ts +++ b/packages/opentelemetry-core/src/common/attributes.ts @@ -18,7 +18,7 @@ import { SpanAttributeValue, SpanAttributes } from '@opentelemetry/api'; export function sanitizeAttributes(attributes: unknown): SpanAttributes { const out: SpanAttributes = {}; - if (attributes === null || typeof attributes !== 'object') { + if (attributes == null || typeof attributes !== 'object') { return out; } @@ -36,7 +36,7 @@ export function sanitizeAttributes(attributes: unknown): SpanAttributes { } export function isAttributeValue(val: unknown): val is SpanAttributeValue { - if (val === null || val === undefined) { + if (val == null) { return true; } @@ -52,7 +52,7 @@ function isHomogeneousAttributeValueArray(arr: unknown[]): boolean { for (const element of arr) { // null/undefined elements are allowed - if (element === null || element === undefined) continue; + if (element == null) continue; if (!type) { if (isValidPrimitiveAttributeValue(element)) { diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 2fd5ccc2370..c353a386731 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -173,7 +173,7 @@ function setLogLevelFromEnv( const value = values[key]; if (typeof value === 'string') { const theLevel = logLevelMap[value.toUpperCase()]; - if (typeof theLevel === 'number') { + if (theLevel != null) { environment[key] = theLevel; } } diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 6b6bb2961dd..5aa369d82b9 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -112,7 +112,7 @@ export class FetchInstrumentation extends InstrumentationBase< ): void { const parsedUrl = web.parseUrl(response.url); span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, response.status); - if (typeof response.statusText === 'string') { + if (response.statusText != null) { span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, response.statusText); } span.setAttribute(HttpAttribute.HTTP_HOST, parsedUrl.host); diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index 7c0346fb8ea..9995cd985c9 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -68,7 +68,7 @@ describe('HttpInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index 8894ecdcff3..7df9f3e771b 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -80,7 +80,7 @@ describe('HttpsInstrumentation Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts index 0c2da0c113c..f507b7f1f17 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options !== null && options !== undefined + options != null ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts index 3cd346953fc..f75cf1e5663 100644 --- a/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-instrumentation-http/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options !== null && options !== undefined + options != null ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts index 748eb9ebf0a..be05279d9a4 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -58,7 +58,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts index 0dbf568f356..65b0040eabe 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -63,7 +63,7 @@ describe('HttpPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts index 0c2da0c113c..f507b7f1f17 100644 --- a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts @@ -53,7 +53,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options !== null && options !== undefined + options != null ? http.get(input, options, onGetResponseCb) : http.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts index 8d13bd9802a..e742977e867 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -72,7 +72,7 @@ describe('Packages', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index 804711ed4bd..74a247e909e 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -76,7 +76,7 @@ describe('HttpsPlugin Integration tests', () => { mockServer.listen(0, () => { const addr = mockServer.address(); - if (addr === null || addr === undefined) { + if (addr == null) { done(new Error('unexpected addr null')); return; } diff --git a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts index 3cd346953fc..f75cf1e5663 100644 --- a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts @@ -57,7 +57,7 @@ function get(input: any, options?: any): GetResult { }); } req = - options !== null && options !== undefined + options != null ? https.get(input, options, onGetResponseCb) : https.get(input, onGetResponseCb); req.on('error', err => { diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index f56bd01f169..ea6ebce1823 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -89,8 +89,7 @@ export class Span implements api.Span, ReadableSpan { setAttribute(key: string, value?: SpanAttributeValue): this; setAttribute(key: string, value: unknown): this { - if (value === null || value === undefined || this._isSpanEnded()) - return this; + if (value == null || this._isSpanEnded()) return this; if (key.length === 0) { api.diag.warn(`Invalid attribute key: ${key}`); return this;