Add spaces after flow control statements (#126320)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
bool isThereMeaningOfLife = true;
|
||||
|
||||
void main() {
|
||||
if (isThereMeaningOfLife) {}
|
||||
if(isThereMeaningOfLife) {}
|
||||
//^
|
||||
|
||||
switch (isThereMeaningOfLife) {
|
||||
case false:
|
||||
case true:
|
||||
}
|
||||
switch(isThereMeaningOfLife) {
|
||||
// ^
|
||||
case false:
|
||||
case true:
|
||||
}
|
||||
|
||||
for (int index = 0; index < 10; index++) {}
|
||||
for(int index = 0; index < 10; index++) {}
|
||||
// ^
|
||||
|
||||
while (isThereMeaningOfLife) {}
|
||||
while(isThereMeaningOfLife) {}
|
||||
// ^
|
||||
|
||||
try {
|
||||
} catch (e) {}
|
||||
try {
|
||||
} catch(e) {}
|
||||
// ^
|
||||
}
|
||||
@@ -124,6 +124,24 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('analyze.dart - verifySpacesAfterFlowControlStatements', () async {
|
||||
final String result = await capture(() => verifySpacesAfterFlowControlStatements(testRootPath, minimumMatches: 2), shouldHaveErrors: true);
|
||||
final String lines = <String>[
|
||||
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:11: no space after flow control statement',
|
||||
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:18: no space after flow control statement',
|
||||
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:25: no space after flow control statement',
|
||||
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:29: no space after flow control statement',
|
||||
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:35: no space after flow control statement',
|
||||
]
|
||||
.map((String line) => line.replaceAll('/', Platform.isWindows ? r'\' : '/'))
|
||||
.join('\n');
|
||||
expect(result,
|
||||
'╔═╡ERROR╞═══════════════════════════════════════════════════════════════════════\n'
|
||||
'$lines\n'
|
||||
'╚═══════════════════════════════════════════════════════════════════════════════\n'
|
||||
);
|
||||
});
|
||||
|
||||
test('analyze.dart - verifyNoBinaries - positive', () async {
|
||||
final String result = await capture(() => verifyNoBinaries(
|
||||
testRootPath,
|
||||
|
||||
Reference in New Issue
Block a user