Skip to content

Commit

Permalink
[feat] Display dynamic columns in static HTML
Browse files Browse the repository at this point in the history
"CodeChecker parse -e html" command produces a static HTML that displays
the reports. However, the dynamic analysis related columns were missing
from this table: testcase and timestamp are now displayed too, if any.
  • Loading branch information
bruntib committed Feb 25, 2024
1 parent 08dab9c commit 14ab2f2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ def to_macro_expansions(
'notes': to_bug_path_events(report.notes),
'reviewStatus': report.review_status.formatted_status()
if report.review_status else '',
'severity': self.get_severity(report.checker_name)
'severity': self.get_severity(report.checker_name),
'testcase': report.annotations.get('testcase') \
if report.annotations else None,
'timestamp': report.annotations.get('timestamp') \
if report.annotations else None
})

return html_reports, files
Expand Down Expand Up @@ -302,6 +306,7 @@ def create_index_html(self, output_dir: str):
for report in reports:
html_report_links.append({'link': html_file, 'report': report})

print(html_report_links)
table_reports = map(lambda data: {
'link': data['link'],
'file-path': data['report']['fileId'],
Expand All @@ -312,7 +317,9 @@ def create_index_html(self, output_dir: str):
'message': data['report']['message'],
'review-status': data['report']['reviewStatus'],
'severity': data['report']['severity'],
'bug-path-length': len(data['report']['events'])
'bug-path-length': len(data['report']['events']),
'testcase': data['report']['testcase'],
'timestamp': data['report']['timestamp']
}, html_report_links)

self._tag_contents['table_reports'] = json.dumps(list(table_reports))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<th id="message">Message</th>
<th id="bug-path-length">Bug path length</th>
<th id="review-status">Review status</th>
<th id="testcase" class="dynamic">Testcase</th>
<th id="timestamp" class="dynamic">Timestamp</th>
</tr>
</thead>
<tbody id="report-list">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ var BugList = {
},

_cmp3 : function (a, b) {
return a < b ? -1 : a > b ? 1 : 0;
if (a === null)
return -1;
else if (b === null)
return 1;
else
return a < b ? -1 : a > b ? 1 : 0;
},

initTableSort : function () {
Expand Down Expand Up @@ -73,17 +78,25 @@ var BugList = {
function compare(a, b) {
var result;

if (columnId == 'file-path')
result = that._cmp3(
[a['file-path'], a['line']],
[b['file-path'], b['line']]);

if (columnId == 'severity')
result = that._cmp3(
severities.indexOf(a['severity']),
severities.indexOf(b['severity']));

result = that._cmp3(a[columnId], b[columnId]);
switch (columnId)
{
case 'file-path':
result = that._cmp3(
[a['file-path'], a['line']],
[b['file-path'], b['line']]);
break;

case 'severity':
result = that._cmp3(
severities.indexOf(a['severity']),
severities.indexOf(b['severity']));
break;

default:
console.log(columnId, a[columnId], b[columnId]);
result = that._cmp3(a[columnId], b[columnId]);
break;
}

return asc ? result : -result;
}
Expand Down Expand Up @@ -138,6 +151,18 @@ var BugList = {
review_col.appendChild(document.createTextNode(data['review-status']));
row.appendChild(review_col);

var testcase_col = document.createElement('td');
testcase_col.setAttribute('class', 'dynamic');
testcase_col.appendChild(
document.createTextNode(data['testcase'] || ''));
row.appendChild(testcase_col);

var timestamp_col = document.createElement('td');
timestamp_col.setAttribute('class', 'dynamic');
timestamp_col.appendChild(
document.createTextNode(data['timestamp'] || ''));
row.appendChild(timestamp_col);

return row;
},

Expand All @@ -148,9 +173,21 @@ var BugList = {
var report_list = document.getElementById('report-list');
report_list.innerHTML = '';

for (var i = startIdx; i < endIdx; ++i)
var dynamic_cols_needed = false;

for (var i = startIdx; i < endIdx; ++i) {
report_list.appendChild(this.buildRow(reports[i], i + 1));

if (reports[i]['testcase'] || reports[i]['timestamp'])
dynamic_cols_needed = true;
}

for (var tag of document.getElementsByClassName('dynamic'))
if (dynamic_cols_needed)
tag.style.removeProperty('display');
else
tag.style.display = 'none';

this.initBugPathLength();
},

Expand Down

0 comments on commit 14ab2f2

Please sign in to comment.