Skip to content

Commit eda4878

Browse files
committed
Only pass --new-analysis-summary if it is not default behavior
1 parent eeaea14 commit eda4878

File tree

9 files changed

+40
-49
lines changed

9 files changed

+40
-49
lines changed

lib/codeql.js

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

lib/codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js

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

lib/codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-features.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-features.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
makeVersionInfo,
3030
createTestConfig,
3131
} from "./testing-utils";
32+
import { ToolsFeature } from "./tools-features";
3233
import * as util from "./util";
3334
import { initializeEnvironment } from "./util";
3435

@@ -772,33 +773,34 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
772773

773774
const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
774775
{
775-
codeqlVersion: "2.15.0",
776+
codeqlVersion: makeVersionInfo("2.15.0", {
777+
[ToolsFeature.AnalysisSummaryV2IsDefault]: true,
778+
}),
776779
githubVersion: {
777780
type: util.GitHubVariant.DOTCOM,
778781
},
779-
flagPassed: true,
782+
flagPassed: false,
780783
negativeFlagPassed: false,
781784
},
782785
{
783-
codeqlVersion: "2.15.0",
786+
codeqlVersion: makeVersionInfo("2.15.0"),
784787
githubVersion: {
785-
type: util.GitHubVariant.GHES,
786-
version: "3.9.0",
788+
type: util.GitHubVariant.DOTCOM,
787789
},
788790
flagPassed: true,
789791
negativeFlagPassed: false,
790792
},
791793
{
792-
codeqlVersion: "2.15.0",
794+
codeqlVersion: makeVersionInfo("2.15.0"),
793795
githubVersion: {
794796
type: util.GitHubVariant.GHES,
795-
version: "3.8.6",
797+
version: "3.9.0",
796798
},
797-
flagPassed: false,
798-
negativeFlagPassed: true,
799+
flagPassed: true,
800+
negativeFlagPassed: false,
799801
},
800802
{
801-
codeqlVersion: "2.14.6",
803+
codeqlVersion: makeVersionInfo("2.14.6"),
802804
githubVersion: {
803805
type: util.GitHubVariant.DOTCOM,
804806
},
@@ -819,14 +821,12 @@ for (const {
819821
: negativeFlagPassed
820822
? "--no-new-analysis-summary"
821823
: "nothing"
822-
} for CodeQL CLI v${codeqlVersion} and ${
824+
} for CodeQL version ${JSON.stringify(codeqlVersion)} and ${
823825
util.GitHubVariant[githubVersion.type]
824826
} ${githubVersion.version ? ` ${githubVersion.version}` : ""}`, async (t) => {
825827
const runnerConstructorStub = stubToolRunnerConstructor();
826828
const codeqlObject = await codeql.getCodeQLForTesting();
827-
sinon
828-
.stub(codeqlObject, "getVersion")
829-
.resolves(makeVersionInfo(codeqlVersion));
829+
sinon.stub(codeqlObject, "getVersion").resolves(codeqlVersion);
830830
// safeWhich throws because of the test CodeQL object.
831831
sinon.stub(safeWhich, "safeWhich").resolves("");
832832
await codeqlObject.databaseInterpretResults(

src/codeql.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -890,20 +890,16 @@ export async function getCodeQLForCmd(
890890
codeqlArgs.push("--no-sarif-include-diagnostics");
891891
}
892892
if (
893-
// Analysis summary v2 links to the status page, so check the GHES version we're running on
894-
// supports the status page.
895-
(config.gitHubVersion.type !== util.GitHubVariant.GHES ||
896-
semver.gte(config.gitHubVersion.version, "3.9.0")) &&
897893
(await util.codeQlVersionAbove(
898894
this,
899895
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
900-
))
896+
)) &&
897+
!isSupportedToolsFeature(
898+
await this.getVersion(),
899+
ToolsFeature.AnalysisSummaryV2IsDefault,
900+
)
901901
) {
902902
codeqlArgs.push("--new-analysis-summary");
903-
} else if (
904-
await util.codeQlVersionAbove(this, CODEQL_VERSION_ANALYSIS_SUMMARY_V2)
905-
) {
906-
codeqlArgs.push("--no-new-analysis-summary");
907903
}
908904
codeqlArgs.push(databasePath);
909905
if (querySuitePaths) {

src/tools-features.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { VersionInfo } from "./codeql";
22

33
export enum ToolsFeature {
4+
AnalysisSummaryV2IsDefault = "analysisSummaryV2Default",
45
BuildModeOption = "buildModeOption",
56
IndirectTracingSupportsStaticBinaries = "indirectTracingSupportsStaticBinaries",
67
InformsAboutUnsupportedPathFilters = "informsAboutUnsupportedPathFilters",

0 commit comments

Comments
 (0)