Skip to content

Commit 0f7d4be

Browse files
committed
Combine nested conditionals into one if-statement
1 parent 8b8d89d commit 0f7d4be

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

Plugins/Swift-DocC Convert/SwiftDocCConvert.swift

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,24 @@ import PackagePlugin
6969
customSymbolGraphOptions: parsedArguments.symbolGraphArguments
7070
)
7171

72-
if try FileManager.default.contentsOfDirectory(atPath: symbolGraphs.targetSymbolGraphsDirectory.path).isEmpty {
73-
// This target did not produce any symbol graphs. Let's check if it has a
74-
// DocC catalog.
72+
if target.doccCatalogPath == nil,
73+
try FileManager.default.contentsOfDirectory(atPath: symbolGraphs.targetSymbolGraphsDirectory.path).isEmpty
74+
{
75+
// This target did not produce any symbol graphs and has no DocC catalog.
76+
let message = """
77+
'\(target.name)' does not contain any documentable symbols or a \
78+
DocC catalog and will not produce documentation
79+
"""
7580

76-
guard target.doccCatalogPath != nil else {
77-
let message = """
78-
'\(target.name)' does not contain any documentable symbols or a \
79-
DocC catalog and will not produce documentation
80-
"""
81-
82-
if swiftSourceModuleTargets.count > 1 {
83-
// We're building multiple targets, just throw a warning for this
84-
// one target that does not produce documentation.
85-
Diagnostics.warning(message)
86-
} else {
87-
// This is the only target being built so throw an error
88-
Diagnostics.error(message)
89-
}
90-
return
81+
if swiftSourceModuleTargets.count > 1 {
82+
// We're building multiple targets, just emit a warning for this
83+
// one target that does not produce documentation.
84+
Diagnostics.warning(message)
85+
} else {
86+
// This is the only target being built so emit an error
87+
Diagnostics.error(message)
9188
}
89+
return
9290
}
9391

9492
// Construct the output path for the generated DocC archive

0 commit comments

Comments
 (0)