Skip to content

Commit 85addea

Browse files
author
Michael Brewer
committed
chore(all): fix doc typos and apply basic lint recommendations
- Simplify comparisons - Fix gramma or spelling on doc strings - Fix doc string typos
1 parent 697a775 commit 85addea

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

packages/logger/src/Logger.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import cloneDeep from 'lodash.clonedeep';
55
import merge from 'lodash.merge';
66
import { ConfigServiceInterface, EnvironmentVariablesService } from './config';
77
import type {
8+
ClassThatLogs,
89
Environment,
910
HandlerMethodDecorator,
1011
LambdaFunctionContext,
1112
LogAttributes,
12-
ClassThatLogs,
1313
LoggerOptions,
1414
LogItemExtraInput,
1515
LogItemMessage,
@@ -90,7 +90,7 @@ class Logger implements ClassThatLogs {
9090
}
9191

9292
public static evaluateColdStartOnce(): void {
93-
if (Logger.getColdStartEvaluatedValue() === false) {
93+
if (!Logger.getColdStartEvaluatedValue()) {
9494
Logger.evaluateColdStart();
9595
}
9696
}
@@ -117,9 +117,8 @@ class Logger implements ClassThatLogs {
117117

118118
descriptor.value = (event, context, callback) => {
119119
this.addContext(context);
120-
const result = originalMethod?.apply(this, [ event, context, callback ]);
121120

122-
return result;
121+
return originalMethod?.apply(this, [ event, context, callback ]);
123122
};
124123
};
125124
}
@@ -181,7 +180,7 @@ class Logger implements ClassThatLogs {
181180
const coldStartValue = Logger.getColdStartValue();
182181
if (typeof coldStartValue === 'undefined') {
183182
Logger.setColdStartValue(true);
184-
} else if (coldStartValue === true) {
183+
} else if (coldStartValue) {
185184
Logger.setColdStartValue(false);
186185
} else {
187186
Logger.setColdStartValue(false);

packages/logger/src/log/LogItemInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LogAttributes } from '../types/Log';
1+
import { LogAttributes } from '../types';
22

33
interface LogItemInterface {
44

packages/logger/src/types/formats/PowertoolLog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type PowertoolLog = LogAttributes & {
3737
/**
3838
* message
3939
*
40-
* Description: Log statement value. Unserializable JSON values will be casted to string.
40+
* Description: Log statement value. Unserializable JSON values will be cast to string.
4141
* Example: "Collecting payment"
4242
*/
4343
message?: string

packages/tracing/src/Tracer.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ class Tracer implements TracerInterface {
140140
* @param error - Error to serialize as metadata
141141
*/
142142
public addErrorAsMetadata(error: Error): void {
143-
if (this.tracingEnabled === false) {
143+
if (!this.tracingEnabled) {
144144
return;
145145
}
146146

147147
const subsegment = this.getSegment();
148-
if (this.captureError === false) {
148+
if (!this.captureError) {
149149
subsegment.addErrorFlag();
150150

151151
return;
@@ -163,7 +163,7 @@ class Tracer implements TracerInterface {
163163
* @param methodName - Name of the method that is being traced
164164
*/
165165
public addResponseAsMetadata(data?: unknown, methodName?: string): void {
166-
if (data === undefined || this.captureResponse === false || this.tracingEnabled === false) {
166+
if (data === undefined || !this.captureResponse || !this.tracingEnabled) {
167167
return;
168168
}
169169

@@ -175,7 +175,7 @@ class Tracer implements TracerInterface {
175175
*
176176
*/
177177
public addServiceNameAnnotation(): void {
178-
if (this.tracingEnabled === false || this.serviceName === undefined) {
178+
if (!this.tracingEnabled || this.serviceName === undefined) {
179179
return;
180180
}
181181
this.putAnnotation('Service', this.serviceName);
@@ -184,17 +184,17 @@ class Tracer implements TracerInterface {
184184
/**
185185
* Add ColdStart annotation to the current segment or subsegment.
186186
*
187-
* If Tracer has been initialized outside of the Lambda handler then the same instance
188-
* of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
187+
* If Tracer has been initialized outside the Lambda handler then the same instance
188+
* of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
189189
* and this method will annotate `ColdStart: false` after the first invocation.
190190
*
191191
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
192192
*/
193193
public annotateColdStart(): void {
194-
if (this.tracingEnabled === true) {
194+
if (this.tracingEnabled) {
195195
this.putAnnotation('ColdStart', Tracer.coldStart);
196196
}
197-
if (Tracer.coldStart === true) {
197+
if (Tracer.coldStart) {
198198
Tracer.coldStart = false;
199199
}
200200
}
@@ -222,7 +222,7 @@ class Tracer implements TracerInterface {
222222
* @returns AWS - Instrumented AWS SDK
223223
*/
224224
public captureAWS<T>(aws: T): T {
225-
if (this.tracingEnabled === false) return aws;
225+
if (!this.tracingEnabled) return aws;
226226

227227
return this.provider.captureAWS(aws);
228228
}
@@ -251,7 +251,7 @@ class Tracer implements TracerInterface {
251251
* @returns service - Instrumented AWS SDK v2 client
252252
*/
253253
public captureAWSClient<T>(service: T): T {
254-
if (this.tracingEnabled === false) return service;
254+
if (!this.tracingEnabled) return service;
255255

256256
return this.provider.captureAWSClient(service);
257257
}
@@ -281,7 +281,7 @@ class Tracer implements TracerInterface {
281281
* @returns service - Instrumented AWS SDK v3 client
282282
*/
283283
public captureAWSv3Client<T>(service: T): T {
284-
if (this.tracingEnabled === false) return service;
284+
if (!this.tracingEnabled) return service;
285285

286286
return this.provider.captureAWSv3Client(service);
287287
}
@@ -322,7 +322,7 @@ class Tracer implements TracerInterface {
322322
const originalMethod = descriptor.value;
323323

324324
descriptor.value = ((event, context, callback) => {
325-
if (this.tracingEnabled === false) {
325+
if (!this.tracingEnabled) {
326326
return originalMethod?.apply(target, [ event, context, callback ]);
327327
}
328328

@@ -389,7 +389,7 @@ class Tracer implements TracerInterface {
389389
const originalMethod = descriptor.value;
390390

391391
descriptor.value = (...args: unknown[]) => {
392-
if (this.tracingEnabled === false) {
392+
if (!this.tracingEnabled) {
393393
return originalMethod?.apply(target, [...args]);
394394
}
395395

@@ -417,16 +417,16 @@ class Tracer implements TracerInterface {
417417
/**
418418
* Retrieve the current value of `ColdStart`.
419419
*
420-
* If Tracer has been initialized outside of the Lambda handler then the same instance
421-
* of Tracer will be reused throghout the lifecycle of that same Lambda execution environment
420+
* If Tracer has been initialized outside the Lambda handler then the same instance
421+
* of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
422422
* and this method will return `false` after the first invocation.
423423
*
424424
* @see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
425425
*
426426
* @returns boolean - `true` if is cold start, otherwise `false`
427427
*/
428428
public static getColdStart(): boolean {
429-
if (Tracer.coldStart === true) {
429+
if (Tracer.coldStart) {
430430
Tracer.coldStart = false;
431431

432432
return true;
@@ -498,7 +498,7 @@ class Tracer implements TracerInterface {
498498
* @param value - Value for annotation
499499
*/
500500
public putAnnotation(key: string, value: string | number | boolean): void {
501-
if (this.tracingEnabled === false) return;
501+
if (!this.tracingEnabled) return;
502502

503503
const document = this.getSegment();
504504
if (document instanceof Segment) {
@@ -528,10 +528,10 @@ class Tracer implements TracerInterface {
528528
*
529529
* @param key - Metadata key
530530
* @param value - Value for metadata
531-
* @param timestamp - Namespace that metadata will lie under, if none is passed it will use the serviceName
531+
* @param namespace - Namespace that metadata will lie under, if none is passed it will use the serviceName
532532
*/
533533
public putMetadata(key: string, value: unknown, namespace?: string | undefined): void {
534-
if (this.tracingEnabled === false) return;
534+
if (!this.tracingEnabled) return;
535535

536536
const document = this.getSegment();
537537
if (document instanceof Segment) {
@@ -608,7 +608,7 @@ class Tracer implements TracerInterface {
608608
*
609609
* @param serviceName - Service name to validate
610610
*/
611-
private isValidServiceName(serviceName?: string): boolean {
611+
private static isValidServiceName(serviceName?: string): boolean {
612612
return typeof serviceName === 'string' && serviceName.trim().length > 0;
613613
}
614614

@@ -700,21 +700,21 @@ class Tracer implements TracerInterface {
700700
* @param serviceName - Name of the service to use
701701
*/
702702
private setServiceName(serviceName?: string): void {
703-
if (serviceName !== undefined && this.isValidServiceName(serviceName)) {
703+
if (serviceName !== undefined && Tracer.isValidServiceName(serviceName)) {
704704
this.serviceName = serviceName;
705705

706706
return;
707707
}
708708

709709
const customConfigValue = this.getCustomConfigService()?.getServiceName();
710-
if (customConfigValue !== undefined && this.isValidServiceName(customConfigValue)) {
710+
if (customConfigValue !== undefined && Tracer.isValidServiceName(customConfigValue)) {
711711
this.serviceName = customConfigValue;
712712

713713
return;
714714
}
715715

716716
const envVarsValue = this.getEnvVarsService()?.getServiceName();
717-
if (envVarsValue !== undefined && this.isValidServiceName(envVarsValue)) {
717+
if (envVarsValue !== undefined && Tracer.isValidServiceName(envVarsValue)) {
718718
this.serviceName = envVarsValue;
719719

720720
return;
@@ -728,7 +728,7 @@ class Tracer implements TracerInterface {
728728
* @param enabled - Whether or not tracing is enabled
729729
*/
730730
private setTracingEnabled(enabled?: boolean): void {
731-
if (enabled !== undefined && enabled === false) {
731+
if (enabled !== undefined && !enabled) {
732732
this.tracingEnabled = enabled;
733733

734734
return;
@@ -748,7 +748,7 @@ class Tracer implements TracerInterface {
748748
return;
749749
}
750750

751-
if (this.isLambdaSamCli() || this.isLambdaExecutionEnv() === false) {
751+
if (this.isLambdaSamCli() || !this.isLambdaExecutionEnv()) {
752752
this.tracingEnabled = false;
753753
}
754754
}

packages/tracing/src/middleware/middy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Segment, Subsegment } from 'aws-xray-sdk-core';
2323
* }).use(captureLambdaHandler(tracer));
2424
* ```
2525
*
26-
* @param tracer - The Tracer instance to use for tracing
26+
* @param target - The Tracer instance to use for tracing
2727
* @returns middleware object - The middy middleware object
2828
*/
2929
const captureLambdaHandler = (target: Tracer): middy.MiddlewareObj => {

0 commit comments

Comments
 (0)