Add warning type into TopDirs and TopFiles index
* The index was a directory or file path.
This change adds additional entries that have
warning type prefix in the index.
* In the "Directories/Files with at least 1% warnings"
section, the list will include number of warnings for
(1) "all warnings in a directory/file"
(2) "warnings of a type in a directory/file"
(3) "warnings of a type in all directories/files"
Examples:
4273 (8.7%) frameworks/av/...
4130 (8.4%) packages/...
2427 (5.0%) [google-explicit-constructor] */...
1628 (3.3%) [cert-err34-c] */...
1099 (2.2%) [google-runtime-int] bionic/tests/math_data/...
608 (1.2%) [cert-err34-c] external/...
Bug: 231245501
Test: warn.py --url=http://cs/android --separator='?l=' build.log > warnings.html
Test: warn.py --gencsv build.log > warnings.csv
Change-Id: I13bb54c846ad514334f78c5a71e994a131a92963
diff --git a/tools/warn/html_writer.py b/tools/warn/html_writer.py
index 3fa822a..09ebf30 100644
--- a/tools/warn/html_writer.py
+++ b/tools/warn/html_writer.py
@@ -662,15 +662,26 @@
var warningsOfFiles = {};
var warningsOfDirs = {};
var subDirs = {};
- function addOneWarning(map, key) {
- map[key] = 1 + ((key in map) ? map[key] : 0);
+ function addOneWarning(map, key, type, unique) {
+ function increaseCounter(idx) {
+ map[idx] = 1 + ((idx in map) ? map[idx] : 0);
+ }
+ increaseCounter(key)
+ if (type != "") {
+ increaseCounter(type + " " + key)
+ if (unique) {
+ increaseCounter(type + " *")
+ }
+ }
}
for (var i = 0; i < numWarnings; i++) {
- var file = WarningMessages[i].replace(/:.*/, "");
- addOneWarning(warningsOfFiles, file);
+ var message = WarningMessages[i]
+ var file = message.replace(/:.*/, "");
+ var warningType = message.endsWith("]") ? message.replace(/.*\[/, "[") : "";
+ addOneWarning(warningsOfFiles, file, warningType, true);
var dirs = file.split("/");
var dir = dirs[0];
- addOneWarning(warningsOfDirs, dir);
+ addOneWarning(warningsOfDirs, dir, warningType, true);
for (var d = 1; d < dirs.length - 1; d++) {
var subDir = dir + "/" + dirs[d];
if (!(dir in subDirs)) {
@@ -678,7 +689,7 @@
}
subDirs[dir][subDir] = 1;
dir = subDir;
- addOneWarning(warningsOfDirs, dir);
+ addOneWarning(warningsOfDirs, dir, warningType, false);
}
}
var minDirWarnings = numWarnings*(LimitPercentWarnings/100);
@@ -725,27 +736,33 @@
document.getElementById(divName));
table.draw(view, {allowHtml: true, alternatingRowStyle: true});
}
- addTable("Directory", "top_dirs_table", TopDirs, "selectDir");
- addTable("File", "top_files_table", TopFiles, "selectFile");
+ addTable("[Warning Type] Directory", "top_dirs_table", TopDirs, "selectDir");
+ addTable("[Warning Type] File", "top_files_table", TopFiles, "selectFile");
}
function selectDirFile(idx, rows, dirFile) {
if (rows.length <= idx) {
return;
}
var name = rows[idx][2];
+ var type = "";
+ if (name.startsWith("[")) {
+ type = " " + name.replace(/ .*/, "");
+ name = name.replace(/.* /, "");
+ }
var spanName = "selected_" + dirFile + "_name";
- document.getElementById(spanName).innerHTML = name;
+ document.getElementById(spanName).innerHTML = name + type;
var divName = "selected_" + dirFile + "_warnings";
var numWarnings = rows[idx][1].v;
var prefix = name.replace(/\\.\\.\\.$/, "");
var data = new google.visualization.DataTable();
- data.addColumn('string', numWarnings + ' warnings in ' + name);
+ data.addColumn('string', numWarnings + type + ' warnings in ' + name);
var getWarningMessage = (FlagPlatform == "chrome")
? ((x) => addURLToLine(WarningMessages[Warnings[x][2]],
WarningLinks[Warnings[x][3]]))
: ((x) => addURL(WarningMessages[Warnings[x][2]]));
for (var i = 0; i < Warnings.length; i++) {
- if (WarningMessages[Warnings[i][2]].startsWith(prefix)) {
+ if ((prefix.startsWith("*") || WarningMessages[Warnings[i][2]].startsWith(prefix)) &&
+ (type == "" || WarningMessages[Warnings[i][2]].endsWith(type))) {
data.addRow([getWarningMessage(i)]);
}
}
@@ -827,14 +844,14 @@
def section2():
dump_dir_file_section(
writer, 'directory', 'top_dirs_table',
- 'Directories with at least ' +
- str(LIMIT_PERCENT_WARNINGS) + '% warnings')
+ 'Directories/Warnings with at least ' +
+ str(LIMIT_PERCENT_WARNINGS) + '% of all cases')
def section3():
dump_dir_file_section(
writer, 'file', 'top_files_table',
- 'Files with at least ' +
- str(LIMIT_PERCENT_WARNINGS) + '% or ' +
- str(LIMIT_WARNINGS_PER_FILE) + ' warnings')
+ 'Files/Warnings with at least ' +
+ str(LIMIT_PERCENT_WARNINGS) + '% of all or ' +
+ str(LIMIT_WARNINGS_PER_FILE) + ' cases')
def section4():
writer('<script>')
emit_js_data(writer, flags, warning_messages, warning_links,