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. --- DomainInspectionService.swift | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'DomainInspectionService.swift') diff --git a/DomainInspectionService.swift b/DomainInspectionService.swift index 3cdb21c..3ebfe09 100644 --- a/DomainInspectionService.swift +++ b/DomainInspectionService.swift @@ -295,10 +295,10 @@ struct DomainInspectionService { let ptrRecord = mapOptionalServiceResult(ptrOutcome.map { normalizeErrors(in: $0.value) }, missingMessage: "No A record available") let geolocation = mapOptionalServiceResult(geoOutcome.map { normalizeErrors(in: $0.value) }, missingMessage: "No A record available") let availabilityConfidence = confidenceForAvailability(result: availability.value, provenance: provenanceBySection[.availability]) - let ownershipConfidence = confidenceForOwnership(result: ownership.value, error: ownership.message) - let subdomainConfidence = confidenceForSubdomains(results: subdomains.value, error: subdomains.message) - let emailConfidence = confidenceForEmail(result: emailSecurity.value, error: emailSecurity.message) - let geolocationConfidence = confidenceForGeolocation(result: geolocation.value, error: geolocation.message) + let ownershipConfidence = confidenceForOwnership(result: ownership.value) + let subdomainConfidence = confidenceForSubdomains(results: subdomains.value) + let emailConfidence = confidenceForEmail(result: emailSecurity.value) + let geolocationConfidence = confidenceForGeolocation(result: geolocation.value) let validationIssues = validationIssues(for: normalizedDomain, snapshotTimestamp: startedAt, availability: availability.value, dnsSections: dnsSections.value, provenanceBySection: provenanceBySection) let snapshot = LookupSnapshot( @@ -580,21 +580,21 @@ struct DomainInspectionService { return .low } - private func confidenceForOwnership(result: DomainOwnership?, error: String?) -> ConfidenceLevel { - guard let result else { return error == nil ? .low : .low } + private func confidenceForOwnership(result: DomainOwnership?) -> ConfidenceLevel { + guard let result else { return .low } let hasDirectRegistrationData = result.registrar != nil || result.createdDate != nil || result.expirationDate != nil return hasDirectRegistrationData ? .high : .medium } - private func confidenceForSubdomains(results: [DiscoveredSubdomain], error: String?) -> ConfidenceLevel { + private func confidenceForSubdomains(results: [DiscoveredSubdomain]) -> ConfidenceLevel { if !results.isEmpty { return .medium } - return error == nil ? .low : .low + return .low } - private func confidenceForEmail(result: EmailSecurityResult?, error: String?) -> ConfidenceLevel { - guard let result else { return error == nil ? .low : .low } + private func confidenceForEmail(result: EmailSecurityResult?) -> ConfidenceLevel { + guard let result else { return .low } let foundCount = [result.spf.found, result.dmarc.found, result.dkim.found, result.bimi.found, result.mtaSts?.txtFound == true] .filter { $0 } .count @@ -607,8 +607,8 @@ struct DomainInspectionService { return .low } - private func confidenceForGeolocation(result: IPGeolocation?, error: String?) -> ConfidenceLevel { - guard let result else { return error == nil ? .low : .low } + private func confidenceForGeolocation(result: IPGeolocation?) -> ConfidenceLevel { + guard let result else { return .low } if result.city != nil && result.country_name != nil && result.latitude != nil && result.longitude != nil { return .high } -- cgit v1.2.3