Skip to content

Commit

Permalink
Update min SDK and a number of lints
Browse files Browse the repository at this point in the history
Update dev dependencies
  • Loading branch information
kevmoo committed Aug 2, 2024
1 parent 32fffa5 commit c6c9728
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 165 deletions.
58 changes: 43 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,67 @@
name: Dart

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github

permissions: read-all

jobs:
build:
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [ dev ]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

test:
needs: analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.4, dev]

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- uses: nanasess/setup-chromedriver@42cc2998329f041de87dc3cfa33a930eacd57eaa

- name: Install dependencies
run: dart pub get

- name: Validate formatting
run: dart format --output=none --set-exit-if-changed .

- name: Analyze source code
run: dart analyze

# Disabled; tracked via #75.
# - name: Run tests
# run: |
# export DISPLAY=:99
# chromedriver --port=4444 --url-base=/wd/hub &
# sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
# dart test
# env:
# CHROMEDRIVER_ARGS: '--no-sandbox --headless'
- name: Run tests
run: |
export DISPLAY=:99
chromedriver --port=4444 --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
dart test
env:
CHROMEDRIVER_ARGS: '--no-sandbox --headless'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.2-wip

- Require SDK `sdk: ^3.4.0`.

## 1.2.1

- Make the return type of `runtime`'s `ExceptionDetails.url` field nullable.
Expand Down
6 changes: 1 addition & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
errors:
deprecated_member_use_from_same_package: ignore

linter:
rules:
- avoid_dynamic_calls
4 changes: 1 addition & 3 deletions example/multiplex.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright 2015 Google. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.

library wip.multiplex;

import 'dart:io' show stderr;

import 'package:args/args.dart' show ArgParser;
import 'package:logging/logging.dart'
show hierarchicalLoggingEnabled, Level, Logger, LogRecord;
show Level, LogRecord, Logger, hierarchicalLoggingEnabled;
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
show ChromeConnection;

Expand Down
2 changes: 0 additions & 2 deletions example/multiplex_impl.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2015 Google. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.

library wip.multiplex_impl;

import 'dart:async' show Future;
import 'dart:convert' show jsonEncode;
import 'dart:io' show HttpServer, InternetAddress;
Expand Down
10 changes: 4 additions & 6 deletions lib/dom_model.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2015 Google. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.

library wip.dom_model;

import 'dart:async' show EventSink, Future, Stream, StreamTransformer;
import 'dart:collection' show UnmodifiableListView, UnmodifiableMapView;
import 'dart:mirrors' show reflect;
Expand Down Expand Up @@ -112,7 +110,7 @@ class WipDomModel implements WipDom {
void _onChildNodeInserted(
ChildNodeInsertedEvent event, EventSink<ChildNodeInsertedEvent> sink) {
var parent = _getOrCreateNode(event.parentNodeId);
int index =
var index =
parent._children!.indexOf(_getOrCreateNode(event.previousNodeId)) + 1;
var node = _getOrCreateNodeFromNode(event.node);
parent._children!.insert(index, node);
Expand Down Expand Up @@ -147,7 +145,7 @@ class WipDomModel implements WipDom {

@override
Future<Map<String, String>> getAttributes(int nodeId) async {
Map<String, String> attributes = await _dom.getAttributes(nodeId);
var attributes = await _dom.getAttributes(nodeId);
var node = _getOrCreateNode(nodeId);
node._attributes = Map.from(attributes);
return attributes;
Expand All @@ -158,7 +156,7 @@ class WipDomModel implements WipDom {
/// multiple times on the same page.
@override
Future<Node> getDocument() {
_root ??= _dom.getDocument().then((n) => _getOrCreateNodeFromNode(n));
_root ??= _dom.getDocument().then(_getOrCreateNodeFromNode);
return _root!;
}

Expand Down Expand Up @@ -303,7 +301,7 @@ class _Node implements Node {
map['childNodeCount'] = childNodeCount!;
}
if (_children != null && _children!.isNotEmpty) {
var newChildren = [];
var newChildren = <Map<dynamic, dynamic>>[];
for (var child in _children!) {
newChildren.add(child._toJsonInternal(visited));
}
Expand Down
8 changes: 3 additions & 5 deletions lib/forwarder.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2015 Google. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.

library crmux.forwarder;

import 'dart:async'
show Future, Stream, StreamController, StreamSink, StreamSubscription;
import 'dart:convert' show jsonDecode, jsonEncode;
Expand All @@ -11,7 +9,7 @@ import 'package:logging/logging.dart' show Logger;

import 'dom_model.dart' show flattenAttributesMap;
import 'webkit_inspection_protocol.dart'
show WipConnection, WipDom, WipError, WipEvent, WipResponse;
show WipConnection, WipDom, WipError, WipEvent;

/// Forwards a [Stream] to a [WipConnection] and events
/// from a [WipConnection] to a [StreamSink].
Expand Down Expand Up @@ -51,7 +49,7 @@ class WipForwarder {
try {
var method = json['method'] as String;
var params = json['params'] as Map<String, dynamic>;
bool processed = false;
var processed = false;

if (method.contains('reakpoint')) {
forwardPausedEvents = true;
Expand All @@ -72,7 +70,7 @@ class WipForwarder {
}
}
if (!processed) {
WipResponse resp = await _debugger.sendCommand(method, params);
var resp = await _debugger.sendCommand(method, params);
if (resp.result != null) {
response['result'] = resp.result;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../webkit_inspection_protocol.dart';

@Deprecated('This domain is deprecated - use Runtime or Log instead')
class WipConsole extends WipDomain {
WipConsole(WipConnection connection) : super(connection);
WipConsole(super.connection);

Future<WipResponse> enable() => sendCommand('Console.enable');

Expand All @@ -25,7 +25,7 @@ class WipConsole extends WipDomain {
}

class ConsoleMessageEvent extends WipEvent {
ConsoleMessageEvent(Map<String, dynamic> json) : super(json);
ConsoleMessageEvent(super.json);

Map get _message => params!['message'] as Map;

Expand All @@ -49,7 +49,7 @@ class ConsoleMessageEvent extends WipEvent {
}

class ConsoleClearedEvent extends WipEvent {
ConsoleClearedEvent(Map<String, dynamic> json) : super(json);
ConsoleClearedEvent(super.json);
}

class WipConsoleCallFrame {
Expand Down
50 changes: 26 additions & 24 deletions lib/src/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../webkit_inspection_protocol.dart';
class WipDebugger extends WipDomain {
final _scripts = <String, WipScript>{};

WipDebugger(WipConnection connection) : super(connection) {
WipDebugger(super.connection) {
onScriptParsed.listen((event) {
_scripts[event.script.scriptId] = event.script;
});
Expand Down Expand Up @@ -55,14 +55,14 @@ class WipDebugger extends WipDomain {
WipLocation location, {
String? condition,
}) async {
Map<String, dynamic> params = {
var params = <String, dynamic>{
'location': location.toJsonMap(),
};
if (condition != null) {
params['condition'] = condition;
}

final WipResponse response =
final response =
await sendCommand('Debugger.setBreakpoint', params: params);

if (response.result!.containsKey('exceptionDetails')) {
Expand Down Expand Up @@ -90,15 +90,15 @@ class WipDebugger extends WipDomain {
String expression, {
bool? returnByValue,
}) async {
Map<String, dynamic> params = {
var params = <String, dynamic>{
'callFrameId': callFrameId,
'expression': expression,
};
if (returnByValue != null) {
params['returnByValue'] = returnByValue;
}

final WipResponse response =
final response =
await sendCommand('Debugger.evaluateOnCallFrame', params: params);

if (response.result!.containsKey('exceptionDetails')) {
Expand All @@ -122,7 +122,7 @@ class WipDebugger extends WipDomain {
WipLocation? end,
bool? restrictToFunction,
}) async {
Map<String, dynamic> params = {
var params = <String, dynamic>{
'start': start.toJsonMap(),
};
if (end != null) {
Expand All @@ -132,15 +132,16 @@ class WipDebugger extends WipDomain {
params['restrictToFunction'] = restrictToFunction;
}

final WipResponse response =
final response =
await sendCommand('Debugger.getPossibleBreakpoints', params: params);

if (response.result!.containsKey('exceptionDetails')) {
throw ExceptionDetails(
response.result!['exceptionDetails'] as Map<String, dynamic>);
} else {
List locations = response.result!['locations'];
return List.from(locations.map((map) => WipBreakLocation(map)));
var locations = response.result!['locations'] as List;
return List.from(locations
.map((map) => WipBreakLocation(map as Map<String, dynamic>)));
}
}

Expand Down Expand Up @@ -187,7 +188,7 @@ String _pauseStateToString(PauseState state) {
enum PauseState { all, none, uncaught }

class ScriptParsedEvent extends WipEvent {
ScriptParsedEvent(Map<String, dynamic> json) : super(json);
ScriptParsedEvent(super.json);

WipScript get script => WipScript(params!);

Expand All @@ -196,17 +197,17 @@ class ScriptParsedEvent extends WipEvent {
}

class GlobalObjectClearedEvent extends WipEvent {
GlobalObjectClearedEvent(Map<String, dynamic> json) : super(json);
GlobalObjectClearedEvent(super.json);
}

class DebuggerResumedEvent extends WipEvent {
DebuggerResumedEvent(Map<String, dynamic> json) : super(json);
DebuggerResumedEvent(super.json);
}

/// Fired when the virtual machine stopped on breakpoint or exception or any
/// other stop criteria.
class DebuggerPausedEvent extends WipEvent {
DebuggerPausedEvent(Map<String, dynamic> json) : super(json);
DebuggerPausedEvent(super.json);

/// Call stack the virtual machine stopped on.
List<WipCallFrame> getCallFrames() => (params!['callFrames'] as List)
Expand All @@ -231,7 +232,7 @@ class DebuggerPausedEvent extends WipEvent {
/// Async stack trace, if any.
StackTrace? get asyncStackTrace => params!['asyncStackTrace'] == null
? null
: StackTrace(params!['asyncStackTrace']);
: StackTrace(params!['asyncStackTrace'] as Map<String, dynamic>);

@override
String toString() => 'paused: $reason';
Expand Down Expand Up @@ -295,11 +296,11 @@ class WipLocation {
}
}

String get scriptId => json['scriptId'];
String get scriptId => json['scriptId'] as String;

int get lineNumber => json['lineNumber'];
int get lineNumber => json['lineNumber'] as int;

int? get columnNumber => json['columnNumber'];
int? get columnNumber => json['columnNumber'] as int?;

Map<String, dynamic> toJsonMap() {
return json;
Expand Down Expand Up @@ -353,11 +354,11 @@ class WipScope {
}

class WipBreakLocation extends WipLocation {
WipBreakLocation(Map<String, dynamic> json) : super(json);
WipBreakLocation(super.json);

WipBreakLocation.fromValues(String scriptId, int lineNumber,
{int? columnNumber, String? type})
: super.fromValues(scriptId, lineNumber, columnNumber: columnNumber) {
WipBreakLocation.fromValues(super.scriptId, super.lineNumber,
{super.columnNumber, String? type})
: super.fromValues() {
if (type != null) {
json['type'] = type;
}
Expand All @@ -369,9 +370,10 @@ class WipBreakLocation extends WipLocation {

/// The response from [WipDebugger.setBreakpoint].
class SetBreakpointResponse extends WipResponse {
SetBreakpointResponse(Map<String, dynamic> json) : super(json);
SetBreakpointResponse(super.json);

String get breakpointId => result!['breakpointId'];
String get breakpointId => result!['breakpointId'] as String;

WipLocation get actualLocation => WipLocation(result!['actualLocation']);
WipLocation get actualLocation =>
WipLocation(result!['actualLocation'] as Map<String, dynamic>);
}
Loading

0 comments on commit c6c9728

Please sign in to comment.