Skip to content

feat: code scanning cleanup and Roslyn analyzers#244

Merged
joshsmithxrm merged 5 commits intomainfrom
fix/code-scanning-cleanup
Jan 7, 2026
Merged

feat: code scanning cleanup and Roslyn analyzers#244
joshsmithxrm merged 5 commits intomainfrom
fix/code-scanning-cleanup

Conversation

@joshsmithxrm
Copy link
Owner

Summary

  • Tune code scanning tools (CodeQL, Copilot, Gemini) to reduce noise and focus on real issues
  • Add Roslyn analyzers for compile-time architectural enforcement
  • Dismiss 282 legacy CodeQL alerts that were style suggestions, not security issues

Changes

CodeQL Configuration

  • Disable 6 style rules that conflict with project conventions (LINQ suggestions, ternary, nested-if, etc.)
  • Keep security-and-quality suite for actual security analysis

Bot Configuration

  • Add .github/copilot-instructions.md with ADR-based architecture guidance
  • Add .gemini/config.yaml and styleguide.md for Gemini Code Assist
  • Focus bots on real issues: concurrency, performance, resource leaks

Roslyn Analyzers (PPDS.Analyzers)

ID Rule Purpose
PPDS006 UseEarlyBoundEntities Flag string literals in QueryExpression
PPDS012 NoSyncOverAsync Flag .GetAwaiter().GetResult(), .Result, .Wait()
PPDS013 NoFireAndForgetInCtor Flag unawaited async calls in constructors

EditorConfig

  • Fix generated code pattern to match subdirectories (**/Generated/**.cs)
  • Suppress CS8981 for lowercase enum names in generated code

Test plan

  • Build succeeds with 0 warnings, 0 errors
  • All unit tests pass
  • PPDS012 analyzer correctly flags sync-over-async (verified with ServiceRegistration.cs)
  • CI pipeline passes

Closes #231

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 7, 2026 04:13
@gemini-code-assist
Copy link

Summary of Changes

Hello @joshsmithxrm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's code quality and developer experience by streamlining static analysis tools and introducing custom architectural enforcement. By tuning existing code scanning tools and integrating new Roslyn analyzers, the aim is to reduce irrelevant warnings, highlight critical issues more effectively, and ensure adherence to established architectural patterns, ultimately leading to more robust and maintainable code.

Highlights

  • Code Scanning Tuning: CodeQL, Copilot, and Gemini configurations have been refined to significantly reduce noise from style suggestions and focus on identifying genuine security, performance, and architectural issues. This includes disabling 6 CodeQL style rules that conflicted with project conventions and dismissing 282 legacy CodeQL alerts.
  • New Roslyn Analyzers: Three custom Roslyn analyzers (PPDS006, PPDS012, PPDS013) have been introduced to enforce compile-time architectural patterns. These analyzers flag issues such as using string literals in QueryExpression, sync-over-async patterns, and fire-and-forget async calls in constructors.
  • Bot Review Guidance: Dedicated instruction files (.github/copilot-instructions.md and .gemini/config.yaml, styleguide.md) have been added to guide Copilot and Gemini Code Assist, ensuring their feedback aligns with the project's Architectural Decision Records (ADRs) and focuses on high-value findings.
  • EditorConfig Updates: The .editorconfig has been updated to correctly match generated code in subdirectories (**/Generated/**.cs) and to suppress the CS8981 warning for lowercase enum names in generated code, which is common in Power Platform contexts.
Ignored Files
  • Ignored by pattern: .gemini/** (2)
    • .gemini/config.yaml
    • .gemini/styleguide.md
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is an excellent pull request that significantly improves the project's code quality and maintainability by introducing Roslyn analyzers for architectural enforcement and cleaning up code scanning configurations. The new documentation, analyzer projects, and configuration files are well-structured and clear. I have one suggestion to make one of the new analyzers more robust by using a stronger type check. Overall, this is a high-quality contribution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a comprehensive code scanning cleanup by tuning existing tools (CodeQL, Copilot, Gemini) and introducing custom Roslyn analyzers for compile-time architectural enforcement. The changes focus on reducing noise from style suggestions while maintaining security analysis capabilities.

  • Configures CodeQL to disable 6 style rules that conflict with project conventions while keeping the security-and-quality suite
  • Adds custom Roslyn analyzers (PPDS.Analyzers) for architectural pattern enforcement at compile-time
  • Creates bot configuration files to guide Copilot and Gemini reviews toward real issues (concurrency, performance, resource leaks)

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/PPDS.Analyzers/Rules/UseEarlyBoundEntitiesAnalyzer.cs Analyzer to detect string literals in QueryExpression and suggest early-bound constants
src/PPDS.Analyzers/Rules/NoSyncOverAsyncAnalyzer.cs Analyzer to detect sync-over-async patterns that can cause deadlocks
src/PPDS.Analyzers/Rules/NoFireAndForgetInCtorAnalyzer.cs Analyzer to detect unawaited async calls in constructors
src/PPDS.Analyzers/DiagnosticIds.cs Central registry of diagnostic IDs and categories for all analyzers
src/PPDS.Analyzers/PPDS.Analyzers.csproj Analyzer project configuration targeting netstandard2.0 with Roslyn packages
src/PPDS.Cli/PPDS.Cli.csproj Adds analyzer project reference with OutputItemType="Analyzer"
src/PPDS.Cli/Services/ServiceRegistration.cs Adds pragma suppression for PPDS012 with justification comment for DI factory
PPDS.Sdk.sln Adds PPDS.Analyzers project to solution with build configurations
.github/copilot-instructions.md Guidance for Copilot reviews based on ADRs and project patterns
.github/codeql/codeql-config.yml Disables 6 style-related CodeQL rules while keeping security analysis
.github/CODE_SCANNING.md Comprehensive documentation of code scanning tools and rationale
.gemini/config.yaml Gemini Code Assist configuration with MEDIUM severity threshold
.gemini/styleguide.md Architecture guidance for Gemini based on ADRs and common patterns
.editorconfig Updates generated code pattern and adds CS8981 suppression for lowercase enums

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/PPDS.Cli/Services/ServiceRegistration.cs 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Tune code scanning tools to reduce noise and add architectural enforcement:

## CodeQL
- Disable 6 style rules that conflict with project conventions
- Keep security-and-quality suite for actual security analysis
- All 282 existing alerts dismissed (batch API)

## Bot Configuration
- Add .github/copilot-instructions.md with ADR-based guidance
- Add .gemini/config.yaml and styleguide.md for Gemini Code Assist
- Focus bots on real issues: concurrency, performance, resource leaks

## Roslyn Analyzers (PPDS.Analyzers)
- PPDS006: UseEarlyBoundEntities - flag string literals in QueryExpression
- PPDS012: NoSyncOverAsync - flag .GetAwaiter().GetResult(), .Result, .Wait()
- PPDS013: NoFireAndForgetInCtor - flag unawaited async calls in constructors

## EditorConfig
- Fix generated code pattern to match subdirectories
- Suppress CS8981 for lowercase enum names in generated code

Closes #231

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use full metadata name for QueryExpression type check (Gemini)
- Reference CODE_SCANNING.md instead of CLAUDE.md (Copilot)
- Combine nested if statements in NoSyncOverAsyncAnalyzer (Copilot)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add PPDS012/PPDS013 suppressions to TUI files with comments explaining why:
- PpdsApplication.cs: Terminal.Gui requires sync disposal (IDisposable contract)
- SqlQueryScreen.cs: Fire-and-forget with explicit ContinueWith error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add triage decision tree to CODE_SCANNING.md
- Document known safe patterns (Terminal.Gui sync disposal, DI factories, ContinueWith)
- Add HasContinueWithErrorHandling to PPDS013 analyzer to recognize
  fire-and-forget with .ContinueWith() as intentional error handling
- Reduces false positives for patterns like SqlQueryScreen constructor

Closes #246

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CodeQL flagged outerInvocation as unused - only type check needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@joshsmithxrm
Copy link
Owner Author

Fixed CodeQL finding (unused variable) in 8d73174 - Removed outerInvocation, now using type-only pattern match.

@joshsmithxrm joshsmithxrm merged commit 573c21c into main Jan 7, 2026
12 checks passed
@joshsmithxrm joshsmithxrm deleted the fix/code-scanning-cleanup branch January 7, 2026 07:01
@github-project-automation github-project-automation bot moved this from Todo to Done in PPDS Roadmap Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

chore: Tune code scanning tools to reduce noise

2 participants