sonar 11 left. super-linear fixed

This commit is contained in:
Cindy Chang
2024-08-13 11:45:01 +08:00
parent 1e0796e56e
commit 699d7a4f6b
2 changed files with 20 additions and 10 deletions

View File

@@ -247,8 +247,10 @@ export default {
/**
* @param {number} time use timeLabel.js
*/
timeLabel(time){
let result = getTimeLabel(time).match(/(\d+)\s*([a-zA-Z]+)/);
timeLabel(time){ // sonar-qube prevent super-linear runtime due to backtracking; change * to ?
//
const label = getTimeLabel(time).replace(/\s+/g, ' '); // 將所有連續空白字符壓縮為一個空白
const result = label.match(/^(\d+)\s?([a-zA-Z]+)$/); // add ^ and $ to meet sonar-qube need
return result;
},
/**