Skip to content

Commit 74a6bbc

Browse files
authored
Merge pull request #37 from Webperf-se/no-duplicates
Remove duplicate group issues
2 parents b7ea6ed + 996ba0c commit 74a6bbc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ export default class WebPerfPlugin extends SitespeedioPlugin {
250250
this.data.groups[group].issues = this.sortIssues(this.data.groups[group].issues);
251251
this.data.groups[group].pages[entry.url].issues = this.sortIssues(this.data.groups[group].pages[entry.url].issues);
252252

253+
// Remove duplicates
254+
this.data.groups[group].issues = this.data.groups[group].issues.filter((issue, index, self) =>
255+
index === self.findIndex((other) => (
256+
other.test == issue.test &&
257+
other.rule === issue.rule &&
258+
other.severity === issue.severity &&
259+
other.category === issue.category
260+
))
261+
);
262+
253263
// Calculate score
254264
this.data.groups[group].score = this.scoreHelper.calculateScore(this.data.groups[group].issues)
255265
this.data.groups[group].pages[entry.url].score = this.scoreHelper.calculateScore(this.data.groups[group].pages[entry.url].issues)

0 commit comments

Comments
 (0)