RuntimeTools / SwiftMetrics

Swift Application Metrics instruments the Swift runtime for performance monitoring, providing the monitoring data programatically via an API or visually with an Eclipse Client.
https://developer.ibm.com/swift/monitoring-diagnostics/application-metrics-for-swift/
Other
154 stars 49 forks source link

SwiftBAMDC warning for String interpolation and default values #198

Closed KyeMaloy97 closed 5 years ago

KyeMaloy97 commented 6 years ago

In SwiftDataCollector.swift on line 61, there is a String interpolation warning from the compiler.

warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit? Log.debug("[SwiftDataCollector] envData: \(self.envData)")

Swift Version: 4.1 macOS Version: 10.14 Mojave SwiftMetrics Version: 2.4.0

There were also two notes from the compiler too:

note: use 'String(describing:)' to silence this warning note: provide a default value to avoid this warning

djones6 commented 5 years ago

This looks to be due to the Swift 4.2 changes to implicitly unwrapped optionals: https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md

It seems that although envData is force-unwrapped, it is now presented as a [String:String]? in terms of its type, which triggers this warning when applying string interpolation.

I suspect a fix would be to change this to envData: \(self.envData ?? [:])