Skip to content

Commit 96bc9b1

Browse files
committed
Collect all invalid entries in summary
1 parent bed32f2 commit 96bc9b1

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

org/allPRs.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export const featureFlagAsanaLink = async () => {
301301
if (changedFiles.length === 0) return;
302302

303303
const asanaTaskUrlRegex = /^\/\/\/\s*https:\/\/app\.asana\.com\/1\/137249556945\/project\/1211834678943996\/task\/\d+(\?\S*)?\s*$/;
304+
const casesWithInvalidLinks: { file: string; caseName: string }[] = [];
304305

305306
for (const file of changedFiles) {
306307
const structuredDiff = await danger.git.structuredDiffForFile(file);
@@ -347,7 +348,8 @@ export const featureFlagAsanaLink = async () => {
347348

348349
// Only check added lines for new case declarations
349350
if (change.type !== "add") continue;
350-
if (!/^\s*case\s+\w+/.test(content)) continue;
351+
const caseMatch = content.match(/^\s*case\s+(\w+)/);
352+
if (!caseMatch) continue;
351353

352354
// Found an added case line – walk upward through added comment lines looking for the Asana URL
353355
let foundAsanaLink = false;
@@ -363,12 +365,16 @@ export const featureFlagAsanaLink = async () => {
363365
}
364366

365367
if (!foundAsanaLink) {
366-
warn(`New FeatureFlag case in \`${file}\` is missing a valid Feature Flag link in the comment.\nAdd a task in https://app.asana.com/1/137249556945/project/1211834678943996/list/1211838475578067 and use it in the comment.`);
367-
return;
368+
casesWithInvalidLinks.push({ file, caseName: caseMatch[1] });
368369
}
369370
}
370371
}
371372
}
373+
374+
if (casesWithInvalidLinks.length > 0) {
375+
const caseList = casesWithInvalidLinks.map(c => `- \`${c.caseName}\` in \`${c.file}\``).join("\n");
376+
warn(`New FeatureFlag cases are missing a valid Feature Flag link in the comment:\n${caseList}\nAdd a task in https://app.asana.com/1/137249556945/project/1211834678943996/list/1211838475578067 and use it in the comment.`);
377+
}
372378
}
373379

374380
// Default run

tests/featureFlagAsanaLink.allPRs.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,19 @@ describe("Feature flag Asana link checks", () => {
268268
await featureFlagAsanaLink()
269269
expect(dm.warn).toHaveBeenCalled()
270270
})
271+
272+
it("reports all cases missing links in a single warning", async () => {
273+
dm.rawDiff = `@@ -10,6 +10,10 @@ enum FeatureFlag {
274+
+ case firstFeature
275+
+ /// https://app.asana.com/1/137249556945/project/1211834678943996/task/123456789
276+
+ case validFeature
277+
+ case secondFeature`
278+
279+
await featureFlagAsanaLink()
280+
expect(dm.warn).toHaveBeenCalledTimes(1)
281+
const message = dm.warn.mock.calls[0][0]
282+
expect(message).toContain("firstFeature")
283+
expect(message).toContain("secondFeature")
284+
expect(message).not.toContain("validFeature")
285+
})
271286
})

0 commit comments

Comments
 (0)