Skip to content

Commit e7f67e2

Browse files
committed
Redefine shouldPerformDiffInformedAnalysis()
This commit renames the original shouldPerformDiffInformedAnalysis(), which returns `PullRequestBranches | undefined`, to getDiffInformedAnalysisBranches(). It also adds a new shouldPerformDiffInformedAnalysis() function that returns boolean. Separating these two functions makes it clear what the intended uses and return values should be for each.
1 parent 71ab101 commit e7f67e2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/analyze-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { getCodeQL } from "./codeql";
2222
import { Config, getConfig } from "./config-utils";
2323
import { uploadDatabases } from "./database-upload";
2424
import { uploadDependencyCaches } from "./dependency-caching";
25-
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
25+
import { getDiffInformedAnalysisBranches } from "./diff-informed-analysis-utils";
2626
import { EnvVar } from "./environment";
2727
import { Features } from "./feature-flags";
2828
import { Language } from "./languages";
@@ -270,7 +270,7 @@ async function run() {
270270
logger,
271271
);
272272

273-
const branches = await shouldPerformDiffInformedAnalysis(
273+
const branches = await getDiffInformedAnalysisBranches(
274274
codeql,
275275
features,
276276
logger,

src/diff-informed-analysis-utils.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,26 @@ function getPullRequestBranches(): PullRequestBranches | undefined {
4242

4343
/**
4444
* Check if the action should perform diff-informed analysis.
45+
*/
46+
export async function shouldPerformDiffInformedAnalysis(
47+
codeql: CodeQL,
48+
features: FeatureEnablement,
49+
logger: Logger,
50+
): Promise<boolean> {
51+
return (
52+
(await getDiffInformedAnalysisBranches(codeql, features, logger)) !==
53+
undefined
54+
);
55+
}
56+
57+
/**
58+
* Get the branches to use for diff-informed analysis.
4559
*
4660
* @returns If the action should perform diff-informed analysis, return
4761
* the base and head branches that should be used to compute the diff ranges.
4862
* Otherwise return `undefined`.
4963
*/
50-
export async function shouldPerformDiffInformedAnalysis(
64+
export async function getDiffInformedAnalysisBranches(
5165
codeql: CodeQL,
5266
features: FeatureEnablement,
5367
logger: Logger,

0 commit comments

Comments
 (0)