#!/bin/bash
# SonarScanner Code Review Script
# Usage: ./code-review.sh

set -e

# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

echo -e "${GREEN}Starting SonarScanner Code Review...${NC}\n"

# Export dotnet tools to PATH
export PATH="$PATH:/Users/jean-philippe/.dotnet/tools"

# Clean previous build artifacts
echo -e "${YELLOW}Cleaning previous build...${NC}"
dotnet clean

# Begin SonarScanner analysis
echo -e "${YELLOW}Starting SonarScanner analysis...${NC}"
dotnet-sonarscanner begin \
  /k:"codex-adk-backend" \
  /n:"CODEX ADK Backend" \
  /v:"1.0.0" \
  /d:sonar.host.url="http://localhost:9000" \
  /o:"codex" \
  /d:sonar.verbose=false

# Build the solution
echo -e "${YELLOW}Building solution...${NC}"
dotnet build --no-incremental

# End SonarScanner analysis
echo -e "${YELLOW}Completing SonarScanner analysis...${NC}"
dotnet-sonarscanner end

echo -e "\n${GREEN}Code review complete!${NC}"
echo -e "${YELLOW}Note: For full SonarQube integration, install SonarQube server or use SonarCloud.${NC}"
echo -e "Visit: https://www.sonarsource.com/products/sonarqube/downloads/"
