Skip to content

Commit b3e76d6

Browse files
committed
Swift: Drop support for plaintext diagnostics (and helpLinks).
The recommended option is Markdown diagnostics, and we have already migrated everything to emit them. The empty help link we're currently emitting everywhere is a bug.
1 parent a1beaa6 commit b3e76d6

File tree

11 files changed

+5
-55
lines changed

11 files changed

+5
-55
lines changed

swift/integration-tests/linux-only/autobuilder/unsupported-os/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "Currently, `autobuild` for Swift analysis is only supported on macOS.\n\n[Change the Actions runner][1] to run on macOS.\n\nYou may be able to run analysis on Linux by setting up a [manual build command][2].\n\n[1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on\n[2]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/failure/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "`autobuild` failed to run the detected build command:\n\n```\n/usr/bin/xcodebuild build -project <test-root-directory>/hello-failure.xcodeproj -target hello-failure CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO\n```\n\nSet up a [manual build command][1] or [check the logs of the autobuild step][2].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language\n[2]: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/using-workflow-run-logs",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/no-build-system/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "`autobuild` could not detect an Xcode project or workspace.\n\nSet up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/no-swift-with-spm/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "A Swift package was detected, but no viable Xcode target was found.\n\nSwift Package Manager builds are not currently supported by `autobuild`. Set up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/no-swift/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "All targets found within Xcode projects or workspaces either contain no Swift source files, or are tests.\n\nTo analyze a custom set of source files, set up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/no-xcode-with-spm/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "A Swift package was detected, but no viable Xcode target was found.\n\nSwift Package Manager builds are not currently supported by `autobuild`. Set up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/only-tests-with-spm/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "A Swift package was detected, but no viable Xcode target was found.\n\nSwift Package Manager builds are not currently supported by `autobuild`. Set up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/integration-tests/osx-only/autobuilder/only-tests/diagnostics.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"helpLinks": [
3-
""
4-
],
52
"markdownMessage": "All targets found within Xcode projects or workspaces either contain no Swift source files, or are tests.\n\nTo analyze a custom set of source files, set up a [manual build command][1].\n\n[1]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
63
"severity": "error",
74
"source": {

swift/logging/SwiftDiagnostics.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ nlohmann::json SwiftDiagnostic::json(const std::chrono::system_clock::time_point
4040
{"telemetry", has(Visibility::telemetry)},
4141
}},
4242
{"severity", severityToString(severity)},
43-
{"helpLinks", std::vector<std::string_view>(absl::StrSplit(helpLinks, ' '))},
44-
{format == Format::markdown ? "markdownMessage" : "plaintextMessage",
45-
absl::StrCat(message, "\n\n", action)},
43+
{"markdownMessage", absl::StrCat(message, "\n\n", action)},
4644
{"timestamp", fmt::format("{:%FT%T%z}", timestamp)},
4745
};
4846
if (location) {

swift/logging/SwiftDiagnostics.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ struct SwiftDiagnosticsLocation {
3535
// These are internally stored into a map on id's. A specific error log can use binlog's category
3636
// as id, which will then be used to recover the diagnostic source while dumping.
3737
struct SwiftDiagnostic {
38-
enum class Format {
39-
plaintext,
40-
markdown,
41-
};
42-
4338
enum class Visibility : unsigned char {
4439
none = 0b000,
4540
statusPage = 0b001,
@@ -56,31 +51,18 @@ struct SwiftDiagnostic {
5651
error,
5752
};
5853

59-
// wrapper for passing optional help links to constructor
60-
struct HelpLinks {
61-
std::string_view value;
62-
};
63-
6454
static constexpr std::string_view extractorName = "swift";
6555

6656
std::string_view id;
6757
std::string_view name;
6858
std::string_view action;
6959

70-
Format format{Format::markdown};
7160
Visibility visibility{Visibility::all};
7261
Severity severity{Severity::error};
7362

74-
// space separated if more than 1. Not a vector to allow constexpr
75-
// TODO(C++20) with vector going constexpr this can be turned to `std::vector<std::string_view>`
76-
std::string_view helpLinks{""};
77-
7863
std::optional<SwiftDiagnosticsLocation> location{};
7964

80-
// notice help links are really required only for plaintext messages, otherwise they should be
81-
// directly embedded in the markdown message
82-
// optional arguments can be any of HelpLinks, Severity, Visibility or Format to set the
83-
// corresponding field
65+
// optional arguments can be either Severity or Visibility to set the corresponding field.
8466
// TODO(C++20) this constructor won't really be necessary anymore with designated initializers
8567
template <typename... OptionalArgs>
8668
constexpr SwiftDiagnostic(std::string_view id,
@@ -91,10 +73,9 @@ struct SwiftDiagnostic {
9173
(setOptionalArg(optionalArgs), ...);
9274
}
9375

94-
// create a JSON diagnostics for this source with the given `timestamp` and `message`
95-
// Depending on format, either a plaintextMessage or markdownMessage is used that includes both
96-
// the message and the action to take. The id is used to construct the source id in the form
97-
// `swift/<prog name>/<id>`
76+
// create a JSON diagnostics for this source with the given `timestamp` and Markdown `message`
77+
// A markdownMessage is emitted that includes both the message and the action to take. The id is
78+
// used to construct the source id in the form `swift/<prog name>/<id>`
9879
nlohmann::json json(const std::chrono::system_clock::time_point& timestamp,
9980
std::string_view message) const;
10081

@@ -114,8 +95,6 @@ struct SwiftDiagnostic {
11495
private:
11596
bool has(Visibility v) const;
11697

117-
constexpr void setOptionalArg(HelpLinks h) { helpLinks = h.value; }
118-
constexpr void setOptionalArg(Format f) { format = f; }
11998
constexpr void setOptionalArg(Visibility v) { visibility = v; }
12099
constexpr void setOptionalArg(Severity s) { severity = s; }
121100

0 commit comments

Comments
 (0)