-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reporter): Add threshold reporter
- Loading branch information
Andrii Kucherenko
committed
Aug 17, 2018
1 parent
6ae45ca
commit e8e1b25
Showing
10 changed files
with
69 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# ![AVA](logo.svg) | ||
|
||
|
||
# Copy/paste detector (ALPHA VERSION). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { red } from 'colors/safe'; | ||
import { END_PROCESS_EVENT, Events } from '../events'; | ||
import { IOptions } from '../interfaces/options.interface'; | ||
import { IReporter } from '../interfaces/reporter.interface'; | ||
import { STATISTIC_DB } from '../stores/models'; | ||
import { StoresManager } from '../stores/stores-manager'; | ||
|
||
export class ThresholdReporter implements IReporter { | ||
constructor(private options: IOptions) { | ||
} | ||
|
||
public attach(): void { | ||
Events.on(END_PROCESS_EVENT, this.finish.bind(this)); | ||
} | ||
|
||
private finish() { | ||
const statistic = StoresManager.getStore(STATISTIC_DB).get( | ||
this.options.executionId | ||
); | ||
if (statistic) { | ||
if (this.options.threshold && this.options.threshold < statistic.all.percentage) { | ||
console.error(red('ERROR: jscpd found too many duplicates over threshold')); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters