]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6331 add a sqale rating
authorStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 13:24:48 +0000 (15:24 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 13:25:14 +0000 (15:25 +0200)
server/sonar-web/src/main/hbs/overview/overview-debt.hbs
server/sonar-web/src/main/js/application.js
server/sonar-web/src/main/js/overview/models/state.js
server/sonar-web/src/test/js/overview.js
server/sonar-web/src/test/json/overview/measures.json

index 232cc2228fe925b6cee813f76a71b30b27ee971f..132f040fcbdc571cdbe7ca1b649b65418ad8d6d9 100644 (file)
@@ -4,6 +4,9 @@
   <tr>
     <td class="width-55">
       <div class="overview-main-measure">
+        {{#notNull sqaleRating}}
+          <a href="{{urlForDrilldown componentKey 'sqale_rating'}}"><span class="rating rating-{{formatMeasure sqaleRating 'RATING'}}">{{formatMeasure sqaleRating 'RATING'}}</span></a>
+        {{/notNull}}
         <a href="{{urlForDrilldown componentKey 'sqale_index'}}">{{formatMeasure debt 'WORK_DUR'}}</a>
       </div>
       <div class="overview-trend">
index 24088b89b81ccefc1edacfbba4b17f24661ca956..cde3f74828b91187ffef8b2eece195b0b7f965fd 100644 (file)
@@ -422,6 +422,15 @@ function fileFromPath (path) {
     return formatted[0] !== '-' ? '+' + formatted : formatted;
   };
 
+  /**
+   * Format a rating measure
+   * @param value
+   */
+  var ratingFormatter = function (value) {
+    var intValue = +value;
+    return String.fromCharCode(97 + intValue - 1).toUpperCase();
+  };
+
   /**
    * Format a measure according to its type
    * @param measure
@@ -440,7 +449,8 @@ function fileFromPath (path) {
           'PERCENT': function (value) {
             return numeral(+value / 100).format('0,0.0%');
           },
-          'WORK_DUR': durationFormatter
+          'WORK_DUR': durationFormatter,
+          'RATING': ratingFormatter
         };
     if (measure != null && type != null) {
       formatted = formatters[type] != null ? formatters[type](measure) : measure;
index c8b2f228aeb8a4f29323ce0c8994a08122d5c72c..b62181ada55c689feb8e8ed0322d3c344726b1cf 100644 (file)
@@ -24,6 +24,7 @@ define(function () {
       SIZE_METRIC = 'ncloc',
       ISSUES_METRIC = 'violations',
       DEBT_METRIC = 'sqale_index',
+      SQALE_RATING_METRIC = 'sqale_rating',
       COVERAGE_METRIC = 'overall_coverage',
       NEW_COVERAGE_METRIC = 'new_overall_coverage',
       DUPLICATIONS_METRIC = 'duplicated_lines_density';
@@ -67,6 +68,7 @@ define(function () {
               GATE_METRIC,
               SIZE_METRIC,
               DEBT_METRIC,
+              SQALE_RATING_METRIC,
               COVERAGE_METRIC,
               NEW_COVERAGE_METRIC,
               DUPLICATIONS_METRIC
@@ -153,7 +155,8 @@ define(function () {
     },
 
     parseDebt: function (msr) {
-      var debtMeasure = _.findWhere(msr, { key: DEBT_METRIC });
+      var debtMeasure = _.findWhere(msr, { key: DEBT_METRIC }),
+          sqaleRatingMeasure = _.findWhere(msr, { key: SQALE_RATING_METRIC });
       if (debtMeasure != null) {
         this.set({
           debt: debtMeasure.val,
@@ -162,6 +165,9 @@ define(function () {
           debt3: debtMeasure.var3
         });
       }
+      if (sqaleRatingMeasure != null) {
+        this.set({ sqaleRating: sqaleRatingMeasure.val });
+      }
     },
 
     parseCoverage: function (msr) {
index 39ab84605cff11ac2e2aeadc8a4c865f63bb4ee0..73e931133ebe0f8250434558df1d6d68553b91f6 100644 (file)
@@ -26,7 +26,7 @@ lib.changeWorkingDirectory('overview');
 lib.configureCasper();
 
 
-casper.test.begin(testName(), 33, function (test) {
+casper.test.begin(testName(), 34, function (test) {
   casper
       .start(lib.buildUrl('overview'), function () {
         lib.setDefaultViewport();
@@ -67,6 +67,7 @@ casper.test.begin(testName(), 33, function (test) {
         test.assertSelectorContains('#overview-issues', '1,605');
         test.assertExists('#overview-issues-trend path');
 
+        test.assertSelectorContains('#overview-debt', 'A');
         test.assertSelectorContains('#overview-debt', '66');
         test.assertSelectorContains('#overview-debt', '-2');
         test.assertSelectorContains('#overview-debt', '-49');
index b48b46d7169321278797accd93a677a36cd7297a..33c235ca5751d0f75235aad32ce648071eb2bf1e 100644 (file)
         "var3": -30819,
         "fvar3": "-64d"
       },
+      {
+        "key": "sqale_rating",
+        "val": 1,
+        "frmt_val": "A",
+        "data": "A",
+        "trend": 0,
+        "var": 0,
+        "var1": 0,
+        "fvar1": "0",
+        "var2": 0,
+        "fvar2": "0",
+        "var3": 0,
+        "fvar3": "0"
+      },
       {
         "key": "overall_coverage",
         "val": 83.9,