|
19 | 19 |
|
20 | 20 | #include "deflookup.hh" |
21 | 21 |
|
| 22 | +#include "finger-print.hh" |
22 | 23 | #include "msg-filter.hh" |
23 | 24 | #include "parser.hh" |
24 | 25 |
|
@@ -79,8 +80,29 @@ void DefLookup::hashDefect(const Defect &def) |
79 | 80 | defList.push_back(def); |
80 | 81 | } |
81 | 82 |
|
82 | | -static bool defLookupCore(TDefList &defList) |
| 83 | +static bool defLookupCore(TDefList &defList, const Defect &lookFor) |
83 | 84 | { |
| 85 | + // look by line content without spaces if available |
| 86 | + const std::string lineCont = FingerPrinter(lookFor).getLineContent(); |
| 87 | + if (!lineCont.empty()) { |
| 88 | + bool fullLineContCoverage = true; |
| 89 | + |
| 90 | + for (auto it = defList.begin(); it != defList.end(); ++it) { |
| 91 | + const std::string lineContNow = FingerPrinter(*it).getLineContent(); |
| 92 | + if (lineContNow.empty()) |
| 93 | + fullLineContCoverage = false; |
| 94 | + else if (lineCont == lineContNow) { |
| 95 | + // matched by line content without spaces |
| 96 | + defList.erase(it); |
| 97 | + return true; |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + if (fullLineContCoverage) |
| 102 | + // we had line content for all lines but none of them matched |
| 103 | + return false; |
| 104 | + } |
| 105 | + |
84 | 106 | // just remove an arbitrary one |
85 | 107 | // TODO: add some other criteria in order to make the match more precise |
86 | 108 | defList.resize(defList.size() - 1U); |
@@ -132,7 +154,7 @@ bool DefLookup::lookup(const Defect &def) |
132 | 154 | // process the resulting list of defects sequentially |
133 | 155 | TDefList &defList = itByMsg->second; |
134 | 156 | assert(!defList.empty()); |
135 | | - if (!defLookupCore(defList)) |
| 157 | + if (!defLookupCore(defList, def)) |
136 | 158 | return false; |
137 | 159 |
|
138 | 160 | // remove empty maps to speed up subsequent lookups |
|
0 commit comments