treewide: make less webhook-centric
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ifab58fcb523549ca9cb83dc8467be51e6a6a6964
This commit is contained in:
parent
d8c09eeefa
commit
374408834b
9 changed files with 479 additions and 39 deletions
|
|
@ -15,7 +15,9 @@ const RISKY_FILE_PATTERN =
|
|||
|
||||
const DOC_FILE_PATTERN = /\.(md|mdx|txt|rst|adoc)$|^(README|CHANGELOG|LICENSE|CONTRIBUTING)/i;
|
||||
|
||||
function categorizeFiles(files: { filename: string; additions: number; deletions: number; changes: number }[]) {
|
||||
function categorizeFiles(
|
||||
files: { filename: string; additions: number; deletions: number; changes: number }[]
|
||||
) {
|
||||
const src: typeof files = [];
|
||||
const tests: typeof files = [];
|
||||
const generated: typeof files = [];
|
||||
|
|
@ -89,7 +91,11 @@ export class DiffBackend implements EngineBackend {
|
|||
} else if (totalChanges <= this.config.maxChanges) {
|
||||
signals.push({ name: `large PR (${totalChanges} lines)`, positive: false, weight: 0.8 });
|
||||
} else {
|
||||
signals.push({ name: `very large PR (${totalChanges} lines, exceeds limit)`, positive: false, weight: 1.5 });
|
||||
signals.push({
|
||||
name: `very large PR (${totalChanges} lines, exceeds limit)`,
|
||||
positive: false,
|
||||
weight: 1.5,
|
||||
});
|
||||
}
|
||||
|
||||
// --- Focus signals ---
|
||||
|
|
@ -98,9 +104,17 @@ export class DiffBackend implements EngineBackend {
|
|||
} else if (meaningful.length <= 10) {
|
||||
signals.push({ name: 'focused changeset', positive: true, weight: 0.8 });
|
||||
} else if (meaningful.length > 30) {
|
||||
signals.push({ name: `sprawling changeset (${meaningful.length} files)`, positive: false, weight: 1.2 });
|
||||
signals.push({
|
||||
name: `sprawling changeset (${meaningful.length} files)`,
|
||||
positive: false,
|
||||
weight: 1.2,
|
||||
});
|
||||
} else if (meaningful.length > 20) {
|
||||
signals.push({ name: `broad changeset (${meaningful.length} files)`, positive: false, weight: 0.6 });
|
||||
signals.push({
|
||||
name: `broad changeset (${meaningful.length} files)`,
|
||||
positive: false,
|
||||
weight: 0.6,
|
||||
});
|
||||
}
|
||||
|
||||
// --- Test coverage ---
|
||||
|
|
@ -129,10 +143,17 @@ export class DiffBackend implements EngineBackend {
|
|||
|
||||
// --- Churn detection (files with high add+delete suggesting rewrites) ---
|
||||
const highChurnFiles = src.filter(
|
||||
(f) => f.additions > 50 && f.deletions > 50 && Math.min(f.additions, f.deletions) / Math.max(f.additions, f.deletions) > 0.6
|
||||
(f) =>
|
||||
f.additions > 50 &&
|
||||
f.deletions > 50 &&
|
||||
Math.min(f.additions, f.deletions) / Math.max(f.additions, f.deletions) > 0.6
|
||||
);
|
||||
if (highChurnFiles.length >= 3) {
|
||||
signals.push({ name: `high churn in ${highChurnFiles.length} files (possible refactor)`, positive: false, weight: 0.5 });
|
||||
signals.push({
|
||||
name: `high churn in ${highChurnFiles.length} files (possible refactor)`,
|
||||
positive: false,
|
||||
weight: 0.5,
|
||||
});
|
||||
}
|
||||
|
||||
// --- Risky files ---
|
||||
|
|
@ -180,7 +201,11 @@ export class DiffBackend implements EngineBackend {
|
|||
const totalSignalWeight = positiveWeight + negativeWeight;
|
||||
const confidence =
|
||||
signals.length > 0
|
||||
? Math.min(1, Math.abs(positiveWeight - negativeWeight) / Math.max(totalSignalWeight, 1) * 0.6 + 0.25)
|
||||
? Math.min(
|
||||
1,
|
||||
(Math.abs(positiveWeight - negativeWeight) / Math.max(totalSignalWeight, 1)) * 0.6 +
|
||||
0.25
|
||||
)
|
||||
: 0;
|
||||
|
||||
// Build reasoning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue