Skip to content

Commit 16fb747

Browse files
authored
Merge pull request #14 from jwren/update-analysis-options-strict-types
Enable strict analysis options and resolve type warnings
2 parents 1b30826 + cbec08b commit 16fb747

File tree

7 files changed

+57
-39
lines changed

7 files changed

+57
-39
lines changed

tool/analysis_options.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313

1414
include: package:lints/recommended.yaml
1515

16-
# Uncomment the following section to specify additional rules.
17-
18-
# analyzer:
19-
# exclude:
20-
# - path/to/excluded/files/**
21-
22-
# For more information about the core and recommended set of lints, see
23-
# https://dart.dev/go/core-lints
24-
2516
linter:
2617
# The lint rules applied to this project can be customized in the
2718
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
@@ -35,6 +26,8 @@ linter:
3526
# producing the lint.
3627
rules:
3728
# Error Prevention
29+
unnecessary_statements: true
30+
no_self_assignments: true
3831
avoid_catches_without_on_clauses: true
3932
avoid_catching_errors: true
4033
avoid_returning_this: true
@@ -113,6 +106,7 @@ linter:
113106
unnecessary_string_interpolations: true
114107
unnecessary_this: true
115108
use_function_type_syntax_for_parameters: true
109+
use_if_null_to_convert_nulls_to_bools: true
116110
use_string_buffers: true
117111
use_to_and_as_if_applicable: true
118112

@@ -128,11 +122,22 @@ linter:
128122
library_private_types_in_public_api: true
129123
prefer_asserts_in_initializer_lists: true
130124
prefer_constructors_over_static_methods: true
125+
secure_pubspec_urls: true
126+
sort_pub_dependencies: true
127+
unnecessary_to_list_in_spreads: true
128+
use_super_parameters: true
129+
annotate_overrides: true
131130

132131
# Documentation
133132
dangling_library_doc_comments: true
134133
library_annotations: true
135134
public_member_api_docs: true
136135

136+
analyzer:
137+
language:
138+
strict-casts: true
139+
strict-inference: true
140+
strict-raw-types: true
141+
137142
# Additional information about this file can be found at
138143
# https://dart.dev/guides/language/analysis-options

tool/bin/skills.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const String version = '0.1.0';
1515
void main(List<String> arguments) async {
1616
final httpClient = http.Client();
1717

18-
final runner = CommandRunner('skills', 'A sample command-line application.')
19-
..addCommand(GenerateSkillCommand(httpClient: httpClient))
20-
..addCommand(ValidateSkillCommand(httpClient: httpClient));
18+
final runner =
19+
CommandRunner<void>('skills', 'A sample command-line application.')
20+
..addCommand(GenerateSkillCommand(httpClient: httpClient))
21+
..addCommand(ValidateSkillCommand(httpClient: httpClient));
2122

2223
runner.argParser.addFlag(
2324
'version',

tool/lib/src/commands/base_skill_command.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import '../models/skill_params.dart';
1414
import '../services/gemini_service.dart';
1515

1616
/// Base command for skill operations.
17-
abstract class BaseSkillCommand extends Command {
17+
abstract class BaseSkillCommand extends Command<void> {
1818
/// Creates a new [BaseSkillCommand].
1919
BaseSkillCommand({
2020
required this.httpClient,
@@ -64,7 +64,11 @@ abstract class BaseSkillCommand extends Command {
6464
final yamlContent = file.readAsStringSync();
6565
final yamlList = loadYaml(yamlContent) as YamlList;
6666
final skills = yamlList
67-
.map((e) => SkillParams.fromJson(jsonDecode(jsonEncode(e))))
67+
.map(
68+
(e) => SkillParams.fromJson(
69+
jsonDecode(jsonEncode(e)) as Map<String, dynamic>,
70+
),
71+
)
6872
.toList();
6973

7074
final skillFilter = argResults?['skill'] as String?;
@@ -95,7 +99,7 @@ abstract class BaseSkillCommand extends Command {
9599

96100
int thinkingBudget;
97101
try {
98-
thinkingBudget = int.parse(argResults!['thinking-budget']);
102+
thinkingBudget = int.parse(argResults!['thinking-budget'] as String);
99103
} on FormatException {
100104
logger.warning(
101105
'Invalid thinking-budget: ${argResults!['thinking-budget']}. Skipping.',

tool/test/commands/base_skill_command_test.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _TestSkillCommand extends BaseSkillCommand {
3636

3737
void main() {
3838
group('BaseSkillCommand Edge Cases', () {
39-
late CommandRunner runner;
39+
late CommandRunner<void> runner;
4040
late Directory tempDir;
4141
late MockClient mockClient;
4242
final logs = <String>[];
@@ -46,7 +46,7 @@ void main() {
4646
'base_skill_commands_test',
4747
);
4848
mockClient = MockClient((request) async => throw UnimplementedError());
49-
runner = CommandRunner('skills', 'Test runner')
49+
runner = CommandRunner<void>('skills', 'Test runner')
5050
..addCommand(_TestSkillCommand(httpClient: mockClient));
5151

5252
Logger.root.level = Level.INFO;
@@ -71,8 +71,12 @@ void main() {
7171
test('logs warning when no skills match the --skill filter', () async {
7272
final configFile = File(p.join(tempDir.path, 'config.yaml'));
7373
await configFile.writeAsString(
74-
jsonEncode([
75-
{'name': 'existent-skill', 'description': 'desc', 'resources': []},
74+
jsonEncode(<Map<String, dynamic>>[
75+
{
76+
'name': 'existent-skill',
77+
'description': 'desc',
78+
'resources': <String>[],
79+
},
7680
]),
7781
);
7882

@@ -102,8 +106,12 @@ void main() {
102106
test('logs severe error when GEMINI_API_KEY is not set', () async {
103107
final configFile = File(p.join(tempDir.path, 'config.yaml'));
104108
await configFile.writeAsString(
105-
jsonEncode([
106-
{'name': 'existent-skill', 'description': 'desc', 'resources': []},
109+
jsonEncode(<Map<String, dynamic>>[
110+
{
111+
'name': 'existent-skill',
112+
'description': 'desc',
113+
'resources': <String>[],
114+
},
107115
]),
108116
);
109117

tool/test/generate_skills_retry_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import 'package:test/test.dart';
1515

1616
void main() {
1717
group('GenerateSkillsCommand Retry Logic', () {
18-
late CommandRunner runner;
18+
late CommandRunner<void> runner;
1919
late Directory tempDir;
2020
late File inputFile;
2121

2222
setUp(() async {
2323
tempDir = await Directory.systemTemp.createTemp('skills_retry_test');
2424
inputFile = File(p.join(tempDir.path, 'input.yaml'));
25-
runner = CommandRunner('skills', 'Test runner');
25+
runner = CommandRunner<void>('skills', 'Test runner');
2626
});
2727

2828
tearDown(() async {

tool/test/generate_skills_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import 'package:test/test.dart';
1515

1616
void main() {
1717
group('GenerateSkillsCommand', () {
18-
late CommandRunner runner;
18+
late CommandRunner<void> runner;
1919
late Directory tempDir;
2020
late File videoFile;
2121

2222
setUp(() async {
2323
tempDir = await Directory.systemTemp.createTemp('skills_gen_test');
2424
videoFile = File(p.join(tempDir.path, 'input.yaml'));
25-
runner = CommandRunner('skills', 'Test runner');
25+
runner = CommandRunner<void>('skills', 'Test runner');
2626
});
2727

2828
tearDown(() async {

tool/test/validate_skills_test.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'package:test/test.dart';
1515

1616
void main() {
1717
group('ValidateSkillCommand', () {
18-
late CommandRunner runner;
18+
late CommandRunner<void> runner;
1919
late Directory tempDir;
2020
late Directory skillsDir;
2121
late Directory validationDir;
@@ -64,7 +64,7 @@ void main() {
6464
]),
6565
);
6666

67-
runner = CommandRunner('skills', 'Test runner')
67+
runner = CommandRunner<void>('skills', 'Test runner')
6868
..addCommand(
6969
ValidateSkillCommand(
7070
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -134,7 +134,7 @@ void main() {
134134
return http.Response('Not Found', 404);
135135
});
136136

137-
runner = CommandRunner('skills', 'Test runner')
137+
runner = CommandRunner<void>('skills', 'Test runner')
138138
..addCommand(
139139
ValidateSkillCommand(
140140
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -179,7 +179,7 @@ void main() {
179179
]),
180180
);
181181

182-
runner = CommandRunner('skills', 'Test runner')
182+
runner = CommandRunner<void>('skills', 'Test runner')
183183
..addCommand(
184184
ValidateSkillCommand(
185185
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -200,7 +200,7 @@ void main() {
200200
test('logs severe error when config file not found', () async {
201201
final path = p.join(tempDir.path, 'NON_EXISTENT.yaml');
202202

203-
runner = CommandRunner('skills', 'Test runner')
203+
runner = CommandRunner<void>('skills', 'Test runner')
204204
..addCommand(
205205
ValidateSkillCommand(
206206
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -245,7 +245,7 @@ void main() {
245245
return http.Response('Not Found', 404);
246246
});
247247

248-
runner = CommandRunner('skills', 'Test runner')
248+
runner = CommandRunner<void>('skills', 'Test runner')
249249
..addCommand(
250250
ValidateSkillCommand(
251251
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -283,7 +283,7 @@ void main() {
283283
throw Exception('Network Error');
284284
});
285285

286-
runner = CommandRunner('skills', 'Test runner')
286+
runner = CommandRunner<void>('skills', 'Test runner')
287287
..addCommand(
288288
ValidateSkillCommand(
289289
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -332,7 +332,7 @@ void main() {
332332
return http.Response('Not Found', 404);
333333
});
334334

335-
runner = CommandRunner('skills', 'Test runner')
335+
runner = CommandRunner<void>('skills', 'Test runner')
336336
..addCommand(
337337
ValidateSkillCommand(
338338
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -382,7 +382,7 @@ void main() {
382382
return http.Response('Not Found', 404);
383383
});
384384

385-
runner = CommandRunner('skills', 'Test runner')
385+
runner = CommandRunner<void>('skills', 'Test runner')
386386
..addCommand(
387387
ValidateSkillCommand(
388388
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -430,7 +430,7 @@ void main() {
430430
return http.Response('Not Found', 404);
431431
});
432432

433-
runner = CommandRunner('skills', 'Test runner')
433+
runner = CommandRunner<void>('skills', 'Test runner')
434434
..addCommand(
435435
ValidateSkillCommand(
436436
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -510,7 +510,7 @@ Content
510510
return http.Response('Not Found', 404);
511511
});
512512

513-
runner = CommandRunner('skills', 'Test runner')
513+
runner = CommandRunner<void>('skills', 'Test runner')
514514
..addCommand(
515515
ValidateSkillCommand(
516516
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -551,7 +551,7 @@ Content
551551
(request) async => http.Response('', 200),
552552
);
553553

554-
runner = CommandRunner('skills', 'Test runner')
554+
runner = CommandRunner<void>('skills', 'Test runner')
555555
..addCommand(
556556
ValidateSkillCommand(
557557
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -591,7 +591,7 @@ Content
591591
(request) async => throw Exception('Generic Error'),
592592
);
593593

594-
runner = CommandRunner('skills', 'Test runner')
594+
runner = CommandRunner<void>('skills', 'Test runner')
595595
..addCommand(
596596
ValidateSkillCommand(
597597
environment: {'GEMINI_API_KEY': 'test-key'},
@@ -651,7 +651,7 @@ Content
651651
return http.Response('Not Found', 404);
652652
});
653653

654-
runner = CommandRunner('skills', 'Test runner')
654+
runner = CommandRunner<void>('skills', 'Test runner')
655655
..addCommand(
656656
ValidateSkillCommand(
657657
environment: {'GEMINI_API_KEY': 'test-key'},

0 commit comments

Comments
 (0)