Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/cli/audit_diff_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func renderAuditDiffPretty(diff *AuditDiff) {
var summaryParts []string
anomalyCount := 0

if diff.FirewallDiff != nil && !isEmptyDiff(diff.FirewallDiff) {
if diff.FirewallDiff != nil && !isEmptyFirewallDiff(diff.FirewallDiff) {
fwParts := []string{}
if len(diff.FirewallDiff.NewDomains) > 0 {
fwParts = append(fwParts, fmt.Sprintf("%d new domains", len(diff.FirewallDiff.NewDomains)))
Expand Down Expand Up @@ -102,7 +102,7 @@ func renderAuditDiffPretty(diff *AuditDiff) {

// renderFirewallDiffMarkdownSection renders the firewall diff sub-section as markdown
func renderFirewallDiffMarkdownSection(diff *FirewallDiff) {
if diff == nil || isEmptyDiff(diff) {
if diff == nil || isEmptyFirewallDiff(diff) {
return
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func renderRunMetricsDiffMarkdownSection(run1ID, run2ID int64, diff *RunMetricsD

// renderFirewallDiffPrettySection renders the firewall diff as a pretty console sub-section
func renderFirewallDiffPrettySection(diff *FirewallDiff) {
if diff == nil || isEmptyDiff(diff) {
if diff == nil || isEmptyFirewallDiff(diff) {
return
}

Expand Down Expand Up @@ -370,8 +370,8 @@ func statusEmoji(status string) string {
}
}

// isEmptyDiff returns true if the firewall diff contains no changes
func isEmptyDiff(diff *FirewallDiff) bool {
// isEmptyFirewallDiff returns true if the firewall diff contains no changes
func isEmptyFirewallDiff(diff *FirewallDiff) bool {
return len(diff.NewDomains) == 0 &&
len(diff.RemovedDomains) == 0 &&
len(diff.StatusChanges) == 0 &&
Expand All @@ -387,7 +387,7 @@ func isEmptyMCPToolsDiff(diff *MCPToolsDiff) bool {

// isEmptyAuditDiff returns true if the audit diff contains no changes across all sections
func isEmptyAuditDiff(diff *AuditDiff) bool {
fwEmpty := diff.FirewallDiff == nil || isEmptyDiff(diff.FirewallDiff)
fwEmpty := diff.FirewallDiff == nil || isEmptyFirewallDiff(diff.FirewallDiff)
mcpEmpty := diff.MCPToolsDiff == nil || isEmptyMCPToolsDiff(diff.MCPToolsDiff)
metricsEmpty := diff.RunMetricsDiff == nil
return fwEmpty && mcpEmpty && metricsEmpty
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/audit_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ func TestStatusEmoji(t *testing.T) {

func TestIsEmptyDiff(t *testing.T) {
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The test name TestIsEmptyDiff is now misleading since the helper under test was renamed to isEmptyFirewallDiff. Renaming the test to TestIsEmptyFirewallDiff (or similar) would keep test intent aligned with the production symbol name and make grepping easier.

Suggested change
func TestIsEmptyDiff(t *testing.T) {
func TestIsEmptyFirewallDiff(t *testing.T) {

Copilot uses AI. Check for mistakes.
emptyDiff := &FirewallDiff{}
assert.True(t, isEmptyDiff(emptyDiff), "Empty diff should be detected")
assert.True(t, isEmptyFirewallDiff(emptyDiff), "Empty diff should be detected")

nonEmptyDiff := &FirewallDiff{
NewDomains: []DomainDiffEntry{{Domain: "test.com"}},
}
assert.False(t, isEmptyDiff(nonEmptyDiff), "Non-empty diff should not be detected as empty")
assert.False(t, isEmptyFirewallDiff(nonEmptyDiff), "Non-empty diff should not be detected as empty")
}

// findDiffEntry is a test helper to find a domain in a list of diff entries
Expand Down
Loading