|
| 1 | +# Code Scanning Configuration |
| 2 | + |
| 3 | +This document explains how code scanning tools are configured for the PPDS SDK repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +| Tool | Configuration | Purpose | |
| 8 | +|------|---------------|---------| |
| 9 | +| **CodeQL** | `.github/codeql/codeql-config.yml` | Security analysis (style rules disabled) | |
| 10 | +| **Copilot** | `.github/copilot-instructions.md` | PR review guidance | |
| 11 | +| **Gemini** | `.gemini/config.yaml`, `.gemini/styleguide.md` | PR review with architecture focus | |
| 12 | +| **Roslyn Analyzers** | `src/PPDS.Analyzers/` | Compile-time enforcement | |
| 13 | + |
| 14 | +## CodeQL Configuration |
| 15 | + |
| 16 | +CodeQL runs the `security-and-quality` query suite with style rules disabled. |
| 17 | + |
| 18 | +### Disabled Rules |
| 19 | + |
| 20 | +| Rule ID | Name | Why Disabled | |
| 21 | +|---------|------|--------------| |
| 22 | +| `cs/linq/missed-where` | LINQ Where suggestion | Conflicts with project style (prefer explicit foreach) | |
| 23 | +| `cs/linq/missed-select` | LINQ Select suggestion | Conflicts with project style | |
| 24 | +| `cs/missed-ternary-operator` | Ternary suggestion | Style preference, not quality | |
| 25 | +| `cs/nested-if-statements` | Nested if suggestion | Style preference, not quality | |
| 26 | +| `cs/catch-of-all-exceptions` | Generic catch clause | Intentional CLI pattern (top-level handlers) | |
| 27 | +| `cs/path-combine` | Path.Combine usage | All paths are controlled inputs in CLI context | |
| 28 | + |
| 29 | +### Path Exclusions |
| 30 | + |
| 31 | +Test code is excluded from analysis: |
| 32 | +- `tests/**` |
| 33 | +- `**/*Tests/**` |
| 34 | +- `**/*.Tests/**` |
| 35 | + |
| 36 | +## Bot Review Assessment |
| 37 | + |
| 38 | +Based on PR feedback analysis: |
| 39 | + |
| 40 | +| Bot | Value | Notes | |
| 41 | +|-----|-------|-------| |
| 42 | +| **Gemini** | HIGH | Catches real bugs: concurrency, performance, logic errors | |
| 43 | +| **Copilot** | MIXED | Good for duplication, resource leaks; noisy for style | |
| 44 | +| **CodeQL** | LOW | Mostly style noise for this codebase | |
| 45 | + |
| 46 | +## Roslyn Analyzers (PPDS.Analyzers) |
| 47 | + |
| 48 | +Compile-time enforcement of architectural patterns. Analyzers run during build and show as warnings in IDE. |
| 49 | + |
| 50 | +### Implemented Rules |
| 51 | + |
| 52 | +| ID | Name | Description | Severity | |
| 53 | +|----|------|-------------|----------| |
| 54 | +| PPDS006 | UseEarlyBoundEntities | Flags string literals in QueryExpression | Warning | |
| 55 | +| PPDS012 | NoSyncOverAsync | Flags `.GetAwaiter().GetResult()`, `.Result`, `.Wait()` | Warning | |
| 56 | +| PPDS013 | NoFireAndForgetInCtor | Flags async calls in constructors without await | Warning | |
| 57 | + |
| 58 | +### Planned Rules |
| 59 | + |
| 60 | +| ID | Name | Description | Source | |
| 61 | +|----|------|-------------|--------| |
| 62 | +| PPDS001 | NoDirectFileIoInUi | UI layer using File.Read/Write directly | ADR-0024 | |
| 63 | +| PPDS002 | NoConsoleInServices | Service using Console.WriteLine | ADR-0015 | |
| 64 | +| PPDS003 | NoUiFrameworkInServices | Service referencing Spectre/Terminal.Gui | ADR-0025 | |
| 65 | +| PPDS004 | UseStructuredExceptions | Service throwing raw Exception | ADR-0026 | |
| 66 | +| PPDS005 | NoSdkInPresentation | CLI command calling ServiceClient directly | ADR-0015 | |
| 67 | +| PPDS007 | PoolClientInParallel | Pool client acquired outside parallel loop | ADR-0002/0005 | |
| 68 | +| PPDS008 | UseBulkOperations | Loop with single Delete/Update calls | Gemini PR#243 | |
| 69 | +| PPDS011 | PropagateCancellation | Async method not passing CancellationToken | Gemini PR#242 | |
| 70 | + |
| 71 | +### Suppressing Analyzer Warnings |
| 72 | + |
| 73 | +To suppress a specific warning in code: |
| 74 | + |
| 75 | +```csharp |
| 76 | +#pragma warning disable PPDS006 |
| 77 | +var query = new QueryExpression("customentity"); // No early-bound class available |
| 78 | +#pragma warning restore PPDS006 |
| 79 | +``` |
| 80 | + |
| 81 | +To suppress project-wide in `.editorconfig`: |
| 82 | + |
| 83 | +```ini |
| 84 | +[*.cs] |
| 85 | +dotnet_diagnostic.PPDS006.severity = none |
| 86 | +``` |
| 87 | + |
| 88 | +## Architecture (ADRs) |
| 89 | + |
| 90 | +Bot instructions reference these Architecture Decision Records: |
| 91 | + |
| 92 | +| ADR | Summary | |
| 93 | +|-----|---------| |
| 94 | +| [0015](../docs/adr/0015_APPLICATION_SERVICE_LAYER.md) | Application Services for CLI/TUI/Daemon | |
| 95 | +| [0024](../docs/adr/0024_SHARED_LOCAL_STATE.md) | Shared local state architecture | |
| 96 | +| [0025](../docs/adr/0025_UI_AGNOSTIC_PROGRESS.md) | UI-agnostic progress reporting | |
| 97 | +| [0026](../docs/adr/0026_STRUCTURED_ERROR_MODEL.md) | Structured error model | |
| 98 | + |
| 99 | +## Related Issues |
| 100 | + |
| 101 | +- [#231](https://github.com/joshsmithxrm/ppds-sdk/issues/231) - Tune code scanning tools to reduce noise |
| 102 | +- [#232](https://github.com/joshsmithxrm/ppds-sdk/issues/232) - ADR-0024 (style) - Prefer foreach over LINQ |
0 commit comments