tasks/lib/coverageStats.js
function badgeColour(collection, stat, watermarks) {
      var watermarkType = stat === "overall" ? "lines" : stat;
      var low = watermarks[watermarkType][0];
      var high = watermarks[watermarkType][1];
      var mid = (high - low) / 2;
      var value = collection[stat].pct;
      if (value < low) {
        collection[stat].colour = "red";
      } else if (value < mid) {
        collection[stat].colour = "orange";
      } else if (value < high) {
        collection[stat].colour = "yellow";
      } else if (value < 100) {
        collection[stat].colour = "green";
      } else {
        collection[stat].colour = "brightgreen";
      }
    }
function badgeColour(collection, stat, watermarks) {
      var watermarkType = stat === "overall" ? "lines" : stat;
      var low = watermarks[watermarkType][0];
      var high = watermarks[watermarkType][1];
      var mid = (high - low) / 2;
      var value = collection[stat].pct;
      if (value < low) {
        collection[stat].colour = "red";
      } else if (value < mid) {
        collection[stat].colour = "orange";
      } else if (value < high) {
        collection[stat].colour = "yellow";
      } else if (value < 100) {
        collection[stat].colour = "green";
      } else {
        collection[stat].colour = "brightgreen";
      }
    }
function badgeColour ( collection , stat , watermarks ) { var watermarkType = stat === "overall" ? "lines" : stat ; var low = watermarks [ watermarkType ] [ 0 ] ; var high = watermarks [ watermarkType ] [ 1 ] ; var mid = ( high - low ) / 2 ; var value = collection [ stat ] . pct ; if ( value < low ) { collection [ stat ] . colour = "red" ; } else if ( value < mid ) { collection [ stat ] . colour = "orange" ; } else if ( value < high ) { collection [ stat ] . colour = "yellow" ; } else if ( value < 100 ) { collection [ stat ] . colour = "green" ; } else { collection [ stat ] . colour = "brightgreen" ; } }
Helper function to determine badge colour
@param {Object} collection - a collection of statistic properties
@param {Object} stat - a statistic from the collection to calculate the badge for
@param {Object} watermarks - the high and low watermarks for each statistic in collection
Helper function to determine badge colour