chore: Update .gitignore to exclude SonarQube files and add Codacy and SonarScanner scripts

refactor: Remove WarmupPeriod logging from SMA and WMA examples
This commit is contained in:
Miha Kralj
2025-11-30 17:17:55 -08:00
parent 4dd753f7c0
commit 626a2afa9b
7 changed files with 109 additions and 10 deletions
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
set -euo pipefail
# Static Analysis Scanner for QuanTAlib
# Runs SonarCloud and Qodana with code coverage
# Tokens must be set as environment variables
if [[ -z "${SONAR_TOKEN:-}" ]]; then
echo "Error: SONAR_TOKEN environment variable not set"
exit 1
fi
if [[ -z "${QODANA_TOKEN:-}" ]]; then
echo "Error: QODANA_TOKEN environment variable not set"
exit 1
fi
# Coverage output directory for Qodana
COVERAGE_DIR=".qodana/code-coverage"
echo "==> Building solution..."
dotnet build --no-incremental
echo "==> Running tests with coverage..."
mkdir -p "$COVERAGE_DIR"
dotnet test --no-build --collect:"XPlat Code Coverage" \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=lcov
# Copy coverage to Qodana directory
find . -name "coverage.info" -exec cp {} "$COVERAGE_DIR/" \;
# Run SonarCloud
echo "==> Starting SonarScanner analysis..."
# Re-run tests with OpenCover format for SonarCloud
dotnet test --no-build --collect:"XPlat Code Coverage" \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
dotnet sonarscanner begin \
/o:"mihakralj-quantalib" \
/k:"mihakralj_QuanTAlib" \
/d:sonar.token="$SONAR_TOKEN" \
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
dotnet build --no-incremental
dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
echo "==> SonarCloud: https://sonarcloud.io/project/overview?id=mihakralj_QuanTAlib"
# Run Qodana
echo "==> Starting Qodana analysis..."
QODANA_TOKEN="$QODANA_TOKEN" qodana scan \
--coverage-dir "$COVERAGE_DIR"
echo "==> Qodana analysis complete"
echo "==> Done!"