Skip to content
Merged
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
1 change: 1 addition & 0 deletions .cursor/mcp.json
8 changes: 8 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mcpServers": {
"sonarqube": {
"type": "http",
"url": "http://sonarqube.vtex.systems/mcp"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged && bash scripts/sonar-verify-staged.sh"
}
},
"lint-staged": {
Expand Down
22 changes: 22 additions & 0 deletions scripts/sonar-verify-staged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Sonar pre-commit gate for staged files (macOS/Linux).
#
# Runs a secrets-only scan (`sonar hook git-pre-commit`). The golden-path command
# `sonar analyze --staged` also triggers Agentic Analysis, which currently returns
# 403 for the VTEX org (feature not enabled yet), so it is kept commented out below.
# Code quality is still enforced by the full Sonar scan in CI.
set -euo pipefail

if command -v sonar >/dev/null 2>&1; then
SONAR_CMD="$(command -v sonar)"
elif [[ -x "${HOME}/.local/share/sonarqube-cli/bin/sonar" ]]; then
SONAR_CMD="${HOME}/.local/share/sonarqube-cli/bin/sonar"
else
echo "Sonar CLI not found. Install with:" >&2
echo " curl -o- https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.sh | bash" >&2
exit 1
fi

# Golden path (re-enable when Agentic Analysis is available for the org):
# exec "$SONAR_CMD" analyze --staged --project vtex_goldenpath
exec "$SONAR_CMD" hook git-pre-commit
Loading