Skip to content

Commit d92b2d1

Browse files
authored
Merge pull request #101 from kkebo/add-ci
2 parents 8f7ba01 + dcb6962 commit d92b2d1

13 files changed

+157
-37
lines changed

.github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ci
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["main"]
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
container: swift:6.1
11+
steps:
12+
- uses: actions/checkout@v4
13+
- run: swift format lint -rsp .
14+
yamllint:
15+
runs-on: ubuntu-latest
16+
container: alpine:3.21
17+
steps:
18+
- uses: actions/checkout@v4
19+
- run: apk update && apk add yamllint
20+
- run: yamllint --version
21+
- run: yamllint --strict --config-file .yamllint.yml .

.swift-format

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentConditionalCompilationBlocks" : true,
6+
"indentSwitchCaseLabels" : false,
7+
"indentation" : {
8+
"spaces" : 4
9+
},
10+
"lineBreakAroundMultilineExpressionChainComponents" : true,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : true,
13+
"lineBreakBeforeEachGenericRequirement" : true,
14+
"lineBreakBetweenDeclarationAttributes" : false,
15+
"lineLength" : 120,
16+
"maximumBlankLines" : 1,
17+
"multiElementCollectionTrailingCommas" : true,
18+
"noAssignmentInExpressions" : {
19+
"allowedFunctions" : [
20+
"XCTAssertNoThrow"
21+
]
22+
},
23+
"prioritizeKeepingFunctionOutputTogether" : true,
24+
"reflowMultilineStringLiterals" : {
25+
"never" : {
26+
27+
}
28+
},
29+
"respectsExistingLineBreaks" : true,
30+
"rules" : {
31+
"AllPublicDeclarationsHaveDocumentation" : false,
32+
"AlwaysUseLiteralForEmptyCollectionInit" : true,
33+
"AlwaysUseLowerCamelCase" : true,
34+
"AmbiguousTrailingClosureOverload" : true,
35+
"AvoidRetroactiveConformances" : false,
36+
"BeginDocumentationCommentWithOneLineSummary" : true,
37+
"DoNotUseSemicolons" : true,
38+
"DontRepeatTypeInStaticProperties" : true,
39+
"FileScopedDeclarationPrivacy" : true,
40+
"FullyIndirectEnum" : true,
41+
"GroupNumericLiterals" : true,
42+
"IdentifiersMustBeASCII" : true,
43+
"NeverForceUnwrap" : false,
44+
"NeverUseForceTry" : true,
45+
"NeverUseImplicitlyUnwrappedOptionals" : true,
46+
"NoAccessLevelOnExtensionDeclaration" : true,
47+
"NoAssignmentInExpressions" : true,
48+
"NoBlockComments" : true,
49+
"NoCasesWithOnlyFallthrough" : true,
50+
"NoEmptyLinesOpeningClosingBraces" : true,
51+
"NoEmptyTrailingClosureParentheses" : true,
52+
"NoLabelsInCasePatterns" : true,
53+
"NoLeadingUnderscores" : true,
54+
"NoParensAroundConditions" : true,
55+
"NoPlaygroundLiterals" : true,
56+
"NoVoidReturnOnFunctionSignature" : true,
57+
"OmitExplicitReturns" : true,
58+
"OneCasePerLine" : true,
59+
"OneVariableDeclarationPerLine" : true,
60+
"OnlyOneTrailingClosureArgument" : true,
61+
"OrderedImports" : true,
62+
"ReplaceForEachWithForLoop" : true,
63+
"ReturnVoidInsteadOfEmptyTuple" : true,
64+
"TypeNamesShouldBeCapitalized" : true,
65+
"UseEarlyExits" : true,
66+
"UseExplicitNilCheckInConditions" : true,
67+
"UseLetInEveryBoundCaseVariable" : true,
68+
"UseShorthandTypeNames" : true,
69+
"UseSingleLinePropertyGetter" : true,
70+
"UseSynthesizedInitializer" : true,
71+
"UseTripleSlashForDocumentationComments" : true,
72+
"UseWhereClausesInForLoops" : true,
73+
"ValidateDocumentationComments" : true
74+
},
75+
"spacesAroundRangeFormationOperators" : false,
76+
"spacesBeforeEndOfLineComments" : 2,
77+
"tabWidth" : 4,
78+
"version" : 1
79+
}

.yamllint.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: default
2+
3+
rules:
4+
line-length: false
5+
document-start: false
6+
truthy:
7+
check-keys: false

DNSecure/DNSecureApp.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by Kenta Kubo on 7/1/20.
66
//
77

8-
import os.log
98
import SwiftUI
9+
import os.log
1010

1111
let logger = Logger()
1212

DNSecure/Extensions/NEOnDemandRuleInterfaceType+CustomStringConvertible.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ extension NEOnDemandRuleInterfaceType: @retroactive CustomStringConvertible {
1313
case .any:
1414
return "Any"
1515
#if os(macOS)
16-
case .ethernet:
17-
return "Ethernet"
16+
case .ethernet:
17+
return "Ethernet"
1818
#endif
1919
case .wiFi:
2020
return "Wi-Fi"
2121
#if os(iOS)
22-
case .cellular:
23-
return "Cellular"
22+
case .cellular:
23+
return "Cellular"
2424
#endif
2525
default:
2626
return "Unknown"

DNSecure/Models/Presets.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ enum Presets {
126126
configuration: .dnsOverTLS(
127127
DoTConfiguration(
128128
servers: [
129-
"116.202.176.26",
129+
"116.202.176.26"
130130
],
131131
serverName: "dot.libredns.gr"
132132
)
@@ -137,7 +137,7 @@ enum Presets {
137137
configuration: .dnsOverHTTPS(
138138
DoHConfiguration(
139139
servers: [
140-
"116.202.176.26",
140+
"116.202.176.26"
141141
],
142142
serverURL: URL(string: "https://doh.libredns.gr/dns-query")
143143
)
@@ -148,7 +148,7 @@ enum Presets {
148148
configuration: .dnsOverHTTPS(
149149
DoHConfiguration(
150150
servers: [
151-
"116.202.176.26",
151+
"116.202.176.26"
152152
],
153153
serverURL: URL(string: "https://doh.libredns.gr/ads")
154154
)

DNSecure/Models/Resolver.swift

+11-10
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ enum Configuration {
4848

4949
func toDNSSettings() -> NEDNSSettings {
5050
switch self {
51-
case let .dnsOverTLS(configuration):
51+
case .dnsOverTLS(let configuration):
5252
return configuration.toDNSSettings()
53-
case let .dnsOverHTTPS(configuration):
53+
case .dnsOverHTTPS(let configuration):
5454
return configuration.toDNSSettings()
5555
}
5656
}
@@ -87,10 +87,10 @@ extension Configuration: Codable {
8787
var container = encoder.container(keyedBy: Self.CodingKeys.self)
8888

8989
switch self {
90-
case let .dnsOverTLS(configuration):
90+
case .dnsOverTLS(let configuration):
9191
try container.encode(Self.Base.dnsOverTLS, forKey: .base)
9292
try container.encode(configuration, forKey: .dotConfiguration)
93-
case let .dnsOverHTTPS(configuration):
93+
case .dnsOverHTTPS(let configuration):
9494
try container.encode(Self.Base.dnsOverHTTPS, forKey: .base)
9595
try container.encode(configuration, forKey: .dohConfiguration)
9696
}
@@ -200,10 +200,11 @@ extension Resolver: Codable {
200200
self.id = try container.decode(UUID.self, forKey: .id)
201201
self.name = try container.decode(String.self, forKey: .name)
202202
self.configuration = try container.decode(Configuration.self, forKey: .configuration)
203-
self.onDemandRules = try container.decodeIfPresent(
204-
[OnDemandRule].self,
205-
forKey: .onDemandRules
206-
) ?? []
203+
self.onDemandRules =
204+
try container.decodeIfPresent(
205+
[OnDemandRule].self,
206+
forKey: .onDemandRules
207+
) ?? []
207208
}
208209
}
209210

@@ -218,7 +219,7 @@ extension Resolvers {
218219
extension Resolvers: @retroactive RawRepresentable {
219220
public init?(rawValue: String) {
220221
guard let data = rawValue.data(using: .utf8),
221-
let result = try? JSONDecoder().decode(Self.self, from: data)
222+
let result = try? JSONDecoder().decode(Self.self, from: data)
222223
else {
223224
return nil
224225
}
@@ -227,7 +228,7 @@ extension Resolvers: @retroactive RawRepresentable {
227228

228229
public var rawValue: String {
229230
guard let data = try? JSONEncoder().encode(self),
230-
let result = String(data: data, encoding: .utf8)
231+
let result = String(data: data, encoding: .utf8)
231232
else {
232233
return "[]"
233234
}

DNSecure/Views/ContentView.swift

+10-6
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ struct ContentView {
9090
manager.onDemandRules = server.onDemandRules.toNEOnDemandRules()
9191
manager.saveToPreferences { saveError in
9292
if let saveError = saveError as NSError? {
93-
guard saveError.domain != "NEConfigurationErrorDomain"
94-
|| saveError.code != 9 else {
93+
guard
94+
saveError.domain != "NEConfigurationErrorDomain"
95+
|| saveError.code != 9
96+
else {
9597
// Nothing was changed
9698
return
9799
}
@@ -187,8 +189,9 @@ extension ContentView: View {
187189
// FIXME: This is a workaround for self.$severs[i].
188190
// That cannot save settings as soon as it is modified.
189191
guard let id = self.usedID,
190-
let uuid = UUID(uuidString: id),
191-
let server = self.servers.find(by: uuid) else {
192+
let uuid = UUID(uuidString: id),
193+
let server = self.servers.find(by: uuid)
194+
else {
192195
return
193196
}
194197
self.saveSettings(of: server)
@@ -263,8 +266,9 @@ extension ContentView: View {
263266
// FIXME: This is a workaround for self.$severs[i].
264267
// That cannot save settings as soon as it is modified.
265268
guard let id = self.usedID,
266-
let uuid = UUID(uuidString: id),
267-
let server = self.servers.find(by: uuid) else {
269+
let uuid = UUID(uuidString: id),
270+
let server = self.servers.find(by: uuid)
271+
else {
268272
return
269273
}
270274
self.saveSettings(of: server)

DNSecure/Views/RestorationView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct RestorationView {
1111
@Environment(\.dismiss) private var dismiss
1212
@State private var selection = Set<Resolver>()
1313
@State private var keyword = ""
14-
let onAdd: (Set<Resolver>) -> ()
14+
let onAdd: (Set<Resolver>) -> Void
1515

1616
private var servers: Resolvers {
1717
guard !self.keyword.isEmpty else { return Presets.servers }

DNSecure/Views/RuleView.swift

+15-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ extension RuleView: View {
3636
} header: {
3737
Text("Interface Type Match")
3838
} footer: {
39-
Text("If the current primary network interface is of this type and all of the other conditions in the rule match, then the rule matches.")
39+
Text(
40+
"If the current primary network interface is of this type and all of the other conditions in the rule match, then the rule matches."
41+
)
4042
}
4143

4244
if self.rule.interfaceType.ssidIsUsed {
@@ -65,7 +67,9 @@ extension RuleView: View {
6567
Text("SSID Match")
6668
}
6769
} footer: {
68-
Text("If the Service Set Identifier (SSID) of the current primary connected network matches one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
70+
Text(
71+
"If the Service Set Identifier (SSID) of the current primary connected network matches one of the strings in this array and all of the other conditions in the rule match, then the rule matches."
72+
)
6973
}
7074
}
7175

@@ -92,7 +96,9 @@ extension RuleView: View {
9296
Text("DNS Search Domain Match")
9397
}
9498
} footer: {
95-
Text("If the current default search domain is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
99+
Text(
100+
"If the current default search domain is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches."
101+
)
96102
}
97103

98104
Section {
@@ -118,7 +124,9 @@ extension RuleView: View {
118124
Text("DNS Server Address Match")
119125
}
120126
} footer: {
121-
Text("If each of the current default DNS servers is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches.")
127+
Text(
128+
"If each of the current default DNS servers is equal to one of the strings in this array and all of the other conditions in the rule match, then the rule matches."
129+
)
122130
}
123131

124132
Section {
@@ -132,7 +140,9 @@ extension RuleView: View {
132140
} header: {
133141
Text("Probe URL Match")
134142
} footer: {
135-
Text("If a request sent to this URL results in a HTTP 200 OK response and all of the other conditions in the rule match, then the rule matches. If you don't want to use this rule, leave it empty.")
143+
Text(
144+
"If a request sent to this URL results in a HTTP 200 OK response and all of the other conditions in the rule match, then the rule matches. If you don't want to use this rule, leave it empty."
145+
)
136146
}
137147
}
138148
.navigationTitle(self.rule.name)

DNSecureTests/DNSecureTests.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
//
77

88
import XCTest
9+
910
@testable import DNSecure
1011

1112
class DNSecureTests: XCTestCase {
12-
1313
override func setUpWithError() throws {
1414
// Put setup code here. This method is called before the invocation of each test method in the class.
1515
}
@@ -29,5 +29,4 @@ class DNSecureTests: XCTestCase {
2929
// Put the code you want to measure the time of here.
3030
}
3131
}
32-
3332
}

DNSecureUITests/DNSecureUITests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import XCTest
99

1010
class DNSecureUITests: XCTestCase {
11-
1211
override func setUpWithError() throws {
1312
// Put setup code here. This method is called before the invocation of each test method in the class.
1413

Package.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// This file is automatically generated.
55
// Do not edit it by hand because the contents will be replaced.
66

7-
import PackageDescription
87
import AppleProductTypes
8+
import PackageDescription
99

1010
let package = Package(
1111
name: "DNSecure",
@@ -24,13 +24,13 @@ let package = Package(
2424
accentColor: .asset("AccentColor"),
2525
supportedDeviceFamilies: [
2626
.pad,
27-
.phone
27+
.phone,
2828
],
2929
supportedInterfaceOrientations: [
3030
.portrait,
3131
.landscapeRight,
3232
.landscapeLeft,
33-
.portraitUpsideDown(.when(deviceFamilies: [.pad]))
33+
.portraitUpsideDown(.when(deviceFamilies: [.pad])),
3434
],
3535
appCategory: .utilities
3636
)
@@ -46,6 +46,6 @@ let package = Package(
4646
"DNSecure"
4747
],
4848
path: "DNSecureTests"
49-
)
49+
),
5050
]
5151
)

0 commit comments

Comments
 (0)