From bb18197860ffdb491f010648ec903003b6e1bb65 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 20 Jul 2026 16:22:28 -0500 Subject: v4.8.3: Clear SonarCloud new-code issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the 4 reported bugs and ~97 code smells flagged in the new-code period. No behavior changes. Bugs (swift:S3923) — DomainInspectionService's confidenceFor* helpers each returned `error == nil ? .low : .low`, an inert conditional. Simplified to `return .low` and dropped the now-unused `error` parameter. Smells: - Merged 14 identical `.empty`/`.error` switch branches in DomainViewModel - Consolidated duplicate implementations (clearPresentedResults/reset, String.nonEmpty/nilIfEmpty, ExportFormat.id/fileExtension) - Extracted nested ternaries into TLSGrade.tone, EmailSecurityGrade.tone, and ChangeImpactClassification.color; removed ContentView.impactColor and the duplicate mapping in BatchResultsView - Documented empty closures and singleton inits - Marked unused protocol-conformance parameters `_` - Renamed CloudSyncTrigger.`import` to `imported` (raw value preserved) and SSLSessionDelegate's _serverTrust/_tlsMetadata - Merged nested ifs in the DER parser; flattened closure nesting in PortScanService and IntegrationService - Replaced two-case switches with if/else Left open: S107 (init parameter counts), S115 (constants mirroring DoH and ipapi JSON keys), S1075 (false positives on https:// literals), and two S117 hits on SwiftUI $binding shorthand. These want a Won't Fix resolution in SonarCloud, not a code change. --- DomainDig/DomainInsightEngine.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'DomainDig/DomainInsightEngine.swift') diff --git a/DomainDig/DomainInsightEngine.swift b/DomainDig/DomainInsightEngine.swift index f1de9c0..6f8edeb 100644 --- a/DomainDig/DomainInsightEngine.swift +++ b/DomainDig/DomainInsightEngine.swift @@ -412,7 +412,7 @@ enum DomainInsightEngine { if hasMXRecords(snapshot), snapshot.emailSecurity == nil { patterns.append("MX records exist without corresponding email security records") } - if snapshot.sslInfo != nil && !(snapshot.dnsSections.first(where: { $0.recordType == .CAA })?.records.isEmpty == false) { + if snapshot.sslInfo != nil, snapshot.dnsSections.first(where: { $0.recordType == .CAA })?.records.isEmpty != false { patterns.append("TLS is active but no CAA record was found") } @@ -427,9 +427,16 @@ enum DomainInsightEngine { let dmarcFound = result.dmarc.found let dmarcStrict = isStrictDMARC(result.dmarc.value) + let dmarcReason: String + if !dmarcFound { + dmarcReason = "DMARC missing" + } else { + dmarcReason = dmarcStrict ? "DMARC policy is strict" : "DMARC policy is not strict" + } + let reasons = [ spfFound ? "SPF present" : "SPF missing", - dmarcFound ? (dmarcStrict ? "DMARC policy is strict" : "DMARC policy is not strict") : "DMARC missing", + dmarcReason, dkimFound ? "DKIM present" : "DKIM not detected" ] -- cgit v1.2.3