From 2ffcf96b4b7a1fbc761796df1336a94408a79ed0 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 12 Jul 2016 20:04:20 -0500 Subject: [PATCH] Use statistics in the legacy report class --- src/flake8/api/legacy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/flake8/api/legacy.py b/src/flake8/api/legacy.py index 35c7101..9fc05bb 100644 --- a/src/flake8/api/legacy.py +++ b/src/flake8/api/legacy.py @@ -141,6 +141,8 @@ class Report(object): .. warning:: This should not be instantiated by users. """ self._application = application + self._style_guide = application.guide + self._stats = self._style_guide.stats @property def total_errors(self): @@ -149,4 +151,7 @@ class Report(object): def get_statistics(self, violation): """Get the number of occurences of a violation.""" - raise NotImplementedError('Statistics capturing needs to happen first') + return [ + '{} {} {}'.format(s.count, s.error_code, s.message) + for s in self._stats.statistics_for(violation) + ]