Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: lib/src/report.dart

Issue 1059873002: Tweaks to warning level and reporting (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Fix up tests Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/info.dart ('k') | test/checker/checker_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Summarizes the information produced by the checker. 5 /// Summarizes the information produced by the checker.
6 library dev_compiler.src.report; 6 library dev_compiler.src.report;
7 7
8 import 'dart:math' show max; 8 import 'dart:math' show max;
9 9
10 import 'package:analyzer/src/generated/source.dart' show Source; 10 import 'package:analyzer/src/generated/source.dart' show Source;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 /// Produces a string representation of the summary. 192 /// Produces a string representation of the summary.
193 String summaryToString(GlobalSummary summary) { 193 String summaryToString(GlobalSummary summary) {
194 var counter = new _Counter(); 194 var counter = new _Counter();
195 summary.accept(counter); 195 summary.accept(counter);
196 196
197 var table = new _Table(); 197 var table = new _Table();
198 // Declare columns and add header 198 // Declare columns and add header
199 table.declareColumn('package'); 199 table.declareColumn('package');
200 table.declareColumn('AnalyzerError', abbreviate: true); 200 table.declareColumn('AnalyzerError', abbreviate: true);
201 infoTypes.forEach((type) => table.declareColumn('$type', abbreviate: true)); 201 var activeInfoTypes =
202 infoTypes.where((type) => counter.totals['$type'] != null);
203 activeInfoTypes
204 .forEach((type) => table.declareColumn('$type', abbreviate: true));
202 table.declareColumn('LinesOfCode', abbreviate: true); 205 table.declareColumn('LinesOfCode', abbreviate: true);
203 table.addHeader(); 206 table.addHeader();
204 207
205 // Add entries for each package 208 // Add entries for each package
206 appendCount(count) => table.addEntry(count == null ? 0 : count); 209 appendCount(count) => table.addEntry(count == null ? 0 : count);
207 for (var package in counter.errorCount.keys) { 210 for (var package in counter.errorCount.keys) {
208 appendCount(package); 211 appendCount(package);
209 appendCount(counter.errorCount[package]['AnalyzerError']); 212 appendCount(counter.errorCount[package]['AnalyzerError']);
210 infoTypes.forEach((e) => appendCount(counter.errorCount[package]['$e'])); 213 activeInfoTypes
214 .forEach((e) => appendCount(counter.errorCount[package]['$e']));
211 appendCount(counter.linesOfCode[package]); 215 appendCount(counter.linesOfCode[package]);
212 } 216 }
213 217
214 // Add totals, percents and a new header for quick reference 218 // Add totals, percents and a new header for quick reference
215 table.addEmptyRow(); 219 table.addEmptyRow();
216 table.addHeader(); 220 table.addHeader();
217 table.addEntry('total'); 221 table.addEntry('total');
218 appendCount(counter.totals['AnalyzerError']); 222 appendCount(counter.totals['AnalyzerError']);
219 infoTypes.forEach((type) => appendCount(counter.totals['$type'])); 223 activeInfoTypes.forEach((type) => appendCount(counter.totals['$type']));
220 appendCount(counter.totalLinesOfCode); 224 appendCount(counter.totalLinesOfCode);
221 225
222 appendPercent(count, total) { 226 appendPercent(count, total) {
223 if (count == null) count = 0; 227 if (count == null) count = 0;
224 var value = (count * 100 / total).toStringAsFixed(2); 228 var value = (count * 100 / total).toStringAsFixed(2);
225 table.addEntry(value); 229 table.addEntry(value);
226 } 230 }
227 231
228 var totalLOC = counter.totalLinesOfCode; 232 var totalLOC = counter.totalLinesOfCode;
229 table.addEntry('%'); 233 table.addEntry('%');
230 appendPercent(counter.totals['AnalyzerError'], totalLOC); 234 appendPercent(counter.totals['AnalyzerError'], totalLOC);
231 infoTypes.forEach((type) => appendPercent(counter.totals['$type'], totalLOC)); 235 activeInfoTypes
236 .forEach((type) => appendPercent(counter.totals['$type'], totalLOC));
232 appendCount(100); 237 appendCount(100);
233 238
234 return table.toString(); 239 return table.toString();
235 } 240 }
236 241
237 /// Helper class to combine all the information in table form. 242 /// Helper class to combine all the information in table form.
238 class _Table { 243 class _Table {
239 int _totalColumns = 0; 244 int _totalColumns = 0;
240 int get totalColumns => _totalColumns; 245 int get totalColumns => _totalColumns;
241 246
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 381
377 visitMessage(MessageSummary message) { 382 visitMessage(MessageSummary message) {
378 var kind = message.kind; 383 var kind = message.kind;
379 errorCount.putIfAbsent(currentPackage, () => <String, int>{}); 384 errorCount.putIfAbsent(currentPackage, () => <String, int>{});
380 errorCount[currentPackage].putIfAbsent(kind, () => 0); 385 errorCount[currentPackage].putIfAbsent(kind, () => 0);
381 errorCount[currentPackage][kind]++; 386 errorCount[currentPackage][kind]++;
382 totals.putIfAbsent(kind, () => 0); 387 totals.putIfAbsent(kind, () => 0);
383 totals[kind]++; 388 totals[kind]++;
384 } 389 }
385 } 390 }
OLDNEW
« no previous file with comments | « lib/src/info.dart ('k') | test/checker/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698