← All Exercises

Classify Review Risk per Changed File

intermediatejavascript~20min

Background

Review time is the scarcest resource in delivery. A risk classifier makes large mechanical diffs and small security diffs receive opposite treatment.

Problem

Assign a review risk level to each changed file using security/config touches, test coverage presence, and change size, so a reviewer spends attention where it matters.

Input

JSON object: { files: [{ file, added, removed, touchesTests?, touchesConfig?, touchesSecurity? }] }

Output

JSON array of { file, risk } sorted by file

Sample tests

Sample 1

Input: {"files":[{"file":"src/auth.ts","added":4,"removed":2,"touchesSecurity":true},{"file":"README.md","added":120,"removed":3}]}
Expected: [{"file":"README.md","risk":"medium"},{"file":"src/auth.ts","risk":"high"}]

Sample 2

Input: {"files":[{"file":"src/auth.test.ts","added":30,"removed":5,"touchesTests":true}]}
Expected: [{"file":"src/auth.test.ts","risk":"low"}]

Your solution

Learning objective

Route review attention by risk instead of diff size alone.