Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ process_files() {
# Read the content of the found local.settings.json file and echo it into the target file
cat "$file" >> $OUTPUT_SCRIPT
# Check if this is the last file and add EOF accordingly
if [ $index -lt $file_count ]; then
if [[ $index -lt $file_count ]]; then
echo -e "\nEOF" >> $OUTPUT_SCRIPT
fi
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function GET(request: Request) {
const isReport = searchParams.get("isReport");
const exceptionCategory = searchParams.get("exceptionCategory");
const reportDate = searchParams.get("reportDate");
const page = Math.max(1, parseInt(searchParams.get("page") || "1", 10));
const page = Math.max(1, Number.parseInt(searchParams.get("page") || "1", 10));

// Handle single exception requests - get fresh data from store
if (exceptionId !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export async function PUT(request: NextRequest) {
);
}

const exceptionId = parseInt(updateRequest.ExceptionId, 10);
if (isNaN(exceptionId) || exceptionId === 0) {
const exceptionId = Number.parseInt(updateRequest.ExceptionId, 10);
if (Number.isNaN(exceptionId) || exceptionId === 0) {
console.warn("Invalid ExceptionId provided:", updateRequest.ExceptionId);
return NextResponse.json(
{ error: "Invalid ExceptionId provided" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function PUT(request: NextRequest) {
const exceptionId =
typeof rawExceptionId === "number"
? rawExceptionId
: parseInt(rawExceptionId, 10);
: Number.parseInt(rawExceptionId, 10);
if (!Number.isFinite(exceptionId) || exceptionId <= 0) {
console.warn("Invalid ExceptionId provided:", rawExceptionId);
return NextResponse.json(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function Page({
const sortBy = resolvedSearchParams.sortBy === "0" ? 0 : 1;
const currentPage = Math.max(
1,
parseInt(resolvedSearchParams.page || "1", 10)
Number.parseInt(resolvedSearchParams.page || "1", 10)
);

const sortOptions = [
Expand Down
2 changes: 1 addition & 1 deletion application/CohortManager/src/Web/app/exceptions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default async function Page({
const sortBy = resolvedSearchParams.sortBy === "0" ? 0 : 1;
const currentPage = Math.max(
1,
parseInt(resolvedSearchParams.page || "1", 10)
Number.parseInt(resolvedSearchParams.page || "1", 10)
);

const sortOptions = [
Expand Down
4 changes: 2 additions & 2 deletions application/CohortManager/src/Web/app/lib/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ export function extractPageFromUrl(url: string): number {
try {
const parsed = new URL(url);
const value = parsed.searchParams.get(PAGE_PARAM);
const page = value ? parseInt(value, 10) : 1;
const page = value ? Number.parseInt(value, 10) : 1;
return Number.isNaN(page) ? 1 : Math.max(1, page);
} catch {
const pageRegex = new RegExp(`[?&]${PAGE_PARAM}=(\\d+)`);
const match = pageRegex.exec(url);
const page = match ? parseInt(match[1], 10) : 1;
const page = match ? Number.parseInt(match[1], 10) : 1;
return Number.isNaN(page) ? 1 : Math.max(1, page);
}
}
Expand Down
4 changes: 2 additions & 2 deletions application/CohortManager/src/Web/app/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const formatCompactDate = (dateString: string): string => {
if (!dateString) return "";

const date = new Date(dateString);
if (isNaN(date.getTime())) return "";
if (Number.isNaN(date.getTime())) return "";

const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
Expand All @@ -37,7 +37,7 @@ export function getCurrentDate(): string {

export function formatGenderValue(gender?: number | string | null): string {
if (gender === null || gender === undefined || gender === "") return "";
const genderNum = typeof gender === "string" ? parseInt(gender, 10) : gender;
const genderNum = typeof gender === "string" ? Number.parseInt(gender, 10) : gender;
if (genderNum === 1) return "Male";
if (genderNum === 2) return "Female";
if (genderNum === 9) return "Unspecified";
Expand Down
14 changes: 7 additions & 7 deletions scripts/azure/GetImageTagsByManifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ while [[ "$#" -gt 0 ]]; do
shift
done

if [ -z "${containerRegistry}" ]; then
if [[ -z "${containerRegistry}" ]]; then
echo "Please provide a container registry argument"
exit 1
fi

# stop processing if no image name is provided
if [ -z "${functionAppName}" ]; then
if [[ -z "${functionAppName}" ]]; then
echo "Please provide an image name as an argument"
exit 1
fi

if [ -z "${subscriptionId}" ]; then
if [[ -z "${subscriptionId}" ]]; then
echo "Please provide a Subscription ID argument"
exit 1
fi

if [ -z "${resourceGroup}" ]; then
if [[ -z "${resourceGroup}" ]]; then
echo "Please provide a resource group argument"
exit 1
fi

if [ verbose == true ]; then
if [[ verbose == true ]]; then
echo "function app name: $functionAppName"
echo "subscription Id: $subscriptionId"
echo "resourceGroup: $resourceGroup"
Expand All @@ -88,13 +88,13 @@ fi
digest=$(az acr repository show --name $containerRegistry --image $functionAppName:$tag --query 'digest' --output tsv 2> /dev/null)

# stop processing if the image does not exist
if [ -z "$digest" ]; then
if [[ -z "$digest" ]]; then
echo "Image $image not found in $containerRegistry"
exit 1
fi

# echo the digest
if [ verbose == true ]; then
if [[ verbose == true ]]; then
echo $digest
fi

Expand Down
4 changes: 2 additions & 2 deletions scripts/deployment/get-docker-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ IFS=$', \n'

echo "Adding Docker compose file includes..."
files_to_process=(${COMPOSE_FILES_CSV})
while [ ${#files_to_process[@]} -gt 0 ]; do
while [[ ${#files_to_process[@]} -gt 0 ]]; do
compose_file="${files_to_process[0]}"
files_to_process=("${files_to_process[@]:1}") # Remove the first file from the list
includes=($(yq -r '.include[]' "${compose_file}"))
Expand Down Expand Up @@ -121,7 +121,7 @@ for compose_file in ${COMPOSE_FILES_CSV}; do
echo
done

if [ ${#non_matched_changes[@]} -ne 0 ]; then
if [[ ${#non_matched_changes[@]} -ne 0 ]]; then
# Remove duplicates (non-matched items across several compose files)
mapfile -t unique_changes < <(printf "%s\n" "${non_matched_changes[@]}" | sort -u)

Expand Down
6 changes: 3 additions & 3 deletions scripts/docker/dgoss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error() {
cleanup() {
set +e
{ kill "$log_pid" && wait "$log_pid"; } 2> /dev/null
if [ -n "$CONTAINER_LOG_OUTPUT" ]; then
if [[ -n "$CONTAINER_LOG_OUTPUT" ]]; then
cp "$tmp_dir/docker_output.log" "$CONTAINER_LOG_OUTPUT"
fi
rm -rf "$tmp_dir"
Expand All @@ -47,7 +47,7 @@ run(){
case "$GOSS_FILES_STRATEGY" in
mount)
info "Starting $CONTAINER_RUNTIME container"
if [ "$CONTAINER_RUNTIME" == "podman" -a $# == 2 ]; then
if [[ "$CONTAINER_RUNTIME" == "podman" -a $# == 2 ]]; then
id=$($CONTAINER_RUNTIME run -d -v "$tmp_dir:/goss:z" "${@:2}" sleep infinity)
else
id=$($CONTAINER_RUNTIME run -d -v "$tmp_dir:/goss:z" "${@:2}")
Expand Down Expand Up @@ -113,7 +113,7 @@ case "$1" in
fi
[[ $GOSS_SLEEP ]] && { info "Sleeping for $GOSS_SLEEP"; sleep "$GOSS_SLEEP"; }
info "Container health"
if [ "true" != "$($CONTAINER_RUNTIME inspect -f '{{.State.Running}}' "$id")" ]; then
if [[ "true" != "$($CONTAINER_RUNTIME inspect -f '{{.State.Running}}' "$id")" ]]; then
$CONTAINER_RUNTIME logs "$id" >&2
error "the container failed to start"
fi
Expand Down
18 changes: 9 additions & 9 deletions scripts/docker/docker.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function version-create-effective-file() {
local version_file="$dir/VERSION"
local build_datetime=${BUILD_DATETIME:-$(date -u +'%Y-%m-%dT%H:%M:%S%z')}

if [ -f "$version_file" ]; then
if [[ -f "$version_file" ]]; then
# shellcheck disable=SC2002
cat "$version_file" | \
sed "s/\(\${yyyy}\|\$yyyy\)/$(date --date="${build_datetime}" -u +"%Y")/g" | \
Expand Down Expand Up @@ -167,9 +167,9 @@ function docker-get-image-version-and-pull() {
# match it by name and version regex, if given.
local versions_file="${TOOL_VERSIONS:=$(git rev-parse --show-toplevel)/.tool-versions}"
local version="latest"
if [ -f "$versions_file" ]; then
if [[ -f "$versions_file" ]]; then
line=$(grep "docker/${name} " "$versions_file" | sed "s/^#\s*//; s/\s*#.*$//" | grep "${match_version:-".*"}")
[ -n "$line" ] && version=$(echo "$line" | awk '{print $2}')
[[ -n "$line" ]] && version=$(echo "$line" | awk '{print $2}')
fi

# Split the image version into two, tag name and digest sha256.
Expand All @@ -178,7 +178,7 @@ function docker-get-image-version-and-pull() {

# Check if the image exists locally already
if ! docker images | awk '{ print $1 ":" $2 }' | grep -q "^${name}:${tag}$"; then
if [ "$digest" != "latest" ]; then
if [[ "$digest" != "latest" ]]; then
# Pull image by the digest sha256 and tag it
docker pull \
--platform linux/amd64 \
Expand Down Expand Up @@ -222,19 +222,19 @@ function _replace-image-latest-by-specific-version() {
local dockerfile="${dir}/Dockerfile.effective"
local build_datetime=${BUILD_DATETIME:-$(date -u +'%Y-%m-%dT%H:%M:%S%z')}

if [ -f "$versions_file" ]; then
if [[ -f "$versions_file" ]]; then
# First, list the entries specific for Docker to take precedence, then the rest but exclude comments
content=$(grep " docker/" "$versions_file"; grep -v " docker/" "$versions_file" ||: | grep -v "^#")
echo "$content" | while IFS= read -r line; do
[ -z "$line" ] && continue
[[ -z "$line" ]] && continue
line=$(echo "$line" | sed "s/^#\s*//; s/\s*#.*$//" | sed "s;docker/;;")
name=$(echo "$line" | awk '{print $1}')
version=$(echo "$line" | awk '{print $2}')
sed -i "s;\(FROM .*\)${name}:latest;\1${name}:${version};g" "$dockerfile"
done
fi

if [ -f "$dockerfile" ]; then
if [[ -f "$dockerfile" ]]; then
# shellcheck disable=SC2002
cat "$dockerfile" | \
sed "s/\(\${yyyy}\|\$yyyy\)/$(date --date="${build_datetime}" -u +"%Y")/g" | \
Expand Down Expand Up @@ -292,9 +292,9 @@ function _get-git-branch-name() {

local branch_name=$(git rev-parse --abbrev-ref HEAD)

if [ -n "${GITHUB_HEAD_REF:-}" ]; then
if [[ -n "${GITHUB_HEAD_REF:-}" ]]; then
branch_name=$GITHUB_HEAD_REF
elif [ -n "${GITHUB_REF:-}" ]; then
elif [[ -n "${GITHUB_REF:-}" ]]; then
# shellcheck disable=SC2001
branch_name=$(echo "$GITHUB_REF" | sed "s#refs/heads/##")
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/tests/docker.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function main() {
done
echo "Total: ${#tests[@]}, Passed: $(( ${#tests[@]} - status )), Failed: $status"
test-docker-suite-teardown
[ $status -gt 0 ] && return 1 || return 0
[[ $status -gt 0 ]] && return 1 || return 0
}

# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/check-markdown-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function main() {
;;
esac

if [ -n "$files" ]; then
if [[ -n "$files" ]]; then
if command -v markdownlint > /dev/null 2>&1 && ! is-arg-true "${FORCE_USE_DOCKER:-false}"; then
files="$files" run-markdownlint-natively
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/githooks/scan-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function get-cmd-to-run() {
;;
esac
# Include base line file if it exists
if [ -f "$dir/scripts/config/.gitleaks-baseline.json" ]; then
if [[ -f "$dir/scripts/config/.gitleaks-baseline.json" ]]; then
cmd="$cmd --baseline-path $dir/scripts/config/.gitleaks-baseline.json"
fi
# Include the config file
Expand Down
6 changes: 3 additions & 3 deletions scripts/podman/amd64-build-from-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ check_tools() {
return 0
fi

if [ ${#missing_tools[@]} -ne 0 ]; then
if [[ ${#missing_tools[@]} -ne 0 ]]; then
echo "Error: Missing required tools: ${missing_tools[*]}" >&2
echo "Please install the missing tools and try again." >&2
exit 1
Expand Down Expand Up @@ -70,7 +70,7 @@ parse_services() {
}

# Validate arguments
if [ $# -eq 0 ]; then
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <compose-file1> [compose-file2] ..." >&2
exit 1
fi
Expand Down Expand Up @@ -122,7 +122,7 @@ for compose_file in "$@"; do
done

# Check if the while loop failed (due to pipe)
if [ ${PIPESTATUS[1]} -ne 0 ]; then
if [[ ${PIPESTATUS[1]} -ne 0 ]]; then
echo "Error: Build failed for $compose_file" >&2
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/reports/create-sbom-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function create-report() {
function run-syft-natively() {


if [ -z "$CHECK_DOCKER_IMAGE" ]; then
if [[ -z "$CHECK_DOCKER_IMAGE" ]]; then
syft scan docker:$CHECK_DOCKER_IMAGE \
--config "$PWD/scripts/config/syft.yaml" \
--output spdx-json="$PWD/$SBOM_REPOSITORY_REPORT.tmp.json"
Expand All @@ -68,7 +68,7 @@ function run-syft-in-docker() {
# shellcheck disable=SC2155
local image=$(name=ghcr.io/anchore/syft docker-get-image-version-and-pull)

if [ -z "$CHECK_DOCKER_IMAGE" ]; then
if [[ -z "$CHECK_DOCKER_IMAGE" ]]; then
docker run --rm --platform linux/amd64 \
--volume "$PWD":/workdir \
--volume /var/run/docker.sock:/var/run/docker.sock \
Expand Down
6 changes: 3 additions & 3 deletions scripts/reports/sonar-analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dotnet test "${UNIT_TEST_DIR}/ConsolidatedTests.csproj" \

# Run frontend tests to generate lcov coverage
echo "Running frontend tests to generate coverage"
if [ -d "application/CohortManager/src/Web" ]; then
if [[ -d "application/CohortManager/src/Web" ]]; then
(
cd application/CohortManager/src/Web || exit 1
# Configure npm to better handle transient 429s and avoid extra work
Expand All @@ -103,13 +103,13 @@ if [ -d "application/CohortManager/src/Web" ]; then
export npm_config_prefer_offline=true
# Retry npm ci with simple backoff to survive registry rate limits
n=0
until [ "$n" -ge 3 ]
until [[ "$n" -ge 3 ]]
do
npm ci && break
n=$((n+1))
sleep $((n*15))
done
if [ "$n" -ge 3 ]; then
if [[ "$n" -ge 3 ]]; then
echo "npm ci failed after retries" >&2
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/shellscript-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function main() {

cd "$(git rev-parse --show-toplevel)"

[ -z "${file:-}" ] && echo "WARNING: 'file' variable not set, defaulting to itself"
[[ -z "${file:-}" ]] && echo "WARNING: 'file' variable not set, defaulting to itself"
local file=${file:-scripts/shellscript-linter.sh}
if command -v shellcheck > /dev/null 2>&1 && ! is-arg-true "${FORCE_USE_DOCKER:-false}"; then
file="$file" run-shellcheck-natively
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright-tests/scripts/health-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ function parseArgs() {
if (skipNext) { skipNext = false; continue; }
const a = args[i];
if (a === '--max-attempts' && args[i + 1]) {
const parsed = parseInt(args[i + 1], 10);
if (isNaN(parsed) || parsed < 1) {
const parsed = Number.parseInt(args[i + 1], 10);
if (Number.isNaN(parsed) || parsed < 1) {
console.error('Error: --max-attempts must be a positive number');
process.exit(1);
}
maxAttempts = parsed;
skipNext = true;
} else if (a === '--interval' && args[i + 1]) {
const parsed = parseInt(args[i + 1], 10);
if (isNaN(parsed) || parsed < 100) {
const parsed = Number.parseInt(args[i + 1], 10);
if (Number.isNaN(parsed) || parsed < 100) {
console.error('Error: --interval must be at least 100ms');
process.exit(1);
}
Expand Down
Loading