]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaws
authorStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 15:56:48 +0000 (17:56 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 31 Mar 2015 15:56:48 +0000 (17:56 +0200)
server/sonar-web/src/main/js/application.js
server/sonar-web/src/main/js/overview/models/state.js

index cde3f74828b91187ffef8b2eece195b0b7f965fd..dba8ef02702bf958c2dea7796f968e9fb2ca6bc0 100644 (file)
@@ -375,22 +375,14 @@ function fileFromPath (path) {
 (function () {
 
   /**
-   * Format a work duration measure
-   * @param {number} value
+   * Format a work duration based on parameters
+   * @param {bool} isNegative
+   * @param {number} days
+   * @param {number} hours
+   * @param {number} minutes
    * @returns {string}
    */
-  var durationFormatter = function (value) {
-    if (value === 0) {
-      return '0';
-    }
-    var hoursInDay = window.SS.hoursInDay || 8,
-        isNegative = value < 0,
-        absValue = Math.abs(value);
-    var days = Math.floor(absValue / hoursInDay / 60);
-    var remainingValue = absValue - days * hoursInDay * 60;
-    var hours = Math.floor(remainingValue / 60);
-    remainingValue -= hours * 60;
-    var minutes = remainingValue;
+  var formatDuration = function (isNegative, days, hours, minutes) {
     var formatted = '';
     if (days > 0) {
       formatted += tp('work_duration.x_days', isNegative ? -1 * days : days);
@@ -410,9 +402,28 @@ function fileFromPath (path) {
     return formatted;
   };
 
+  /**
+   * Format a work duration measure
+   * @param {number} value
+   * @returns {string}
+   */
+  var durationFormatter = function (value) {
+    if (value === 0) {
+      return '0';
+    }
+    var hoursInDay = window.SS.hoursInDay || 8,
+        isNegative = value < 0,
+        absValue = Math.abs(value);
+    var days = Math.floor(absValue / hoursInDay / 60);
+    var remainingValue = absValue - days * hoursInDay * 60;
+    var hours = Math.floor(remainingValue / 60);
+    remainingValue -= hours * 60;
+    return formatDuration(isNegative, days, hours, remainingValue);
+  };
+
   /**
    * Format a work duration variation
-   * @param value
+   * @param {number} value
    */
   var durationVariationFormatter = function (value) {
     if (value === 0) {
@@ -424,11 +435,10 @@ function fileFromPath (path) {
 
   /**
    * Format a rating measure
-   * @param value
+   * @param {number} value
    */
   var ratingFormatter = function (value) {
-    var intValue = +value;
-    return String.fromCharCode(97 + intValue - 1).toUpperCase();
+    return String.fromCharCode(97 + value - 1).toUpperCase();
   };
 
   /**
index b62181ada55c689feb8e8ed0322d3c344726b1cf..44964c6815787113ef1ac671281ff494b048a3f1 100644 (file)
@@ -127,7 +127,7 @@ define(function () {
     fetchIssues: function () {
       var that = this;
 
-      function _fetch (field, createdAfter) {
+      function fetchIssuesByPeriod (field, createdAfter) {
         var url = baseUrl + '/api/issues/search',
             options = {
               ps: 1,
@@ -142,15 +142,15 @@ define(function () {
         });
       }
 
-      _fetch('issues', null);
+      fetchIssuesByPeriod('issues', null);
       if (this.hasPeriod(1)) {
-        _fetch('issues1', this.get('period1Date'));
+        fetchIssuesByPeriod('issues1', this.get('period1Date'));
       }
       if (this.hasPeriod(2)) {
-        _fetch('issues2', this.get('period2Date'));
+        fetchIssuesByPeriod('issues2', this.get('period2Date'));
       }
       if (this.hasPeriod(3)) {
-        _fetch('issues3', this.get('period3Date'));
+        fetchIssuesByPeriod('issues3', this.get('period3Date'));
       }
     },