Skip to content

Commit 59a191d

Browse files
chore(parameters): fix SonarQube code quality issues and optimize imports (#4359)
1 parent ce4601e commit 59a191d

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

packages/parameters/src/appconfig/AppConfigProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ class AppConfigProvider extends BaseProvider {
189189
{ value: string; expiration: number }
190190
>();
191191
protected valueStore = new Map<string, Uint8Array>();
192-
private application?: string;
193-
private environment: string;
192+
private readonly application?: string;
193+
private readonly environment: string;
194194

195195
/**
196196
* It initializes the AppConfigProvider class.

packages/parameters/src/base/BaseProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ abstract class BaseProvider implements BaseProviderInterface {
9292
public async get(
9393
name: string,
9494
options?: GetOptionsInterface
95-
): Promise<unknown | undefined> {
95+
): Promise<unknown> {
9696
const configs = new GetOptions(options);
9797
const key = [name, configs.transform].toString();
9898

packages/parameters/src/dynamodb/DynamoDBProvider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
2-
import type {
3-
GetItemCommandInput,
4-
QueryCommandInput,
5-
} from '@aws-sdk/client-dynamodb';
62
import {
73
DynamoDBClient,
84
type DynamoDBPaginationConfiguration,
95
GetItemCommand,
6+
type GetItemCommandInput,
107
paginateQuery,
8+
type QueryCommandInput,
119
} from '@aws-sdk/client-dynamodb';
1210
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
1311
import { BaseProvider } from '../base/BaseProvider.js';

packages/parameters/src/ssm/SSMProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ class SSMProvider extends BaseProvider {
821821
* @param {boolean} throwOnError - Whether to throw an error if any of the parameters' retrieval throws an error or handle them gracefully
822822
*/
823823
protected static handleAnyInvalidGetParameterErrors(
824-
result: GetParametersCommandOutput,
824+
result: Partial<GetParametersCommandOutput>,
825825
throwOnError: boolean
826826
): string[] {
827827
const errors: string[] = [];
@@ -920,7 +920,7 @@ class SSMProvider extends BaseProvider {
920920
* @param {boolean} throwOnError - Whether to throw an error if any of the parameters' retrieval throws an error or handle them gracefully
921921
*/
922922
protected transformAndCacheGetParametersResponse(
923-
response: GetParametersCommandOutput,
923+
response: Partial<GetParametersCommandOutput>,
924924
parameters: Record<string, SSMGetParametersByNameOptions>,
925925
throwOnError: boolean
926926
): Record<string, unknown> {

packages/parameters/tests/helpers/tinyLogger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Console } from 'node:console';
1313
* the function code is working as expected.
1414
*/
1515
export class TinyLogger {
16-
private console = new Console({
16+
private readonly console: Console = new Console({
1717
stdout: process.stdout,
1818
stderr: process.stderr,
1919
});

packages/parameters/tests/unit/BaseProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestProvider extends BaseProvider {
2424
public constructor() {
2525
super({
2626
awsSdkV3ClientPrototype: class {
27-
#name = 'TestProvider';
27+
readonly #name: string = 'TestProvider';
2828

2929
public hello(): string {
3030
return this.#name;
@@ -412,7 +412,7 @@ describe('Class: BaseProvider', () => {
412412
// Act & Assess
413413
await expect(
414414
provider.getMultiple('my-path', {
415-
// @ts-ignore - we want to test an unexpected runtime error
415+
// @ts-expect-error - we want to test an unexpected runtime error
416416
transform: 1,
417417
throwOnTransformError: true,
418418
})

packages/parameters/tests/unit/SSMProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ describe('Class: SSMProvider', () => {
10121012
throwOnError: boolean
10131013
): string[] {
10141014
return SSMProvider.handleAnyInvalidGetParameterErrors(
1015-
result as GetParametersCommandOutput,
1015+
result,
10161016
throwOnError
10171017
);
10181018
}
@@ -1232,7 +1232,7 @@ describe('Class: SSMProvider', () => {
12321232
throwOnError: boolean
12331233
): Record<string, unknown> {
12341234
return super.transformAndCacheGetParametersResponse(
1235-
response as GetParametersCommandOutput,
1235+
response,
12361236
parameters,
12371237
throwOnError
12381238
);

0 commit comments

Comments
 (0)