diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-03-31 15:24:48 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-03-31 15:25:14 +0200 |
commit | e5b20e3ae06b80d852a91968e975d0894ddfac82 (patch) | |
tree | 5145b000d04fb8243274b9040f9a6b476dfa265d /server | |
parent | ac60aa9eef80689f24b10857dbaf83dd1eb412fe (diff) | |
download | sonarqube-e5b20e3ae06b80d852a91968e975d0894ddfac82.tar.gz sonarqube-e5b20e3ae06b80d852a91968e975d0894ddfac82.zip |
SONAR-6331 add a sqale rating
Diffstat (limited to 'server')
5 files changed, 37 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/hbs/overview/overview-debt.hbs b/server/sonar-web/src/main/hbs/overview/overview-debt.hbs index 232cc2228fe..132f040fcbd 100644 --- a/server/sonar-web/src/main/hbs/overview/overview-debt.hbs +++ b/server/sonar-web/src/main/hbs/overview/overview-debt.hbs @@ -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"> diff --git a/server/sonar-web/src/main/js/application.js b/server/sonar-web/src/main/js/application.js index 24088b89b81..cde3f74828b 100644 --- a/server/sonar-web/src/main/js/application.js +++ b/server/sonar-web/src/main/js/application.js @@ -423,6 +423,15 @@ function fileFromPath (path) { }; /** + * 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 * @param {string} type @@ -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; diff --git a/server/sonar-web/src/main/js/overview/models/state.js b/server/sonar-web/src/main/js/overview/models/state.js index c8b2f228aeb..b62181ada55 100644 --- a/server/sonar-web/src/main/js/overview/models/state.js +++ b/server/sonar-web/src/main/js/overview/models/state.js @@ -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) { diff --git a/server/sonar-web/src/test/js/overview.js b/server/sonar-web/src/test/js/overview.js index 39ab84605cf..73e931133eb 100644 --- a/server/sonar-web/src/test/js/overview.js +++ b/server/sonar-web/src/test/js/overview.js @@ -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'); diff --git a/server/sonar-web/src/test/json/overview/measures.json b/server/sonar-web/src/test/json/overview/measures.json index b48b46d7169..33c235ca575 100644 --- a/server/sonar-web/src/test/json/overview/measures.json +++ b/server/sonar-web/src/test/json/overview/measures.json @@ -60,6 +60,20 @@ "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, "frmt_val": "83.9%", |