Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #65

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
strategy:
fail-fast: false
matrix:
xcode: ["14.3.1"]
xcode: ["14.3.1", "15.0.1"]
include:
- xcode: "14.3.1"
macos: macos-13
- xcode: "15.0.1"
macos: macos-13
runs-on: ${{ matrix.macos }}
name: macOS
steps:
Expand Down Expand Up @@ -57,11 +59,14 @@ jobs:
strategy:
fail-fast: false
matrix:
swift: ["5.8"]
swift: ["5.8", "5.9"]
include:
- swift: "5.8"
container: "swift:5.8"
cache-version: 1
- swift: "5.9"
container: "swift:5.9"
cache-version: 1
runs-on: ubuntu-latest
container: ${{ matrix.container }}
name: Linux
Expand Down
26 changes: 13 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/peripheryapp/periphery",
"state" : {
"revision" : "5182b803cd852276203ee3e3b5af753acde16d0f",
"version" : "2.15.0"
"revision" : "1a06cd8deb85c933bbcf7ac5b4f0a788250f9903",
"version" : "2.17.1"
}
},
{
Expand All @@ -68,17 +68,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/danger/swift.git",
"state" : {
"revision" : "0a4b52f4518974cbd2cc45c29d33cb54a303f81d",
"version" : "3.15.0"
"revision" : "ac400f78c3c0de5b886a2b88f67a26e055548c46",
"version" : "3.18.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
"version" : "1.2.0"
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
Expand Down Expand Up @@ -111,10 +111,10 @@
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/peripheryapp/swift-syntax",
"location" : "https://github.com/apple/swift-syntax",
"state" : {
"revision" : "56ef324e094ad1e655ae7d8c8dabadc7e6bd64e9",
"version" : "1.0.2"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
Expand All @@ -140,17 +140,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tuist/xcodeproj",
"state" : {
"revision" : "b6de1bfe021b861c94e7c83821b595083f74b997",
"version" : "8.8.0"
"revision" : "447c159b0c5fb047a024fd8d942d4a76cf47dde0",
"version" : "8.16.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "01835dc202670b5bb90d07f3eae41867e9ed29f6",
"version" : "5.0.1"
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.0.0"),
.package(url: "https://github.com/taji-taji/swift-shell.git", from: "1.0.0"),
.package(url: "https://github.com/peripheryapp/periphery", from: "2.15.0"),
.package(url: "https://github.com/peripheryapp/periphery", from: "2.0.0"),
],
targets: [
.target(
Expand Down
28 changes: 14 additions & 14 deletions Sources/DangerSwiftPeriphery/DangerDSL+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ extension DangerDSL: ViolationNotifier {
}

extension DangerDSL: PullRequestDiffProvidable {
private var sourceBranch: String {
if let github = github {
return "\(github.pullRequest.base.sha)..\(github.pullRequest.head.sha)"
} else if let gitLab = gitLab {
return gitLab.mergeRequest.targetBranch
} else if let bitbucketCloud = bitbucketCloud {
return bitbucketCloud.pr.destination.branchName
} else if let bitbucketServer = bitbucketServer {
return bitbucketServer.pullRequest.fromRef.displayId
}
return ""
}

func diff(forFile file: String) throws -> FileDiff.Changes {
try utils.diff(forFile: file, sourceBranch: sourceBranch())
try utils.diff(forFile: file, sourceBranch: sourceBranch)
.map {
Logger.shared.debug("changes for \(file):\($0.changes)")
switch $0.changes {
Expand All @@ -27,19 +40,6 @@ extension DangerDSL: PullRequestDiffProvidable {
}
.get()
}

private func sourceBranch() -> String {
if let github = github {
return "origin/\(github.pullRequest.base.ref)..HEAD"
} else if let gitLab = gitLab {
return gitLab.mergeRequest.targetBranch
} else if let bitbucketCloud = bitbucketCloud {
return bitbucketCloud.pr.destination.branchName
} else if let bitbucketServer = bitbucketServer {
return bitbucketServer.pullRequest.fromRef.displayId
}
return ""
}
}

private extension FileDiff.Hunk {
Expand Down
115 changes: 68 additions & 47 deletions Sources/DangerSwiftPeriphery/PeripheryScanOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,85 @@ public enum PeripheryScanOptions {
case retainAssignOnlyProperties
case retainAssignOnlyPropertyTypes([String])
case externalEncodableProtocols([String])
case externalTestCaseClasses([String])
case retainObjcAccessible
case retainObjcAnnotated
case retainUnusedProtocolFuncParams
case cleanBuild
case retainSwiftUIPreviews
case skipBuild
case relativeResults
case strict
case custom(String)
}

extension PeripheryScanOptions {
var optionString: String {
if case let .custom(value) = self {
return value
}
if values.isEmpty {
return key
} else {
return values
.map { [key, $0].joined(separator: " ") }
switch self {
case .config(let config):
return "--config \(config)"
case .workspace(let workspace):
return "--workspace \(workspace)"
case .project(let project):
return "--project \(project)"
case .schemes(let schemes):
return schemes
.map({ "--schemes \($0)" })
.joined(separator: " ")
case .targets(let targets):
return targets
.map({ "--targets \($0)" })
.joined(separator: " ")
case .indexExclude(let indexes):
return indexes
.map({ "--index-exclude \($0)" })
.joined(separator: " ")
case .reportExclude(let reports):
return reports
.map({ "--report-exclude \($0)" })
.joined(separator: " ")
case .reportInclude(let reports):
return reports
.map({ "--report-include \($0)" })
.joined(separator: " ")
case .indexStorePath(let path):
return "--index-store-path \(path)"
case .retainPublic:
return "--retain-public"
case .disableRedundantPublicAnalysis:
return "--disable-redundant-public-analysis"
case .retainAssignOnlyProperties:
return "--retain-assign-only-properties"
case .retainAssignOnlyPropertyTypes(let types):
return types
.map({ "--retain-assign-only-property-types \($0)" })
.joined(separator: " ")
case .externalEncodableProtocols(let protocols):
return protocols
.map({ "--external-encodable-protocols \($0)" })
.joined(separator: " ")
case .externalTestCaseClasses(let classes):
return classes
.map({ "--external-test-case-classes \($0)" })
.joined(separator: " ")
case .retainObjcAccessible:
return "--retain-objc-accessible"
case .retainObjcAnnotated:
return "--retain-objc-annotated"
case .retainUnusedProtocolFuncParams:
return "--retain-unused-protocol-func-params"
case .cleanBuild:
return "--clean-build"
case .retainSwiftUIPreviews:
return "--retain-swift-ui-previews"
case .skipBuild:
return "--skip-build"
case .relativeResults:
return "--relative-results"
case .strict:
return "--strict"
case .custom(let option):
return option
}
}
}

private extension PeripheryScanOptions {
var key: String {
let reflection = Mirror(reflecting: self)
guard reflection.displayStyle == .enum,
let associated = reflection.children.first else {
return "--" + "\(self)".kebabCased
}
return "--" + associated.label!.kebabCased
}

var values: [String] {
let reflection = Mirror(reflecting: self)
guard reflection.displayStyle == .enum,
let associated = reflection.children.first else {
return []
}
switch associated.value {
case let value as String:
return [value]
case let values as [String]:
return values
default:
return []
}
}
}

private extension String {
var kebabCased: String {
let pattern = "([a-z0-9])([A-Z])"

guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {
return self
}
let range = NSRange(location: 0, length: count)
return regex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1-$2").lowercased()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ final class PeripheryScanOptionsTests: XCTestCase {
"--retain-assign-only-property-types type1 --retain-assign-only-property-types type2"),
(.externalEncodableProtocols(["protocol1", "protocol2"]),
"--external-encodable-protocols protocol1 --external-encodable-protocols protocol2"),
(.externalTestCaseClasses(["class1", "class2"]), "--external-test-case-classes class1 --external-test-case-classes class2"),
(.retainObjcAccessible, "--retain-objc-accessible"),
(.retainObjcAnnotated, "--retain-objc-annotated"),
(.retainUnusedProtocolFuncParams, "--retain-unused-protocol-func-params"),
(.cleanBuild, "--clean-build"),
(.retainSwiftUIPreviews, "--retain-swift-ui-previews"),
(.skipBuild, "--skip-build"),
(.relativeResults, "--relative-results"),
(.strict, "--strict"),
(.custom("--test test"), "--test test"),
]
Expand Down