Skip to content

Latest commit

Β 

History

History
318 lines (253 loc) Β· 5.97 KB

File metadata and controls

318 lines (253 loc) Β· 5.97 KB

🎯 Exercise Script: Code Quality (Windows)

Step-by-Step Guide for Students

πŸ“ Instructions: Execute each command in order, one by one. Wait for each command to complete before running the next one.


πŸ“‹ PHASE 1: SETUP

Step 1: Verify Installation

run.bat help

Or with PowerShell:

.\run.ps1 help

Step 2: Install Dependencies

run.bat install

Or with PowerShell:

.\run.ps1 install

Step 3: Check Project Structure

dir

Or with PowerShell:

Get-ChildItem

πŸ” PHASE 2: INITIAL ANALYSIS

Step 4: Record Initial Benchmark

run.bat benchmark-initial

Or with PowerShell:

.\run.ps1 benchmark-initial

Step 5: See Generated Files

dir *report*.txt issues_to_fix*.txt benchmark_results.json

Or with PowerShell:

Get-ChildItem *report*.txt, issues_to_fix*.txt, benchmark_results.json

Step 6: View Fixable Issues (MOST IMPORTANT)

type issues_to_fix_*.txt

Or with PowerShell:

Get-Content issues_to_fix_*.txt

Step 7: View Benchmark Data

python tools/benchmark_code_quality.py --report

⚑ PHASE 3: AUTO-FIXER

Step 8: Fix All Issues Automatically

run.bat fix

Or with PowerShell:

.\run.ps1 fix

Step 9: See What Files Were Modified

git status

Step 10: Verify Code Still Works

run.bat test

Or with PowerShell:

.\run.ps1 test

πŸ“Š PHASE 4: COMPARISON

Step 11: Record Post-Fix Benchmark

run.bat benchmark-post-autofix

Or with PowerShell:

.\run.ps1 benchmark-post-autofix

Step 12: Compare Results

run.bat benchmark-compare

Or with PowerShell:

.\run.ps1 benchmark-compare

Step 13: Generate Detailed Report

run.bat benchmark-report

Or with PowerShell:

.\run.ps1 benchmark-report

πŸ€– PHASE 5: AI AGENT

Step 14: See Remaining Errors

type issues_to_fix_*.txt

Or with PowerShell:

Get-Content issues_to_fix_*.txt

Step 15: Use AI Agent

πŸ’¬ Copy and paste this prompt in your AI agent:

Analyze the files in this project and fix the remaining code quality issues 
that automated tools cannot fix. Focus on:
1. Type errors (MyPy issues)
2. Logic improvements
3. Performance optimizations
4. Code structure improvements

Explain each change you make and why it improves the code.

Step 16: Test After AI Changes

run.bat test

Or with PowerShell:

.\run.ps1 test

πŸ“ˆ PHASE 6: FINAL ANALYSIS

Step 17: Record Final Benchmark

run.bat benchmark-post-ai

Or with PowerShell:

.\run.ps1 benchmark-post-ai

Step 18: Final Comparison

run.bat benchmark-compare

Or with PowerShell:

.\run.ps1 benchmark-compare

Step 19: Final Report

run.bat benchmark-report

Or with PowerShell:

.\run.ps1 benchmark-report

Step 20: Reflection

πŸ€” Answer these questions:

  1. What percentage of errors were fixed automatically?

    • Answer: ___ (check benchmark report)
  2. What types of errors were most difficult to fix?

    • Answer: ___
  3. Which tool did you find most useful?

    • Answer: ___
  4. How would you change your development process after this?

    • Answer: ___

πŸ†˜ TROUBLESHOOTING

If a command fails:

REM Check if dependencies are installed
pip list | findstr "black ruff mypy bandit"

REM Reinstall if needed
run.bat install

Or with PowerShell:

# Check if dependencies are installed
pip list | Select-String "black|ruff|mypy|bandit"

# Reinstall if needed
.\run.ps1 install

If tests fail:

REM See specific errors
run.bat test-verbose

REM Verify code works
python main.py

Or with PowerShell:

# See specific errors
.\run.ps1 test-verbose

# Verify code works
python main.py

If you get confused:

  • Go back to the previous step and make sure it completed successfully
  • Check the output of each command for error messages
  • Ask for help if you're stuck

Windows-Specific Issues:

PowerShell Execution Policy

If you get execution policy errors with PowerShell:

# Check current policy
Get-ExecutionPolicy

# Set policy for current user (if needed)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Python Not Found

If Python is not recognized:

  1. Install Python from https://python.org
  2. Make sure to check "Add Python to PATH" during installation
  3. Restart Command Prompt/PowerShell after installation

Long Path Issues

If you encounter path length issues:

REM Enable long paths (Windows 10+)
git config --global core.longpaths true

πŸ† SUCCESS CRITERIA

βœ… Exercise Completed Successfully if:

  • Reduced at least 70% of initial errors
  • Understand what each tool does
  • Can explain the difference between auto-fixer and AI
  • Applied at least 3 changes suggested by AI
  • Code still works after all changes

🎯 Learning Objectives Achieved:

  • Know code quality tools
  • Can automate repetitive tasks
  • Know when to use AI vs automated tools
  • Have a workflow to improve code

πŸ–₯️ Windows-Specific Notes

Command Prompt vs PowerShell

  • Command Prompt: Use run.bat commands
  • PowerShell: Use .\run.ps1 commands (recommended for better error handling)

File Paths

  • Windows uses backslashes (\) in paths
  • Use quotes around paths with spaces: "C:\Program Files\Python\python.exe"

Environment Variables

  • Python path should be in PATH environment variable
  • Check with: echo %PATH% (CMD) or $env:PATH (PowerShell)

Congratulations on completing the exercise! πŸŽ‰

Remember: Code quality is a continuous process, not a destination.