f-meloni / danger-swift-coverage

Show the coverage of the modified/created files on your PRs.
MIT License
85 stars 20 forks source link

`excludedTargets` parameter default value problem #27

Closed el-hoshino closed 4 years ago

el-hoshino commented 4 years ago

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

nikolaykasyanov commented 4 years ago

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

f-meloni commented 4 years ago

Thank you, https://github.com/f-meloni/danger-swift-coverage/pull/28 should fix it