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

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 3007783002: Add fixes for two additional lints (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/correction/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index 42f4d3dacebe5110e9f5422f3e96a138052108eb..cc1f3ff50bc7048d94390adbba20f9a7714bc2bc 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -5561,6 +5561,21 @@ class LintFixTest extends BaseFixProcessorTest {
new LintCode(lintCode, '<ignored>'));
}
+ test_addRequiredAnnotation() async {
+ String src = '''
+void function({String /*LINT*/param}) {
+ assert(param != null);
+}
+''';
+ await findLint(src, LintNames.always_require_non_null_named_parameters);
+ await applyFix(DartFixKind.LINT_ADD_REQUIRED);
+ verifyResult('''
+void function({@required String param}) {
+ assert(param != null);
+}
+''');
+ }
+
test_lint_addMissingOverride_field() async {
String src = '''
class abstract Test {
@@ -5795,6 +5810,49 @@ bad() async {
''');
}
+ test_removeEmptyElse_newLine() async {
+ String src = '''
+void foo(bool cond) {
+ if (cond) {
+ //
+ }
+ else /*LINT*/;
+}
+''';
+ await findLint(src, LintNames.avoid_empty_else);
+
+ await applyFix(DartFixKind.REMOVE_EMPTY_ELSE);
+
+ verifyResult('''
+void foo(bool cond) {
+ if (cond) {
+ //
+ }
+}
+''');
+ }
+
+ test_removeEmptyElse_sameLine() async {
+ String src = '''
+void foo(bool cond) {
+ if (cond) {
+ //
+ } else /*LINT*/;
scheglov 2017/08/29 17:05:22 Is the lint reported for empty else blocks?
Brian Wilkerson 2017/08/29 17:16:46 It isn't currently, but I think it should be.
+}
+''';
+ await findLint(src, LintNames.avoid_empty_else);
+
+ await applyFix(DartFixKind.REMOVE_EMPTY_ELSE);
+
+ verifyResult('''
+void foo(bool cond) {
+ if (cond) {
+ //
+ }
+}
+''');
+ }
+
test_removeEmptyStatement_insideBlock() async {
String src = '''
void foo() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698