Conversation
- 3.1: Extract ResolveActiveState to ResourceChangeHelpers (7 factory files) - 3.2: Extract EscapeMarkdown as string extension in DiffFormatterStringExtensions - 3.3: Add GetValue to JsonFlattener; remove duplicates from 2 factories - 3.4+6.4: Extract AzureDevOps formatter constants/helpers to AzureDevOpsFormatterHelpers - 3.5: Add GetPrincipalIcon to MarkdownHelpers; update 2 factories - 6.5: Centralise role assignment attribute constants in AzureRoleAssignmentAttributes
…uce Render method complexity - Add ReportModelBuilderOptions and ReportModelBuilderServices records (tasks 2.1+1.1) - Replace 19-param primary constructor with 2-record traditional constructor - Update all 39 test files and CompositionRoot.cs to use new records - Extract WriteDetailsHeader, WriteTagsBadgesSection, WriteNoChangesMessage, ResolveDetailsTag, ResolveSummary phases from DefaultResourceRenderer.Render (task 4.1) - Remove CA1502 and S3776 suppressions from Render method - Replace 5-pass severity iteration with single GroupBy in RenderCodeAnalysisMetadata (task 4.2) - Remove hardcoded 12-column Security Rules separator; derive from actual headers (task 4.3) - Remove useWideNoOpSecurityRuleTable parameter from RenderChildResources - Delegate ReportRenderer.RenderSummary to SummaryRenderer.Render (task 3.6)
…sistency fixes Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
|
@copilot continue with the code review |
|
@copilot I noticed this comment: "Parameter retained for API compatibility; the canonical renderer handles all shapes." all API usage is internal only. There is no need for compatibility, just fix the caller as well. |
…bleColumn[]) instead of cast syntax Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
Code review and security scan complete:
|
…hildScenario variable from ReportRenderer Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
Fixed in |
|
@copilot |
Test Results1 186 tests 1 186 ✅ 1m 47s ⏱️ Results for commit 5068edd. ♻️ This comment has been updated with latest results. |
Code Coverage Summary
|
…sions Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
Renamed in |
|
@copilot call the code review subagent. if the review has any findings (including suggestions), let the developer fix them, otherwise continue with release manager |
- Remove orphaned #pragma warning restore CA1506 from AzureDevOpsModule.cs and ProgramEntry.cs (the disable was already replaced with [SuppressMessage]) - Use string.Equals(action, "delete", StringComparison.Ordinal) in ResourceChangeHelpers.ResolveActiveState to match codebase CA1307 convention Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
Code review complete (✅ Approved). Two minor findings were fixed in
Ready for the release manager. |
|
@copilot implement the suggestions from the review |
- Remove the one-liner RenderSummary private wrapper in ReportRenderer; call SummaryRenderer.Render directly at the call site (line 67) — eliminates the indirection - Fix AzureDevOpsFormatterHelpers.FormatOptionalString: IsNullOrEmpty → IsNullOrWhiteSpace, consistent with IsNullOrWhiteSpace applied elsewhere in display/formatting code - Update work-protocol.md: replace stale DiffFormatterStringExtensions.cs with the current name MarkdownStringExtensions.cs Co-authored-by: oocx <584396+oocx@users.noreply.github.com>
Implemented in
|
|
@copilot handoff to release manager |
Systematic code quality refactoring across
src/Oocx.TfPlan2Md/covering 22 findings documented indocs/code-quality-report.md. No behaviour changes.Summary
Eliminates pervasive duplicate code, splits a 19-parameter god-constructor into typed records, decomposes an overly complex render method, and standardises C# idioms and warning suppression style across the codebase.
Changes
Duplicate code eliminated
ResourceChangeHelpers.ResolveActiveState— 7 word-for-word copies across factories → single shared utilityMarkdownStringExtensions.EscapeMarkdown— extracted as a string extension method; call sites usevalue.EscapeMarkdown()AzureRoleAssignmentAttributes—role_definition_id/name,principal_id/typeconstants centralised (were duplicated across 3 factory files)AzureDevOpsFormatterHelpers— change-label constants +ConvertBoolToString/FormatOptionalStringshared between both AzDo formatter classesSemanticFormatting.GetPrincipalIcon—User→👤 Group→👥 ServicePrincipal→💻mapping centralised (was in 3 places)ReportRenderercallsSummaryRenderer.Render(boldTotal: true)directly at the call site — one-liner private wrapper removedConstructor coupling reduced
ReportModelBuilder's 19-parameter primary constructor (suppressedS107) replaced with two typed records:Complexity reduced
DefaultResourceRenderer.Render— 12 inline phases extracted into named private methods (WriteDetailsHeader,WriteTagsBadgesSection,WriteNoChangesMessage, …);CA1502/S3776suppressions removedRenderCodeAnalysisMetadata— 5 separate.Count()passes over findings → singleGroupBy+ canonical severity-order iterationRenderChildResources— hardcoded"Security Rules"12-column separator → derived from actual column count;useWideNoOpSecurityRuleTablespecial case removedReportRenderer— removed deaduseWideSeparatorsparameter (was discarded with_ =), its unuseduseWideSummarySeparatorslocal variable, and theisNoOpParentChildScenariovariable that was computed solely to feed itNaming improved
DiffFormatterStringExtensionsrenamed toMarkdownStringExtensions— the escape utility is general-purpose markdown escaping, not specific to diff formattersC# modernisation & consistency
new[] { ... }→ collection expressions using explicit-type form (string[] x = [...],ChildTableColumn[] x = [...]) inAzureRMModuleandRoleAssignmentViewModelFactorylabelGroup.Count() == 1→!labelGroup.Skip(1).Any()(avoids O(n) enumeration onIGrouping)#pragma warning disable CA1506→[SuppressMessage(..., Justification = "...")]inAzureDevOpsModule,BuildDefinitionFormatters,BuildDefinitionViewModelFactory,ProgramEntry; orphaned#pragma warning restore CA1506lines removed fromAzureDevOpsModuleandProgramEntryIsNullOrEmpty→IsNullOrWhiteSpacethroughout display/formatting code (RoleAssignmentViewModelFactoryandAzureDevOpsFormatterHelpers.FormatOptionalString)ResourceChangeHelpers.ResolveActiveStateusesstring.Equals(…, StringComparison.Ordinal)to match codebase CA1307 conventionChecklist
Merge method: Use Rebase and merge to maintain a linear history. The repository enforces rebase-only merges by default.
Create & merge guidance: Use
scripts/pr-github.sh createto create PRs, andscripts/pr-github.sh create-and-mergeto perform the merge (this script is the authoritative, repo-preferred tool for PR creation and merges). If you need to inspect/check the PR, use GitHub chat tools (github/*) as needed.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.