Merge pull request #1789 from tenhobi/add-effective_dart-to-linter-page

Add effective_dart to linter page
diff --git a/tool/crawl.dart b/tool/crawl.dart
index a6119ca..8871acc 100644
--- a/tool/crawl.dart
+++ b/tool/crawl.dart
@@ -24,6 +24,10 @@
 const _pedanticOptionsRootUrl =
     'https://raw.githubusercontent.com/dart-lang/pedantic/master/lib';
 const _pedanticOptionsUrl = '$_pedanticOptionsRootUrl/analysis_options.yaml';
+const _effectiveDartOptionsRootUrl =
+    'https://raw.githubusercontent.com/tenhobi/effective_dart/master/lib';
+const _effectiveDartOptionsUrl =
+    '$_effectiveDartOptionsRootUrl/analysis_options.yaml';
 const _stagehandOptionsUrl =
     'https://raw.githubusercontent.com/dart-lang/stagehand/master/templates/analysis_options.yaml';
 
@@ -34,6 +38,7 @@
 List<String> _flutterRules;
 List<String> _flutterRepoRules;
 List<String> _pedanticRules;
+List<String> _effectiveDartRules;
 List<String> _stagehandRules;
 
 Future<List<String>> get flutterRules async =>
@@ -52,6 +57,17 @@
   return _fetchRules('$_pedanticOptionsRootUrl/$includedOptions');
 }
 
+Future<List<String>> get effectiveDartRules async =>
+    _effectiveDartRules ??= await _fetchEffectiveDartRules();
+
+Future<List<String>> _fetchEffectiveDartRules() async {
+  var client = http.Client();
+  var req = await client.get(_effectiveDartOptionsUrl);
+  var includedOptions =
+      req.body.split('include: package:effective_dart/')[1].trim();
+  return _fetchRules('$_effectiveDartOptionsRootUrl/$includedOptions');
+}
+
 Future<List<String>> get stagehandRules async =>
     _stagehandRules ??= await _fetchRules(_stagehandOptionsUrl);
 
diff --git a/tool/doc.dart b/tool/doc.dart
index 1db585c..1ce8f71 100644
--- a/tool/doc.dart
+++ b/tool/doc.dart
@@ -56,6 +56,7 @@
 
 final flutterRules = <String>[];
 final pedanticRules = <String>[];
+final effectiveDartRules = <String>[];
 
 /// Sorted list of contributed lint rules.
 final List<LintRule> rules =
@@ -90,8 +91,18 @@
   return parts[1].split('.yaml')[0];
 }
 
+Future<String> get effectiveDartLatestVersion async {
+  var url =
+      'https://raw.githubusercontent.com/tenhobi/effective_dart/master/lib/analysis_options.yaml';
+  var client = http.Client();
+  var req = await client.get(url);
+  var parts = req.body.split('package:effective_dart/analysis_options.');
+  return parts[1].split('.yaml')[0];
+}
+
 Future<void> fetchBadgeInfo() async {
   var latestPedantic = await pedanticLatestVersion;
+  var latestEffectiveDart = await effectiveDartLatestVersion;
 
   var pedantic = await fetchConfig(
       'https://raw.githubusercontent.com/dart-lang/pedantic/master/lib/analysis_options.$latestPedantic.yaml');
@@ -99,6 +110,12 @@
     pedanticRules.add(ruleConfig.name);
   }
 
+  var effectiveDart = await fetchConfig(
+      'https://raw.githubusercontent.com/tenhobi/effective_dart/master/lib/analysis_options.$latestEffectiveDart.yaml');
+  for (var ruleConfig in effectiveDart.ruleConfigs) {
+    effectiveDartRules.add(ruleConfig.name);
+  }
+
   var flutter = await fetchConfig(
       'https://raw.githubusercontent.com/flutter/flutter/master/packages/flutter/lib/analysis_options_user.yaml');
   for (var ruleConfig in flutter.ruleConfigs) {
@@ -165,6 +182,10 @@
     sb.write(
         '<a href="https://github.com/dart-lang/pedantic/#enabled-lints"><!--suppress HtmlUnknownTarget --><img alt="pedantic" src="style-pedantic.svg"></a>');
   }
+  if (effectiveDartRules.contains(rule)) {
+    sb.write(
+        '<a href="https://github.com/tenhobi/effective_dart"><!--suppress HtmlUnknownTarget --><img alt="effective_dart" src="style-effective_dart.svg"></a>');
+  }
   return sb.toString();
 }
 
diff --git a/tool/scorecard.dart b/tool/scorecard.dart
index 74afa96..aa87781 100644
--- a/tool/scorecard.dart
+++ b/tool/scorecard.dart
@@ -41,6 +41,7 @@
     Detail.sdk,
     Detail.fix,
     Detail.pedantic,
+    Detail.effectiveDart,
     Detail.flutterUser,
     Detail.flutterRepo,
     Detail.status,
@@ -124,6 +125,7 @@
   static const Detail sdk = Detail('dart sdk', header: Header.left);
   static const Detail fix = Detail('fix');
   static const Detail pedantic = Detail('pedantic');
+  static const Detail effectiveDart = Detail('effective_dart');
   static const Detail flutterUser = Detail('flutter user');
   static const Detail flutterRepo = Detail('flutter repo');
   static const Detail status = Detail('status');
@@ -230,6 +232,7 @@
     var flutterRuleset = await flutterRules;
     var flutterRepoRuleset = await flutterRepoRules;
     var pedanticRuleset = await pedanticRules;
+    var effectiveDartRuleset = await effectiveDartRules;
 
     var issues = await _getIssues();
     var bugs = issues.where(_isBug).toList();
@@ -247,6 +250,9 @@
       if (pedanticRuleset.contains(lint.name)) {
         ruleSets.add('pedantic');
       }
+      if (effectiveDartRuleset.contains(lint.name)) {
+        ruleSets.add('effective_dart');
+      }
       var bugReferences = <String>[];
       for (var bug in bugs) {
         if (bug.title.contains(lint.name)) {
@@ -316,6 +322,10 @@
         case Detail.pedantic:
           sb.write('${ruleSets.contains('pedantic') ? " $checkMark" : ""} |');
           break;
+        case Detail.effectiveDart:
+          sb.write(
+              '${ruleSets.contains('effective_dart') ? " $checkMark" : ""} |');
+          break;
         case Detail.flutterUser:
           sb.write('${ruleSets.contains('flutter') ? " $checkMark" : ""} |');
           break;