From 717c456f08daae3212e48bc8f8e357d0719b4339 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Mon, 31 Jul 2023 16:31:30 -0400 Subject: [PATCH 1/2] [BUGFIX] [snyk]: Using the loop variable k Using the loop variable k [:19] from some outer or global scope in this for in loop [:19] may prevent optimisations by the JavaScript engine. Consider declaring the loop variable inside the head of this for in loop [:19]. --- src/hackerrank/implementation/sockMerchant.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hackerrank/implementation/sockMerchant.ts b/src/hackerrank/implementation/sockMerchant.ts index 0202a10..2d3b71d 100644 --- a/src/hackerrank/implementation/sockMerchant.ts +++ b/src/hackerrank/implementation/sockMerchant.ts @@ -15,8 +15,7 @@ export function sockMerchant(n: number, ar: number[]): number { console.debug(matches); - let k: keyof Matches; - for (k in matches) { + for (const k in matches) { console.debug(matches[k]); result += Math.floor(matches[k] / 2); From c13f0af60ea2ec6ca49bd75955db2ca79876cff6 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Mon, 31 Jul 2023 16:55:12 -0400 Subject: [PATCH 2/2] [BUGFIX] [Sonarcloud]: code smell fixed. --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 269485f..c502035 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM node:20.2.0-alpine3.16 as base +FROM node:20.2.0-alpine3.16 AS base RUN apk add --update --no-cache make ENV WORKDIR=/app WORKDIR ${WORKDIR} -FROM node:20.2.0-alpine3.16 as lint +FROM node:20.2.0-alpine3.16 AS lint ENV WORKDIR=/app WORKDIR ${WORKDIR} @@ -14,9 +14,9 @@ COPY ./src ${WORKDIR}/src RUN apk add --update --no-cache make RUN npm install -g markdownlint-cli -FROM base as development +FROM base AS development -FROM development as builder +FROM development AS builder COPY ./Makefile ${WORKDIR}/ COPY ./package.json ${WORKDIR}/package.json @@ -31,7 +31,7 @@ RUN npm ci --verbose ## ## https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions ## -FROM builder as testing +FROM builder AS testing ENV LOG_LEVEL=info ENV BRUTEFORCE=false @@ -50,7 +50,7 @@ CMD ["npm", "run", "test"] ## in the production phase, "good practices" such as ## WORKSPACE and USER are maintained ## -FROM builder as production +FROM builder AS production ENV LOG_LEVEL=info ENV BRUTEFORCE=false