Skip to content

Commit 46fc143

Browse files
author
shaark
committed
issue-182. added new test case
1 parent e76aafe commit 46fc143

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

lint_test/prefer_early_return_test.dart

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,64 @@ void threeSeqentialIfReturn2() {
236236
}
237237
}
238238

239-
void throwExpression() {
239+
void oneIfWithThrowWithReturn() {
240240
//no lint
241241
if (true) {
242242
throw '';
243243
}
244244

245245
return;
246246
}
247+
248+
void oneIfElseWithThrowReturn() {
249+
//no lint
250+
if (true) {
251+
_doSomething();
252+
} else {
253+
throw '';
254+
}
255+
}
256+
257+
void twoSeqentialIfWithThrow() {
258+
if (false) throw '';
259+
//expect_lint: prefer_early_return
260+
if (true) {
261+
_doSomething();
262+
}
263+
}
264+
265+
void twoSeqentialIfWithThrowReturn2() {
266+
//no lint
267+
if (false) throw '';
268+
//expect_lint: prefer_early_return
269+
if (true) {
270+
_doSomething();
271+
}
272+
273+
return;
274+
}
275+
276+
void threeSeqentialIfWithThrowReturn() {
277+
//no lint
278+
if (false) throw '';
279+
if (true) throw '';
280+
//expect_lint: prefer_early_return
281+
if (true) {
282+
_doSomething();
283+
}
284+
285+
return;
286+
}
287+
288+
void threeSeqentialIfWithThrowReturn2() {
289+
//no lint
290+
if (false) throw '';
291+
//no lint
292+
if (true) {
293+
_doSomething();
294+
}
295+
//expect_lint: prefer_early_return
296+
if (true) {
297+
_doSomething();
298+
}
299+
}

0 commit comments

Comments
 (0)