#!/bin/bash
# Standalone Code Review - Using Roslyn Analyzers
# No external server required

set -e

GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'

echo -e "${GREEN}Starting Code Review (Standalone Mode)...${NC}\n"

# Clean and restore
echo -e "${YELLOW}Cleaning and restoring...${NC}"
dotnet clean > /dev/null
dotnet restore > /dev/null

# Build with full analysis
echo -e "${YELLOW}Running analysis...${NC}\n"
dotnet build \
  /p:TreatWarningsAsErrors=false \
  /p:WarningLevel=4 \
  /p:RunAnalyzers=true \
  /p:EnforceCodeStyleInBuild=true \
  /clp:Summary \
  --verbosity normal

echo -e "\n${GREEN}Code review complete!${NC}"
echo -e "${YELLOW}Review the warnings above for code quality issues.${NC}"

# Count warnings
echo -e "\n${YELLOW}Generating summary...${NC}"
dotnet build --no-incremental 2>&1 | grep -i "warning" | wc -l | xargs -I {} echo -e "${YELLOW}Total warnings found: {}${NC}"
