diff --git a/clients/client-js/sonar-project.properties b/clients/client-js/sonar-project.properties index 7b93e4f..c6a2e42 100644 --- a/clients/client-js/sonar-project.properties +++ b/clients/client-js/sonar-project.properties @@ -1,13 +1,6 @@ sonar.projectKey=bancolombia_async-dataflow-client-js sonar.organization=grupo-bancolombia sonar.projectName=async-dataflow-client-js -sonar.javascript.lcov.reportPaths=./coverage/lcov.info sonar.sources=src sonar.tests=test - - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 \ No newline at end of file +sonar.javascript.lcov.reportPaths=./coverage/lcov.info \ No newline at end of file diff --git a/clients/client-js/src/async-client.ts b/clients/client-js/src/async-client.ts index 7ce468a..e426875 100644 --- a/clients/client-js/src/async-client.ts +++ b/clients/client-js/src/async-client.ts @@ -5,12 +5,12 @@ import { ChannelMessage } from "./channel-message"; export class AsyncClient { private currentTransport: Transport; private currentTransportIndex: number = 0; - private bindings = []; - private cache: Cache = undefined; + private readonly bindings = []; + private readonly cache: Cache = undefined; private closeWasClean: boolean = false; private retriesByTransport = 0; - constructor(private config: AsyncConfig, private transports: Array | null, private mockTransport: any = null) { + constructor(private readonly config: AsyncConfig, private readonly transports: Array | null, private readonly mockTransport: any = null) { if (!config.dedupCacheDisable) { this.cache = new Cache(config.dedupCacheMaxSize, config.dedupCacheTtl); } diff --git a/clients/client-js/src/cache.ts b/clients/client-js/src/cache.ts index 633e6da..32afc3c 100644 --- a/clients/client-js/src/cache.ts +++ b/clients/client-js/src/cache.ts @@ -2,7 +2,7 @@ import { LRUCache } from 'lru-cache' export class Cache { - private cacheImpl: LRUCache; + private readonly cacheImpl: LRUCache; private static readonly MAX_SIZE = 100; private static readonly DEFAULT_MAX_ELEMENTS = 500; diff --git a/clients/client-js/src/decoder/binary-decoder.ts b/clients/client-js/src/decoder/binary-decoder.ts index 4ecc545..ac2ef42 100644 --- a/clients/client-js/src/decoder/binary-decoder.ts +++ b/clients/client-js/src/decoder/binary-decoder.ts @@ -6,7 +6,7 @@ import { MessageDecoder } from "./message-decoder"; export class BinaryDecoder implements MessageDecoder { - private textDecoder: TextDecoder; + private readonly textDecoder: TextDecoder; constructor() { this.textDecoder = new TextDecoder(); diff --git a/clients/client-js/src/retry-timer.ts b/clients/client-js/src/retry-timer.ts index 06a1803..94b9c7e 100644 --- a/clients/client-js/src/retry-timer.ts +++ b/clients/client-js/src/retry-timer.ts @@ -8,11 +8,11 @@ export class RetryTimer { private limitReachedNotified: boolean = false; constructor( - private callback: () => void, - private initial: number = 10, - private jitterFn: (x: number) => number, - private maxRetries: number = 10, - private limitReachedCallback: () => void = () => { }) { + private readonly callback: () => void, + private readonly initial: number = 10, + private readonly jitterFn: (x: number) => number, + private readonly maxRetries: number = 10, + private readonly limitReachedCallback: () => void = () => { }) { } public reset(): void { diff --git a/clients/client-js/src/transport/sse-transport.ts b/clients/client-js/src/transport/sse-transport.ts index 37ed765..5a62d22 100644 --- a/clients/client-js/src/transport/sse-transport.ts +++ b/clients/client-js/src/transport/sse-transport.ts @@ -10,7 +10,7 @@ export class SseTransport implements Transport { private actualToken; private eventSource: EventSourcePlus; - private serializer: MessageDecoder; + private readonly serializer: MessageDecoder; private errorCount = 0; private controller: EventSourceController; private tokenUpdated: boolean = false; @@ -25,9 +25,9 @@ export class SseTransport implements Transport { return new SseTransport(config, handleMessage, errorCallback, transport); } - private constructor(private config: AsyncConfig, - private handleMessage: (_message: ChannelMessage) => void, - private errorCallback: (_error: TransportError) => void, + private constructor(private readonly config: AsyncConfig, + private readonly handleMessage: (_message: ChannelMessage) => void, + private readonly errorCallback: (_error: TransportError) => void, private readonly transport: typeof EventSourcePlus) { this.serializer = new JsonDecoder(); this.actualToken = config.channel_secret; diff --git a/clients/client-js/src/transport/ws-transport.ts b/clients/client-js/src/transport/ws-transport.ts index 6557be7..a03c001 100644 --- a/clients/client-js/src/transport/ws-transport.ts +++ b/clients/client-js/src/transport/ws-transport.ts @@ -13,16 +13,16 @@ export class WsTransport implements Transport { private socket: WebSocket; public isOpen: boolean = false; public isActive: boolean = false; - private stateCallbacks = { open: [], close: [], error: [], message: [] } + private readonly stateCallbacks = { open: [], close: [], error: [], message: [] } private ref = 0; private pendingHeartbeatRef: string = null; private closeWasClean: boolean = false; private heartbeatTimer = null; private readonly heartbeatIntervalMs: number; private tearingDown: boolean = false; - private reconnectTimer: RetryTimer; + private readonly reconnectTimer: RetryTimer; private serializer: MessageDecoder; - private subProtocols: string[] = [Protocol.JSON] + private readonly subProtocols: string[] = [Protocol.JSON] private readonly HEARTBEAT_TIMEOUT = 3051; @@ -34,9 +34,9 @@ export class WsTransport implements Transport { return new WsTransport(config, handleMessage, errorCallback, transport); } - private constructor(private config: AsyncConfig, - private handleMessage: (_message: ChannelMessage) => void, - private errorCallback: (_error: TransportError) => void, + private constructor(private readonly config: AsyncConfig, + private readonly handleMessage: (_message: ChannelMessage) => void, + private readonly errorCallback: (_error: TransportError) => void, private readonly transport: any = null) { const intWindow = typeof window !== "undefined" ? window : null;