profile
viewpoint

Ask questions`excludedTargets` parameter default value problem

From 1.2.0 there's a new xcodeBuildCoverage method implemented in #26 that allows using [ExcludedTarget] type for excludedTargets parameter.

But the problem is, in that method the excludedTargets parameter also has a default value [], which causes a big problem that for projects that don't have excluded targets, there's no way for the compiler to check which method to use, the excludedTargets: [String] one or the excludedTargets: [ExcludedTarget] one. And that will cause a build error:

/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/_tmp_dangerfile.swift:577:1: error: ambiguous use of 'xcodeBuildCoverage(_:minimumCoverage:excludedTargets:hideProjectCoverage:)'
Coverage.xcodeBuildCoverage(.xcresultBundle(ProcessInfo.xcTestResultPath), minimumCoverage: 60)
^
/Users/vagrant/.danger-swift/Scripts/Cache/-Users-vagrant-git-_dangerfile_imports/.build/checkouts/danger-swift-coverage/Sources/DangerSwiftCoverage/DangerSwiftCoverage.swift:19:24: note: found this candidate
    public static func xcodeBuildCoverage(_ coveragePathType: CoveragePathType, minimumCoverage: Float, excludedTargets: [String] = [], hideProjectCoverage: Bool = false) {
                       ^
/Users/vagrant/.danger-swift/Scripts/Cache/-Users-vagrant-git-_dangerfile_imports/.build/checkouts/danger-swift-coverage/Sources/DangerSwiftCoverage/DangerSwiftCoverage.swift:24:24: note: found this candidate
    public static func xcodeBuildCoverage(_ coveragePathType: CoveragePathType, minimumCoverage: Float, excludedTargets: [ExcludedTarget] = [], hideProjectCoverage: Bool = false) {

I think the best way to solve this problem is to remove the default value for [ExcludedTarget] method so for the projects that don't have an excludedTargets parameter, the build can still be passed

f-meloni/danger-swift-coverage

Answer questions nikolaykasyanov

Oh I didn't see this coming, nice find.

useful!
source:https://uonfu.com/
Github User Rank List