2023-09-22 04:35:24 -04:00
|
|
|
const { recordRuleExitStatus } = require("./configParameters.js");
|
|
|
|
|
2023-02-21 02:56:09 -05:00
|
|
|
/**
|
|
|
|
* Check if MR is too large (more than 1000 lines of changes)
|
|
|
|
*
|
|
|
|
* @dangerjs INFO
|
|
|
|
*/
|
|
|
|
module.exports = async function () {
|
2023-09-22 04:35:24 -04:00
|
|
|
const ruleName = "Merge request size (number of changed lines)";
|
2023-02-21 02:56:09 -05:00
|
|
|
const bigMrLinesOfCodeThreshold = 1000;
|
|
|
|
const totalLines = await danger.git.linesOfCode();
|
|
|
|
|
|
|
|
if (totalLines > bigMrLinesOfCodeThreshold) {
|
2023-09-22 04:35:24 -04:00
|
|
|
recordRuleExitStatus(ruleName, "Passed (with suggestions)");
|
2023-02-21 02:56:09 -05:00
|
|
|
return message(
|
|
|
|
`This MR seems to be quite large (total lines of code: ${totalLines}), you might consider splitting it into smaller MRs`
|
|
|
|
);
|
|
|
|
}
|
2023-09-22 04:35:24 -04:00
|
|
|
|
|
|
|
// At this point, the rule has passed
|
|
|
|
recordRuleExitStatus(ruleName, "Passed");
|
2023-02-21 02:56:09 -05:00
|
|
|
};
|