Skip to content

Commit 38a6646

Browse files
authored
Minor cleanup for new and future lints (#321)
1 parent b4fd859 commit 38a6646

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+69
-67
lines changed

analysis_options.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ linter:
1616
- avoid_unused_constructor_parameters
1717
- avoid_void_async
1818
- cancel_subscriptions
19+
- combinators_ordering
1920
- directives_ordering
21+
- lines_longer_than_80_chars
2022
- literal_only_boolean_expressions
2123
- missing_whitespace_between_adjacent_strings
2224
- no_adjacent_strings_in_list
@@ -34,6 +36,7 @@ linter:
3436
- type_annotate_public_apis
3537
- unawaited_futures
3638
- unnecessary_lambdas
39+
- unnecessary_library_directive
3740
- unnecessary_parenthesis
3841
- unnecessary_statements
3942
- use_if_null_to_convert_nulls_to_bools

lib/async_html.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import 'dart:async' show Future;
1616

1717
import 'async_core.dart' as core
18-
show createDriver, fromExistingSession, fromExistingSessionSync, WebDriver;
18+
show WebDriver, createDriver, fromExistingSession, fromExistingSessionSync;
1919
import 'src/common/spec.dart';
2020
import 'src/request/async_xhr_request_client.dart';
2121

lib/async_io.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import 'dart:async' show Future;
1616

1717
import 'async_core.dart' as core
1818
show
19+
WebDriver,
20+
WebDriverSpec,
1921
createDriver,
2022
fromExistingSession,
21-
fromExistingSessionSync,
22-
WebDriver,
23-
WebDriverSpec;
23+
fromExistingSessionSync;
2424
import 'src/request/async_io_request_client.dart';
2525

2626
export 'package:webdriver/async_core.dart'

lib/core.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@Deprecated("Use 'package:webdriver/async_core.dart' instead.")
16-
library core;
16+
library;
1717

1818
/// Consider this file as deprecated. This exists as an alias to async_core.dart
1919
/// for backward compatibility.

lib/io.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@Deprecated("Use 'package:webdriver/async_io.dart' instead.")
16-
library io;
16+
library;
1717

1818
/// Consider this file as deprecated. This exists as an alias to async_io.dart
1919
/// for backward compatibility.

lib/src/async/mouse.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class Mouse {
3838
_handler.mouse.buildDownRequest(button),
3939
_handler.mouse.parseDownResponse);
4040

41-
/// Releases the mouse button previously held (where the mouse is currently at).
41+
/// Releases the mouse button previously held (where the mouse is currently).
4242
Future<void> up([MouseButton button = MouseButton.primary]) => _client.send(
4343
_handler.mouse.buildUpRequest(button), _handler.mouse.parseUpResponse);
4444

45-
/// Double-clicks at the current mouse coordinates (set by moveTo).
45+
/// Double-clicks at the current mouse coordinates (set by [moveTo]).
4646
Future<void> doubleClick() => _client.send(
4747
_handler.mouse.buildDoubleClickRequest(),
4848
_handler.mouse.parseDoubleClickResponse);
@@ -52,8 +52,8 @@ class Mouse {
5252
/// If [element] is specified and [xOffset] and [yOffset] are not, will move
5353
/// the mouse to the center of the [element].
5454
///
55-
/// If [xOffset] and [yOffset] are specified, will move the mouse that distance
56-
/// from its current location.
55+
/// If [xOffset] and [yOffset] are specified, will move the mouse
56+
/// that distance from its current location.
5757
///
5858
/// If all three are specified, the behavior will be different
5959
/// for W3C and JsonWire. For W3C, it will use [element] center as the

lib/src/async/stepper.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.stepper;
16-
1715
import 'dart:async';
1816

1917
class Stepper {
2018
const Stepper();
2119

22-
/// returns true if command should be executed, false if should not be executed.
20+
/// Returns `true` if [command] should be executed,
21+
/// `false` if it should not be executed.
2322
Future<bool> step(String method, String command, Object? params) =>
2423
Future.value(true);
2524
}

lib/src/async/web_driver.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ class WebDriver implements SearchContext {
216216

217217
/// Take a screenshot of the current page as PNG as stream of uint8.
218218
///
219-
/// Don't use this method. Prefer [captureScreenshotAsBase64] or
220-
/// [captureScreenshotAsList]. Returning the data as Stream<int> can be very
221-
/// slow.
219+
/// Don't use this method.
220+
/// Prefer [captureScreenshotAsBase64] or [captureScreenshotAsList].
221+
/// Returning the data as `Stream<int>` can be very slow.
222222
@Deprecated('Use captureScreenshotAsBase64 or captureScreenshotAsList!')
223223
Stream<int> captureScreenshot() async* {
224224
yield* Stream.fromIterable(await captureScreenshotAsList());

lib/src/common/exception.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ class WebDriverException implements Exception {
1010
const WebDriverException(this.statusCode, this.message);
1111

1212
@override
13-
String toString() =>
14-
'$runtimeType ($statusCode): ${message?.isEmpty ?? true ? '<no message>' : message!}';
13+
String toString() {
14+
final errorMessage = switch (message) {
15+
final message? when message.isNotEmpty => message,
16+
_ => '<no message>',
17+
};
18+
return '$runtimeType ($statusCode): $errorMessage';
19+
}
1520

1621
@override
1722
bool operator ==(Object other) =>

lib/src/handler/json_wire/element.dart

+10-9
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ class JsonWireElementHandler extends ElementHandler {
131131
parseJsonWireResponse(response)?.toString();
132132

133133
@override
134-
WebDriverRequest buildCssPropertyRequest(String elementId, String name) =>
135-
WebDriverRequest.postRequest('execute', {
136-
'script':
137-
'return window.getComputedStyle(arguments[0]).${_cssPropName(name)};',
138-
'args': [
139-
{jsonWireElementStr: elementId}
140-
]
141-
});
134+
WebDriverRequest buildCssPropertyRequest(String elementId, String name) {
135+
final cssProperty = _cssPropName(name);
136+
return WebDriverRequest.postRequest('execute', {
137+
'script': 'return window.getComputedStyle(arguments[0]).$cssProperty;',
138+
'args': [
139+
{jsonWireElementStr: elementId}
140+
]
141+
});
142+
}
142143

143144
@override
144145
String? parseCssPropertyResponse(WebDriverResponse response) =>
@@ -158,6 +159,6 @@ class JsonWireElementHandler extends ElementHandler {
158159
parseJsonWireResponse(response)?.toString();
159160

160161
/// Convert hyphenated-properties to camelCase.
161-
String _cssPropName(String name) => name.splitMapJoin(RegExp(r'-(\w)'),
162+
static String _cssPropName(String name) => name.splitMapJoin(RegExp(r'-(\w)'),
162163
onMatch: (m) => m.group(1)!.toUpperCase(), onNonMatch: (m) => m);
163164
}

lib/src/request/async_io_request_client.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dart:async';
22
import 'dart:convert';
3-
import 'dart:io' show ContentType, HttpClient, HttpHeaders, HttpClientRequest;
3+
import 'dart:io' show ContentType, HttpClient, HttpClientRequest, HttpHeaders;
44

55
import '../../support/async.dart';
66

lib/src/sync/alert.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Alert {
3838
/// Dismisses the currently displayed alert (may not be the alert for which
3939
/// this object was created).
4040
///
41-
/// Throws [NoSuchAlertException] if there isn't currently an alert.
41+
/// Throws [NoSuchAlertException] if there isn't currently an alert.
4242
void dismiss() {
4343
_client.send(_handler.alert.buildDismissRequest(),
4444
_handler.alert.parseDismissResponse);

lib/support/stdio_stepper.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import 'dart:async' show StreamController;
1616
import 'dart:convert' show Encoding, json;
17-
import 'dart:io' show exit, Stdin, stdin, systemEncoding;
17+
import 'dart:io' show Stdin, exit, stdin, systemEncoding;
1818

1919
import '../src/async/stepper.dart';
2020

@@ -75,8 +75,8 @@ class StdioStepper implements Stepper {
7575
}
7676
}
7777

78-
/// Converts a Stream<List<int> | int> to Stream<String> that fires an event
79-
/// for every line of data in the original Stream.
78+
/// Converts a `Stream<List<int> | int>` to `Stream<String>` that
79+
/// fires an event for every line of data in the original [Stream].
8080
class LineReader {
8181
static const cr = 13;
8282
static const lf = 10;
@@ -98,7 +98,7 @@ class LineReader {
9898
onDone: _controller.close, onError: _controller.addError);
9999
}
100100

101-
void _listen(/* List<int> | int */ data) {
101+
void _listen(Object? /* List<int> | int */ data) {
102102
if (data is List<int>) {
103103
data.forEach(_addByte);
104104
} else {

lib/sync_io.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import 'src/request/sync_http_request_client.dart';
1616
import 'sync_core.dart' as core
17-
show createDriver, fromExistingSession, WebDriver, WebDriverSpec;
17+
show WebDriver, WebDriverSpec, createDriver, fromExistingSession;
1818

1919
export 'package:webdriver/sync_core.dart'
2020
hide createDriver, fromExistingSession;

test/async_alert_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.alert_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_command_event_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.command_event_test;
16+
library;
1717

1818
import 'package:stack_trace/stack_trace.dart';
1919
import 'package:test/test.dart';

test/async_cookies_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.options_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_keyboard_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.keyboard_test;
16+
library;
1717

1818
import 'dart:io';
1919

test/async_logs_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.logs_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_mouse_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.mouse_test;
16+
library;
1717

1818
import 'dart:async';
1919

test/async_navigation_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.navigation_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_target_locator_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.target_locator_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_timeouts_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.options_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_web_driver_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.web_driver_test;
16+
library;
1717

1818
import 'dart:async';
1919

test/async_web_element_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.web_element_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/async_core.dart';

test/async_window_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.window_test;
16+
library;
1717

1818
import 'dart:async';
1919
import 'dart:math' show Point, Rectangle;

test/support/async_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.support.async_test;
16-
1715
import 'dart:async' show Future, unawaited;
1816

1917
import 'package:test/test.dart';

test/support/firefox_profile_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
@Tags(['ff'])
1616
@TestOn('vm')
17-
library webdriver.support.firefox_profile_test;
17+
library;
1818

19-
import 'dart:convert' show base64, Encoding, utf8;
19+
import 'dart:convert' show Encoding, base64, utf8;
2020
import 'dart:io' as io;
2121

2222
import 'package:archive/archive_io.dart' as archive;

test/sync/alert.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.alert_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/sync_core.dart';

test/sync/basic_sync.dart

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
library webdriver.support.async_test;
16-
1715
import 'package:test/test.dart';
1816
import 'package:webdriver/sync_io.dart';
1917

test/sync/command_event.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.command_event_test;
16+
library;
1717

1818
import 'package:stack_trace/stack_trace.dart';
1919
import 'package:test/test.dart';

test/sync/cookies.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.options_test;
16+
library;
1717

1818
import 'package:test/test.dart';
1919
import 'package:webdriver/sync_core.dart';

test/sync/keyboard.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
@TestOn('vm')
16-
library webdriver.keyboard_test;
16+
library;
1717

1818
import 'dart:io';
1919

0 commit comments

Comments
 (0)