Skip to content

Commit 22e11a7

Browse files
committed
Merge pull request #110 from Workiva/formatter-updates
CP-1167 Dart formatter updates for dart_dev, dart_style 0.2.1.
2 parents 2fe5772 + 8554f6f commit 22e11a7

File tree

12 files changed

+41
-36
lines changed

12 files changed

+41
-36
lines changed

lib/src/platform_util/platform_util.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ PlatformUtil platformUtil = new StandardPlatformUtil();
2222

2323
abstract class PlatformUtil {
2424
static PlatformUtil retrieve() {
25-
if (platformUtil == null) throw new StateError(
26-
'dart_dev\'s PlatformUtil instance must not be null.');
25+
if (platformUtil == null)
26+
throw new StateError(
27+
'dart_dev\'s PlatformUtil instance must not be null.');
2728
return platformUtil;
2829
}
2930

lib/src/task_process.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class TaskProcess {
4646
_outc.future.then((_) => _stdout.close());
4747
_errc.future.then((_) => _stderr.close());
4848
process.exitCode.then(_procExitCode.complete);
49-
Future.wait([_outc.future, _errc.future, process.exitCode])
50-
.then((_) => _donec.complete());
49+
Future.wait([_outc.future, _errc.future, process.exitCode]).then(
50+
(_) => _donec.complete());
5151
});
5252
}
5353

lib/src/tasks/copy_license/api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ CopyLicenseTask copyLicense(
2626
CopyLicenseTask task = new CopyLicenseTask();
2727

2828
File license = new File(licensePath);
29-
if (!license.existsSync()) throw new Exception(
30-
'License file "$licensePath" does not exist.');
29+
if (!license.existsSync())
30+
throw new Exception('License file "$licensePath" does not exist.');
3131

3232
String licenseContents = license.readAsStringSync();
3333
licenseContents = trimLeadingAndTrailingEmptyLines(licenseContents);

lib/src/tasks/copy_license/cli.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CopyLicenseCli extends TaskCli {
3232
List<String> directories = config.copyLicense.directories;
3333
String licensePath = config.copyLicense.licensePath;
3434

35-
if (!(new File(licensePath)).existsSync()) return new CliResult.fail(
36-
'License file "$licensePath" does not exist.');
35+
if (!(new File(licensePath)).existsSync())
36+
return new CliResult.fail('License file "$licensePath" does not exist.');
3737

3838
CopyLicenseTask task =
3939
copyLicense(directories: directories, licensePath: licensePath);

lib/src/tasks/coverage/api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ class CoverageTask extends Task {
310310
}
311311

312312
File _merge(List<File> collections) {
313-
if (collections.isEmpty) throw new ArgumentError(
314-
'Cannot merge an empty list of coverages.');
313+
if (collections.isEmpty)
314+
throw new ArgumentError('Cannot merge an empty list of coverages.');
315315

316316
Map mergedJson = JSON.decode(collections.first.readAsStringSync());
317317
for (int i = 1; i < collections.length; i++) {

lib/src/tasks/coverage/cli.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class CoverageCli extends TaskCli {
5252
final String command = 'coverage';
5353

5454
Future<CliResult> run(ArgResults parsedArgs) async {
55-
if (!platform_util
56-
.hasImmediateDependency('coverage')) return new CliResult.fail(
57-
'Package "coverage" must be an immediate dependency in order to run its executables.');
55+
if (!platform_util.hasImmediateDependency('coverage'))
56+
return new CliResult.fail(
57+
'Package "coverage" must be an immediate dependency in order to run its executables.');
5858

5959
bool unit = parsedArgs['unit'];
6060
bool integration = parsedArgs['integration'];

lib/src/tasks/docs/cli.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ class DocsCli extends TaskCli {
3232
final String command = 'docs';
3333

3434
Future<CliResult> run(ArgResults parsedArgs) async {
35-
if (!hasImmediateDependency('dartdoc')) return new CliResult.fail(
36-
'Package "dartdoc" must be an immediate dependency in order to run its executables.');
35+
if (!hasImmediateDependency('dartdoc'))
36+
return new CliResult.fail(
37+
'Package "dartdoc" must be an immediate dependency in order to run its executables.');
3738

3839
bool open = TaskCli.valueOf('open', parsedArgs, true);
3940

lib/src/tasks/examples/api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ bool hasExamples() {
2929

3030
ExamplesTask serveExamples(
3131
{String hostname: defaultHostname, int port: defaultPort}) {
32-
if (!hasExamples()) throw new Exception(
33-
'This project does not have any examples.');
32+
if (!hasExamples())
33+
throw new Exception('This project does not have any examples.');
3434

3535
var dartiumExecutable = 'dartium';
3636
var dartiumArgs = ['http://$hostname:$port'];

lib/src/tasks/examples/cli.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class ExamplesCli extends TaskCli {
4343
port = int.parse(port);
4444
}
4545

46-
if (!hasExamples()) return new CliResult.fail(
47-
'This project does not have any examples.');
46+
if (!hasExamples())
47+
return new CliResult.fail('This project does not have any examples.');
4848

4949
ExamplesTask task = serveExamples(hostname: hostname, port: port);
5050
reporter.logGroup(task.pubServeCommand,

lib/src/tasks/format/cli.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class FormatCli extends TaskCli {
4040

4141
Future<CliResult> run(ArgResults parsedArgs) async {
4242
try {
43-
if (!platform_util
44-
.hasImmediateDependency('dart_style')) return new CliResult.fail(
45-
'Package "dart_style" must be an immediate dependency in order to run its executables.');
43+
if (!platform_util.hasImmediateDependency('dart_style'))
44+
return new CliResult.fail(
45+
'Package "dart_style" must be an immediate dependency in order to run its executables.');
4646
} catch (e) {
4747
// It's possible that this check may throw if the pubspec.yaml
4848
// could not be found or if the yaml could not be parsed.
@@ -77,18 +77,20 @@ class FormatCli extends TaskCli {
7777
}
7878

7979
if (task.isDryRun) {
80-
if (task.successful) return new CliResult.success(
81-
excludedFilesWarning + 'Your Dart code is good to go!');
82-
if (task.affectedFiles.isEmpty) return new CliResult.fail(
83-
excludedFilesWarning + 'The Dart formatter needs to be run.');
80+
if (task.successful)
81+
return new CliResult.success(
82+
excludedFilesWarning + 'Your Dart code is good to go!');
83+
if (task.affectedFiles.isEmpty)
84+
return new CliResult.fail(
85+
excludedFilesWarning + 'The Dart formatter needs to be run.');
8486
return new CliResult.fail(excludedFilesWarning +
8587
'The Dart formatter needs to be run. The following files require changes:\n ' +
8688
task.affectedFiles.join('\n '));
8789
} else {
8890
if (!task.successful) return new CliResult.fail('Dart formatter failed.');
89-
if (task.affectedFiles.isEmpty) return new CliResult.success(
90-
excludedFilesWarning +
91-
'Success! All files are already formatted correctly.');
91+
if (task.affectedFiles.isEmpty)
92+
return new CliResult.success(excludedFilesWarning +
93+
'Success! All files are already formatted correctly.');
9294
return new CliResult.success(excludedFilesWarning +
9395
'Success! The following files were formatted:\n ' +
9496
task.affectedFiles.join('\n '));

0 commit comments

Comments
 (0)