Skip to content

Commit 40512d3

Browse files
authored
Reenable Swift formatting checker (#561)
1 parent 165ce8f commit 40512d3

322 files changed

Lines changed: 7109 additions & 5543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/pull_request.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ jobs:
1313
with:
1414
# Not API stable package (yet)
1515
api_breakage_check_enabled: false
16-
# FIXME: Something is off with the format task and it gets "stuck", need to investigate
17-
format_check_enabled: false
16+
format_check_enabled: true
1817
license_header_check_project_name: Swift.org
1918
# Since we need JAVA_HOME to be set up for building the project and depending on a different workflow won't
2019
# give us that, we disable the checking and make a separate job that performs docs validation

‎.swift-format‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version" : 1,
3+
"indentation" : {
4+
"spaces" : 2
5+
},
6+
"tabWidth" : 2,
7+
"fileScopedDeclarationPrivacy" : {
8+
"accessLevel" : "private"
9+
},
10+
"spacesAroundRangeFormationOperators" : false,
11+
"indentConditionalCompilationBlocks" : false,
12+
"indentSwitchCaseLabels" : false,
13+
"lineBreakAroundMultilineExpressionChainComponents" : false,
14+
"lineBreakBeforeControlFlowKeywords" : false,
15+
"lineBreakBeforeEachArgument" : true,
16+
"lineBreakBeforeEachGenericRequirement" : true,
17+
"lineLength" : 180,
18+
"maximumBlankLines" : 2,
19+
"spacesBeforeEndOfLineComments" : 1,
20+
"respectsExistingLineBreaks" : true,
21+
"prioritizeKeepingFunctionOutputTogether" : true,
22+
"rules" : {
23+
"AllPublicDeclarationsHaveDocumentation" : false,
24+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
25+
"AlwaysUseLowerCamelCase" : false,
26+
"AmbiguousTrailingClosureOverload" : true,
27+
"BeginDocumentationCommentWithOneLineSummary" : false,
28+
"DoNotUseSemicolons" : true,
29+
"DontRepeatTypeInStaticProperties" : true,
30+
"FileScopedDeclarationPrivacy" : true,
31+
"FullyIndirectEnum" : true,
32+
"GroupNumericLiterals" : true,
33+
"IdentifiersMustBeASCII" : true,
34+
"NeverForceUnwrap" : false,
35+
"NeverUseForceTry" : false,
36+
"NeverUseImplicitlyUnwrappedOptionals" : false,
37+
"NoAccessLevelOnExtensionDeclaration" : true,
38+
"NoAssignmentInExpressions" : true,
39+
"NoBlockComments" : false,
40+
"NoCasesWithOnlyFallthrough" : true,
41+
"NoEmptyTrailingClosureParentheses" : true,
42+
"NoLabelsInCasePatterns" : true,
43+
"NoLeadingUnderscores" : false,
44+
"NoParensAroundConditions" : true,
45+
"NoVoidReturnOnFunctionSignature" : true,
46+
"OmitExplicitReturns" : true,
47+
"OneCasePerLine" : true,
48+
"OneVariableDeclarationPerLine" : true,
49+
"OnlyOneTrailingClosureArgument" : true,
50+
"OrderedImports" : true,
51+
"ReplaceForEachWithForLoop" : true,
52+
"ReturnVoidInsteadOfEmptyTuple" : true,
53+
"UseEarlyExits" : false,
54+
"UseExplicitNilCheckInConditions" : false,
55+
"UseLetInEveryBoundCaseVariable" : false,
56+
"UseShorthandTypeNames" : true,
57+
"UseSingleLinePropertyGetter" : false,
58+
"UseSynthesizedInitializer" : false,
59+
"UseTripleSlashForDocumentationComments" : true,
60+
"UseWhereClausesInForLoops" : false,
61+
"ValidateDocumentationComments" : false
62+
}
63+
}

‎Benchmarks/Benchmarks/JavaApiCallBenchmarks/JavaApiCallBenchmarks.swift‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414

1515
import Benchmark
1616
import Foundation
17-
import SwiftJava
1817
import JavaNet
18+
import SwiftJava
1919

2020
@MainActor let benchmarks = {
21-
var jvm: JavaVirtualMachine {
22-
get throws {
23-
try .shared()
24-
}
21+
var jvm: JavaVirtualMachine {
22+
get throws {
23+
try .shared()
2524
}
26-
Benchmark("Simple call to Java library") { benchmark in
27-
for _ in benchmark.scaledIterations {
28-
let environment = try jvm.environment()
25+
}
26+
Benchmark("Simple call to Java library") { benchmark in
27+
for _ in benchmark.scaledIterations {
28+
let environment = try jvm.environment()
2929

30-
let urlConnectionClass = try JavaClass<URLConnection>(environment: environment)
31-
blackHole(urlConnectionClass.getDefaultAllowUserInteraction())
32-
}
30+
let urlConnectionClass = try JavaClass<URLConnection>(environment: environment)
31+
blackHole(urlConnectionClass.getDefaultAllowUserInteraction())
3332
}
33+
}
3434
}

‎Benchmarks/Package.swift‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// swift-tools-version: 6.0
22

3-
import PackageDescription
43
import Foundation
4+
import PackageDescription
55

66
// Note: the JAVA_HOME environment variable must be set to point to where
77
// Java is installed, e.g.,
@@ -58,13 +58,15 @@ func getJavaHomeFromPath() -> String? {
5858
guard task.terminationStatus == 0 else { return nil }
5959

6060
let data = pipe.fileHandleForReading.readDataToEndOfFile()
61-
guard let javaPath = String(data: data, encoding: .utf8)?
62-
.trimmingCharacters(in: .whitespacesAndNewlines),
61+
guard
62+
let javaPath = String(data: data, encoding: .utf8)?
63+
.trimmingCharacters(in: .whitespacesAndNewlines),
6364
!javaPath.isEmpty
6465
else { return nil }
6566

6667
let resolved = URL(fileURLWithPath: javaPath).resolvingSymlinksInPath()
67-
return resolved
68+
return
69+
resolved
6870
.deletingLastPathComponent()
6971
.deletingLastPathComponent()
7072
.path
@@ -76,12 +78,12 @@ let javaHome = findJavaHome()
7678

7779
let javaIncludePath = "\(javaHome)/include"
7880
#if os(Linux)
79-
let javaPlatformIncludePath = "\(javaIncludePath)/linux"
81+
let javaPlatformIncludePath = "\(javaIncludePath)/linux"
8082
#elseif os(macOS)
81-
let javaPlatformIncludePath = "\(javaIncludePath)/darwin"
83+
let javaPlatformIncludePath = "\(javaIncludePath)/darwin"
8284
#else
83-
// TODO: Handle windows as well
84-
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
85+
// TODO: Handle windows as well
86+
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
8587
#endif
8688

8789
let package = Package(

0 commit comments

Comments
 (0)