Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Aug 15, 2024
1 parent 3dfd220 commit 7dc8aee
Show file tree
Hide file tree
Showing 33 changed files with 88 additions and 42 deletions.
15 changes: 13 additions & 2 deletions packages/process_run/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,32 @@ analyzer:

linter:
rules:
- public_member_api_docs
- always_declare_return_types
- avoid_dynamic_calls
- avoid_print
- avoid_slow_async_io
- cancel_subscriptions
- deprecated_member_use_from_same_package
- directives_ordering
- implicit_reopen
- invalid_case_patterns
- invalid_runtime_check_with_js_interop_types
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_literal_bool_comparisons
- no_self_assignments
- omit_local_variable_types
- package_api_docs
- package_prefixed_library_names
- prefer_const_constructors
- prefer_const_literals_to_create_immutables
- prefer_if_elements_to_conditional_expressions
- prefer_single_quotes
- public_member_api_docs
- sort_child_properties_last
- test_types_in_equals
- throw_in_finally
- unawaited_futures
- unnecessary_null_aware_assignments
- unnecessary_statements
- unsafe_html
5 changes: 3 additions & 2 deletions packages/process_run/example/dart_bin_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'dart:async';

import 'package:process_run/cmd_run.dart';
import 'package:process_run/shell.dart';
import 'package:process_run/stdio.dart';

Future main() async {
print('dart: ${await which('dart')}');
stdout.writeln('dart: ${await which('dart')}');
var dartBinVersion = await getDartBinVersion();
print('dartBinVersion: $dartBinVersion');
stdout.writeln('dartBinVersion: $dartBinVersion');
await Shell().run('dart --version');
}
3 changes: 2 additions & 1 deletion packages/process_run/example/demo_sync.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ void main() {
// This is a synchronous call and will block until the child process terminates.
var results = shell.runSync('echo "Hello world"');
var result = results.first;
print('output: "${result.outText.trim()}" exitCode: ${result.exitCode}');
stdout.writeln(
'output: "${result.outText.trim()}" exitCode: ${result.exitCode}');
// should display: output: "Hello world" exitCode: 0

// Run the command
Expand Down
5 changes: 3 additions & 2 deletions packages/process_run/example/flutter_bin_version.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:process_run/cmd_run.dart';
import 'package:process_run/stdio.dart';
import 'package:process_run/which.dart';

Future main() async {
print('flutter: ${await which('flutter')}');
stdout.writeln('flutter: ${await which('flutter')}');
var flutterBinVersion = await getFlutterBinVersion();
print('flutterBinVersion: $flutterBinVersion');
stdout.writeln('flutterBinVersion: $flutterBinVersion');
}
9 changes: 5 additions & 4 deletions packages/process_run/example/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import 'dart:async';

import 'package:process_run/cmd_run.dart' show flutterExecutablePath;
import 'package:process_run/shell.dart';
import 'package:process_run/stdio.dart';

Future main() async {
print('dartExecutable: $dartExecutable');
print('flutterExecutablePath: $flutterExecutablePath');
print('which(\'dart\'): ${await which('dart')}');
print('which(\'flutter\'): ${await which('flutter')}');
stdout.writeln('dartExecutable: $dartExecutable');
stdout.writeln('flutterExecutablePath: $flutterExecutablePath');
stdout.writeln('which(\'dart\'): ${await which('dart')}');
stdout.writeln('which(\'flutter\'): ${await which('flutter')}');
await run('dart --version');
}
4 changes: 3 additions & 1 deletion packages/process_run/example/my_script.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:process_run/stdio.dart';

void main(List<String> arguments) {
print(arguments);
stdout.writeln(arguments);
}
3 changes: 2 additions & 1 deletion packages/process_run/example/no_env_user_paths.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:process_run/src/user_config.dart';
import 'package:process_run/stdio.dart';

Future main() async {
var userPaths = getUserPaths(<String, String>{});
for (var path in userPaths) {
print(path);
stdout.writeln(path);
}
}
5 changes: 3 additions & 2 deletions packages/process_run/example/prompt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import 'dart:async';

import 'package:process_run/shell_run.dart';
import 'package:process_run/src/prompt.dart';
import 'package:process_run/stdio.dart';

Future main() async {
print(await prompt('Enter your name'));
print(await promptConfirm('Action'));
stdout.writeln(await prompt('Enter your name'));
stdout.writeln(await promptConfirm('Action'));
await promptTerminate();
}
2 changes: 2 additions & 0 deletions packages/process_run/example/shell/shell_common.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

import 'package:process_run/shell.dart';

Future<void> main() async {
Expand Down
1 change: 1 addition & 0 deletions packages/process_run/example/streamer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Future main(List<String> arguments) async {
await Future<void>.delayed(Duration(microseconds: delay));
}
index++;
// ignore: avoid_print
print('[$index]');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/process_run/example/user_paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import 'package:process_run/src/user_config.dart';
Future main() async {
var userPaths = getUserPaths(Platform.environment);
for (var path in userPaths) {
print(path);
stdout.writeln(path);
}
}
2 changes: 1 addition & 1 deletion packages/process_run/lib/src/bin/shell/env_delete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ShellEnvDeleteCommand extends ShellEnvCommandBase {
FutureOr<bool> onRun() async {
var path = envFilePath;
if (verbose!) {
print('envFilePath: $path');
stdout.writeln('envFilePath: $path');
}
var force = getFlag(flagForce)!;

Expand Down
4 changes: 2 additions & 2 deletions packages/process_run/lib/src/bin/shell/env_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ShellEnvEditCommand extends ShellEnvCommandBase {
@override
FutureOr<bool> onRun() async {
if (verbose!) {
print('envFilePath: $envFilePath');
stdout.writeln('envFilePath: $envFilePath');
}
await envFileReadOrCreate(write: true);

Expand Down Expand Up @@ -41,7 +41,7 @@ class ShellEnvEditCommand extends ShellEnvCommandBase {
await doRun('vi ${shellArgument(envFilePath!)}');
return true;
}
print('no editor found');
stdout.writeln('no editor found');
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/process_run/lib/src/bin/shell/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ShellRunCommand extends ShellBinCommand {
exit(1);
}
if (verbose!) {
print('command: $command');
stdout.writeln('command: $command');
}
await run(command);
return true;
Expand Down
7 changes: 5 additions & 2 deletions packages/process_run/lib/src/common/dev_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:meta/meta.dart';

void _devPrint(Object object) {
if (_devPrintEnabled) {
// ignore: avoid_print
print(object);
}
}
Expand All @@ -14,11 +15,11 @@ bool _devPrintEnabled = true;
@Deprecated('Dev only')
set devPrintEnabled(bool enabled) => _devPrintEnabled = enabled;

@Deprecated('Dev only')

/// Print only in dev mode
@Deprecated('Dev only')
void devPrint(Object? object) {
if (_devPrintEnabled) {
// ignore: avoid_print
print(object);
}
}
Expand All @@ -34,7 +35,9 @@ void _devError([Object? msg]) {
throw UnsupportedError('$msg');
} catch (e, st) {
if (_devPrintEnabled) {
// ignore: avoid_print
print('# ERROR $msg');
// ignore: avoid_print
print(st);
}
rethrow;
Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/lib/src/lines_utils_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Stream<String> shellStreamLines(Stream<List<int>> stream,
ctlr.add(encoding!.decode(currentLine!));
} catch (_) {
// Ignore bad encoding
// ignore: avoid_print
print('ignoring: $currentLine');
}
}
Expand All @@ -97,6 +98,7 @@ Stream<String> shellStreamLines(Stream<List<int>> stream,
ctlr = StreamController<String>(
onPause: () {
if (shellDebug) {
// ignore: avoid_print
print('onPause (paused: ${subscription?.isPaused})');
}
// Last one
Expand Down
3 changes: 3 additions & 0 deletions packages/process_run/lib/src/process_run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Future<ProcessResult> runExecutableArguments(
includeParentEnvironment: false,
runInShell: runInShell);
if (shellDebug) {
// ignore: avoid_print
print('process: ${process.pid}');
}
if (onProcess != null) {
Expand All @@ -92,8 +93,10 @@ Future<ProcessResult> runExecutableArguments(
() async {
try {
var exitCode = await process.exitCode;
// ignore: avoid_print
print('process: ${process.pid} exitCode $exitCode');
} catch (e) {
// ignore: avoid_print
print('process: ${process.pid} Error $e waiting exit code');
}
}();
Expand Down
9 changes: 9 additions & 0 deletions packages/process_run/lib/src/shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ abstract class Shell implements ShellCore, ShellCoreSync {

void _clearPreviousContext() {
if (shellDebug) {
// ignore: avoid_print
print(
'Clear previous context ${_currentProcessResultCompleter?.isCompleted}');
}
Expand Down Expand Up @@ -485,6 +486,7 @@ abstract class Shell implements ShellCore, ShellCoreSync {

try {
if (shellDebug) {
// ignore: avoid_print
print('$_runId: Before $processCmd');
}

Expand All @@ -498,6 +500,7 @@ abstract class Shell implements ShellCore, ShellCoreSync {
workingDirectory: _options.workingDirectory);
} finally {
if (shellDebug) {
// ignore: avoid_print
print(
'$_runId: After $executableFullPath exitCode ${processResult?.exitCode}');
}
Expand Down Expand Up @@ -566,6 +569,7 @@ abstract class Shell implements ShellCore, ShellCoreSync {
try {
// devPrint(_options.environment.keys.where((element) => element.contains('TEKARTIK')));
if (shellDebug) {
// ignore: avoid_print
print('$_runId: Before $processCmd');
}

Expand All @@ -582,13 +586,15 @@ abstract class Shell implements ShellCore, ShellCoreSync {
_currentProcessCmd = processCmd;
_currentProcessRunId = runId;
if (shellDebug) {
// ignore: avoid_print
print('onProcess ${_currentProcessToString()}');
}
if (onProcess != null) {
onProcess(process);
}
if (_killedRunId >= _runId) {
if (shellDebug) {
// ignore: avoid_print
print('shell was killed');
}
_kill();
Expand All @@ -597,6 +603,7 @@ abstract class Shell implements ShellCore, ShellCoreSync {
});
} finally {
if (shellDebug) {
// ignore: avoid_print
print(
'$_runId: After $processCmd exitCode ${processResult?.exitCode}');
}
Expand Down Expand Up @@ -637,13 +644,15 @@ abstract class Shell implements ShellCore, ShellCoreSync {

run().then((value) {
if (shellDebug) {
// ignore: avoid_print
print('$runId: done');
}
if (!completer.isCompleted) {
completer.complete(value);
}
}).catchError((Object e) {
if (shellDebug) {
// ignore: avoid_print
print('$runId: error $e');
}
if (!completer.isCompleted) {
Expand Down
2 changes: 1 addition & 1 deletion packages/process_run/lib/src/stdio/shell_streamer_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ShellOutputLinesStreamerIo
set current(bool current) {
if (this.current != current) {
super.current = current;
if (current == true) {
if (current) {
dump();
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/dart_doc_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.dartdoc_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/dartbin_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.dartbin_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/data/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

void main() {
print('Hello');
}
2 changes: 2 additions & 0 deletions packages/process_run/test/process_run_in_test2_.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.process_run_in_test2_;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/process_run_in_test_.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.process_run_in_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/process_run_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.process_run_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/shell_common_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

library process_run.test.shell_common_api_test;

import 'dart:async';
Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/shell_environment_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.test.shell_environment_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/shell_run_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.test.shell_run_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/shell_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.test.shell_test;

Expand Down
2 changes: 2 additions & 0 deletions packages/process_run/test/which_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

@TestOn('vm')
library process_run.which_test;

Expand Down
Loading

0 comments on commit 7dc8aee

Please sign in to comment.