mrSizeTooLarge.js 750 B

12345678910111213141516171819202122
  1. const { recordRuleExitStatus } = require("./configParameters.js");
  2. /**
  3. * Check if MR is too large (more than 1000 lines of changes)
  4. *
  5. * @dangerjs INFO
  6. */
  7. module.exports = async function () {
  8. const ruleName = "Merge request size (number of changed lines)";
  9. const bigMrLinesOfCodeThreshold = 1000;
  10. const totalLines = await danger.git.linesOfCode();
  11. if (totalLines > bigMrLinesOfCodeThreshold) {
  12. recordRuleExitStatus(ruleName, "Passed (with suggestions)");
  13. return message(
  14. `This MR seems to be quite large (total lines of code: ${totalLines}), you might consider splitting it into smaller MRs`
  15. );
  16. }
  17. // At this point, the rule has passed
  18. recordRuleExitStatus(ruleName, "Passed");
  19. };