Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit edcb5bc

Browse files
committedFeb 20, 2024
parser-cov: look for an eligible key event
... in forward direction, which seems to be more compatible with Coverity's native assignment of key events. Resolves: https://issues.redhat.com/browse/OSH-552 Closes: #165
1 parent 4a46b53 commit edcb5bc

31 files changed

+521184
-2855
lines changed
 

Diff for: ‎src/lib/parser-cov.cc

+20-20
Original file line numberDiff line numberDiff line change
@@ -378,31 +378,31 @@ bool KeyEventDigger::guessKeyEvent(Defect *def)
378378
return true;
379379
}
380380

381-
// use the last event as key event by default (unless deny-listed)
382-
for (int pass = 0; pass < 2; ++pass) {
383-
for (int idx = evtCount - 1U; idx >= 0; --idx) {
384-
const DefEvent &evt = evtList[idx];
385-
if (evt.event == "#")
386-
// never use comment as the key event
387-
continue;
388-
389-
390-
// never use trace or deny-listed event as the key event
391-
// (but pick the last one of there are no other events)
392-
if (!pass) {
393-
const std::string &evtName = evt.event;
394-
if (d->traceEvts.count(evtName) || d->denyList.count(evtName))
395-
continue;
396-
}
381+
// take the first eligible key event
382+
bool valid = false;
383+
for (unsigned idx = 0; idx < evtCount; ++idx) {
384+
const DefEvent &evt = evtList[idx];
385+
if (evt.event == "#")
386+
// never use comment as the key event
387+
continue;
397388

398-
// matched
389+
if (!valid) {
390+
// at least we found an event which is not a comment
399391
def->keyEventIdx = idx;
400-
return true;
392+
valid = true;
401393
}
394+
395+
// skip trace and deny-listed events
396+
const std::string &evtName = evt.event;
397+
if (d->traceEvts.count(evtName) || d->denyList.count(evtName))
398+
continue;
399+
400+
// matched
401+
def->keyEventIdx = idx;
402+
return true;
402403
}
403404

404-
// no valid key event
405-
return false;
405+
return valid;
406406
}
407407

408408
void KeyEventDigger::initVerbosity(Defect *def)

Diff for: ‎tests/csdiff/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ test_csdiff(diff-misc 12-shellcheck-sc222x)
8080
test_csdiff(diff-misc 13-gcca-filt)
8181
test_csdiff(diff-misc 14-gitleaks-paths)
8282
test_csdiff(diff-misc 15-gcc-prof-filter)
83+
test_csdiff(diff-misc 16-cov-parser-key-event)
8384

8485
add_subdirectory(filter-file)

Diff for: ‎tests/csdiff/diff-misc/16-cov-parser-key-event-add-z.err

Whitespace-only changes.

Diff for: ‎tests/csdiff/diff-misc/16-cov-parser-key-event-add.err

Whitespace-only changes.

Diff for: ‎tests/csdiff/diff-misc/16-cov-parser-key-event-fix-z.err

Whitespace-only changes.

Diff for: ‎tests/csdiff/diff-misc/16-cov-parser-key-event-fix.err

Whitespace-only changes.

Diff for: ‎tests/csdiff/diff-misc/16-cov-parser-key-event-new.err

+68,815
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)