in vscode/qodana/src/core/sarif/index.ts [19:48]
async findPrefix(sarifFilePath: string): Promise<string | undefined> {
let locations = await this.getLocations(sarifFilePath);
let commonPrefixes = new Map<string, number>();
for (let location of locations) {
let prefix = await this.findFileByPathEnd(location);
if (prefix) {
let count = commonPrefixes.get(prefix);
if (count) {
commonPrefixes.set(prefix, count + 1);
} else {
commonPrefixes.set(prefix, 1);
}
}
}
if (commonPrefixes.size === 0) {
return undefined;
}
let maxCount = 0;
let maxPrefix = '';
for (let [prefix, count] of commonPrefixes) {
if (count > maxCount) {
maxCount = count;
maxPrefix = prefix;
}
}
if (maxCount >= commonPrefixes.size / 2) {
return maxPrefix;
}
return undefined;
}