|
| 1 | +# ThrowsAnalyzer CLI Tool |
| 2 | + |
| 3 | +Command-line tool for analyzing C# projects and solutions for exception handling diagnostics using ThrowsAnalyzer. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +dotnet tool install --global ThrowsAnalyzer.Cli |
| 9 | +``` |
| 10 | + |
| 11 | +## Quick Start |
| 12 | + |
| 13 | +```bash |
| 14 | +# Analyze a project |
| 15 | +throws-analyzer analyze MyProject.csproj |
| 16 | + |
| 17 | +# Analyze a solution |
| 18 | +throws-analyzer analyze MySolution.sln |
| 19 | + |
| 20 | +# Generate reports with verbose output |
| 21 | +throws-analyzer analyze MyProject.csproj --verbose --open |
| 22 | +``` |
| 23 | + |
| 24 | +## Features |
| 25 | + |
| 26 | +- **Comprehensive Analysis**: Runs all 30 ThrowsAnalyzer diagnostics on your codebase |
| 27 | +- **Dual Report Format**: Generates both HTML and Markdown reports |
| 28 | +- **Interactive HTML Reports**: Sortable tables, color-coded severity, code snippets |
| 29 | +- **Markdown Reports**: GitHub-compatible documentation format |
| 30 | +- **Statistics Dashboard**: Diagnostics by ID, project, severity, and file |
| 31 | +- **Flexible Filtering**: Filter by diagnostic IDs, projects, severity levels |
| 32 | +- **CI/CD Ready**: Exit codes and report formats suitable for automation |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +```bash |
| 37 | +throws-analyzer analyze <path> [options] |
| 38 | +``` |
| 39 | + |
| 40 | +### Common Options |
| 41 | + |
| 42 | +| Option | Description | Default | |
| 43 | +|--------|-------------|---------| |
| 44 | +| `-c, --configuration` | Build configuration (Debug/Release) | `Debug` | |
| 45 | +| `-s, --min-severity` | Minimum severity (Error/Warning/Info) | `Info` | |
| 46 | +| `-o, --output` | Output directory for reports | `./reports` | |
| 47 | +| `-f, --format` | Report format (html/markdown/both) | `both` | |
| 48 | +| `-v, --verbose` | Show verbose output | `false` | |
| 49 | +| `--open` | Open report after generation | `false` | |
| 50 | + |
| 51 | +### Examples |
| 52 | + |
| 53 | +```bash |
| 54 | +# Analyze with Release configuration |
| 55 | +throws-analyzer analyze MySolution.sln -c Release |
| 56 | + |
| 57 | +# Only show warnings and errors |
| 58 | +throws-analyzer analyze MyProject.csproj -s Warning |
| 59 | + |
| 60 | +# Custom output directory |
| 61 | +throws-analyzer analyze MySolution.sln -o ./build/reports |
| 62 | + |
| 63 | +# HTML report only |
| 64 | +throws-analyzer analyze MyProject.csproj -f html --open |
| 65 | + |
| 66 | +# Filter specific diagnostics |
| 67 | +throws-analyzer analyze MySolution.sln -d THROWS004 THROWS021 THROWS026 |
| 68 | + |
| 69 | +# Analyze specific projects |
| 70 | +throws-analyzer analyze MySolution.sln -p MyProject.Core MyProject.Api |
| 71 | +``` |
| 72 | + |
| 73 | +## Report Output |
| 74 | + |
| 75 | +The tool generates comprehensive reports in `./reports/` by default: |
| 76 | + |
| 77 | +- **`analysis-report.html`** - Interactive HTML report with sortable tables |
| 78 | +- **`analysis-report.md`** - Markdown report for documentation |
| 79 | + |
| 80 | +### Report Contents |
| 81 | + |
| 82 | +- Summary statistics (total diagnostics, by severity) |
| 83 | +- Diagnostics breakdown by ID, project, file |
| 84 | +- Top files with most diagnostics |
| 85 | +- Detailed diagnostics with code snippets |
| 86 | +- Color-coded severity indicators |
| 87 | + |
| 88 | +## CI/CD Integration |
| 89 | + |
| 90 | +### GitHub Actions |
| 91 | + |
| 92 | +```yaml |
| 93 | +- name: Install ThrowsAnalyzer CLI |
| 94 | + run: dotnet tool install --global ThrowsAnalyzer.Cli |
| 95 | + |
| 96 | +- name: Run Analysis |
| 97 | + run: throws-analyzer analyze MySolution.sln -c Release -o ./reports |
| 98 | + |
| 99 | +- name: Upload Reports |
| 100 | + uses: actions/upload-artifact@v3 |
| 101 | + with: |
| 102 | + name: throws-analyzer-reports |
| 103 | + path: ./reports/ |
| 104 | +``` |
| 105 | +
|
| 106 | +### Exit Codes |
| 107 | +
|
| 108 | +- `0` - Analysis completed successfully |
| 109 | +- `1` - Analysis failed |
| 110 | +- `2` - Invalid arguments |
| 111 | + |
| 112 | +## Documentation |
| 113 | + |
| 114 | +For complete documentation, see: |
| 115 | +- [CLI Tool Guide](https://github.com/wieslawsoltes/ThrowsAnalyzer/blob/main/docs/CLI_TOOL.md) |
| 116 | +- [Configuration Guide](https://github.com/wieslawsoltes/ThrowsAnalyzer/blob/main/docs/CONFIGURATION_GUIDE.md) |
| 117 | +- [Main Repository](https://github.com/wieslawsoltes/ThrowsAnalyzer) |
| 118 | + |
| 119 | +## ThrowsAnalyzer |
| 120 | + |
| 121 | +The CLI tool uses [ThrowsAnalyzer](https://www.nuget.org/packages/ThrowsAnalyzer), a Roslyn analyzer with **30 diagnostic rules** for exception handling: |
| 122 | + |
| 123 | +- Basic Exception Handling (8 rules) |
| 124 | +- Exception Flow Analysis (3 rules) |
| 125 | +- Async Exception Patterns (3 rules) |
| 126 | +- Iterator Exception Patterns (2 rules) |
| 127 | +- Lambda Exception Patterns (2 rules) |
| 128 | +- Best Practices (4 rules) |
| 129 | + |
| 130 | +Install the analyzer directly in your projects: |
| 131 | + |
| 132 | +```bash |
| 133 | +dotnet add package ThrowsAnalyzer |
| 134 | +``` |
| 135 | + |
| 136 | +## License |
| 137 | + |
| 138 | +MIT License - Copyright © 2025 Wiesław Šoltés |
| 139 | + |
| 140 | +## Support |
| 141 | + |
| 142 | +- GitHub Issues: https://github.com/wieslawsoltes/ThrowsAnalyzer/issues |
| 143 | +- Documentation: https://github.com/wieslawsoltes/ThrowsAnalyzer/tree/main/docs |
0 commit comments