Skip to content

Commit 6a50972

Browse files
committed
Introduce addNoLanguageDiagnostic
1 parent 5cb12c4 commit 6a50972

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

lib/init-action.js

Lines changed: 14 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import {
2626
parseUserConfig,
2727
UserConfig,
2828
} from "./config/db-config";
29-
import { addDiagnostic, makeTelemetryDiagnostic } from "./diagnostics";
29+
import {
30+
addNoLanguageDiagnostic,
31+
makeTelemetryDiagnostic,
32+
} from "./diagnostics";
3033
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
3134
import { EnvVar } from "./environment";
3235
import * as errorMessages from "./error-messages";
@@ -1408,11 +1411,8 @@ async function logGitVersionTelemetry(
14081411
gitVersion: GitVersionInfo,
14091412
): Promise<void> {
14101413
if (config.languages.length > 0) {
1411-
addDiagnostic(
1414+
addNoLanguageDiagnostic(
14121415
config,
1413-
// Arbitrarily choose the first language. We could also choose all languages, but that
1414-
// increases the risk of misinterpreting the data.
1415-
config.languages[0],
14161416
makeTelemetryDiagnostic(
14171417
"codeql-action/git-version-telemetry",
14181418
"Git version telemetry",
@@ -1438,11 +1438,8 @@ async function logGeneratedFilesTelemetry(
14381438
return;
14391439
}
14401440

1441-
addDiagnostic(
1441+
addNoLanguageDiagnostic(
14421442
config,
1443-
// Arbitrarily choose the first language. We could also choose all languages, but that
1444-
// increases the risk of misinterpreting the data.
1445-
config.languages[0],
14461443
makeTelemetryDiagnostic(
14471444
"codeql-action/generated-files-telemetry",
14481445
"Generated files telemetry",

src/diagnostics.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ export function addDiagnostic(
117117
}
118118
}
119119

120+
/** Adds a diagnostic that is not specific to any language. */
121+
export function addNoLanguageDiagnostic(
122+
config: Config,
123+
diagnostic: DiagnosticMessage,
124+
) {
125+
addDiagnostic(
126+
config,
127+
// Arbitrarily choose the first language. We could also choose all languages, but that
128+
// increases the risk of misinterpreting the data.
129+
config.languages[0],
130+
diagnostic,
131+
);
132+
}
133+
120134
/**
121135
* Writes the given diagnostic to the database.
122136
*

src/init-action.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from "./dependency-caching";
3232
import {
3333
addDiagnostic,
34+
addNoLanguageDiagnostic,
3435
flushDiagnostics,
3536
logUnwrittenDiagnostics,
3637
makeDiagnostic,
@@ -374,11 +375,8 @@ async function run(startedAt: Date) {
374375
});
375376

376377
if (repositoryPropertiesResult.isFailure()) {
377-
addDiagnostic(
378+
addNoLanguageDiagnostic(
378379
config,
379-
// Arbitrarily choose the first language. We could also choose all languages, but that
380-
// increases the risk of misinterpreting the data.
381-
config.languages[0],
382380
makeTelemetryDiagnostic(
383381
"codeql-action/repository-properties-load-failure",
384382
"Failed to load repository properties",
@@ -451,11 +449,8 @@ async function run(startedAt: Date) {
451449

452450
// Log CodeQL download telemetry, if appropriate
453451
if (toolsDownloadStatusReport) {
454-
addDiagnostic(
452+
addNoLanguageDiagnostic(
455453
config,
456-
// Arbitrarily choose the first language. We could also choose all languages, but that
457-
// increases the risk of misinterpreting the data.
458-
config.languages[0],
459454
makeTelemetryDiagnostic(
460455
"codeql-action/bundle-download-telemetry",
461456
"CodeQL bundle download telemetry",
@@ -853,11 +848,8 @@ async function recordZstdAvailability(
853848
config: configUtils.Config,
854849
zstdAvailability: ZstdAvailability,
855850
) {
856-
addDiagnostic(
851+
addNoLanguageDiagnostic(
857852
config,
858-
// Arbitrarily choose the first language. We could also choose all languages, but that
859-
// increases the risk of misinterpreting the data.
860-
config.languages[0],
861853
makeTelemetryDiagnostic(
862854
"codeql-action/zstd-availability",
863855
"Zstandard availability",

0 commit comments

Comments
 (0)