dart-lang / dart-lang/source_gen
SharedPartBuilder partId validation regex and error message are inconsistent
- Dominant language
- Dart
- Stars
- 494
- Forks
- 115
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 3
Description
https://github.com/dart-lang/source_gen/blob/master/source_gen/lib/src/builder.dart
If `partId` provided to the SharedPartBuilder doesn't meet regex validation, an error is thrown:
```dart
if (!_partIdRegExp.hasMatch(partId)) {
throw ArgumentError.value(
partId,
'partId',
'`partId` can only contain letters, numbers, `_` and `.`. '
'It cannot start or end with `.`.',
);
}
```
It states `partId` can contain a period, however, here's the regex:
```dart
const partIdRegExpLiteral = r'[A-Za-z_\d-]+';
final _partIdRegExp = RegExp('^$partIdRegExpLiteral\$');
```
As you can see, no period is allowed.
Either the error message or regex should be updated to be consistent.
Contributor guide
Research direction
Open source_gen/lib/src/builder.dart and inspect SharedPartBuilder's partId validation and its ArgumentError message. Make the regex and message describe the same allowed characters, then run the relevant source_gen tests to confirm the validation and error wording are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100