Skip to content

Commit

Permalink
Move from pedantic to lints package (dart-archive/typed_data#49)
Browse files Browse the repository at this point in the history
Fix existing violations of lints:
- `annotate_overrides`
- `avoid_renaming_method_parameters`
- `provide_deprecation_message`
  • Loading branch information
natebosch authored Jul 22, 2021
1 parent 7d23e4c commit e0762b0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
2 changes: 2 additions & 0 deletions pkgs/typed_data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.3.1-dev

## 1.3.0

* Stable release for null safety.
Expand Down
5 changes: 1 addition & 4 deletions pkgs/typed_data/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
include: package:pedantic/analysis_options.1.9.0.yaml
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
errors:
annotate_overrides: ignore
prefer_single_quotes: ignore

linter:
rules:
Expand Down
8 changes: 4 additions & 4 deletions pkgs/typed_data/lib/src/typed_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ abstract class TypedDataBuffer<E> extends ListBase<E> {
// by setting the length in increments of one. We want to grow by doubling
// capacity in most cases.
@override
void add(E value) {
_add(value);
void add(E element) {
_add(element);
}

/// Appends all objects of [values] to the end of this buffer.
Expand Down Expand Up @@ -267,9 +267,9 @@ abstract class TypedDataBuffer<E> extends ListBase<E> {
}

@override
void setRange(int start, int end, Iterable<E> source, [int skipCount = 0]) {
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
if (end > _length) throw RangeError.range(end, 0, _length);
_setRange(start, end, source, skipCount);
_setRange(start, end, iterable, skipCount);
}

/// Like [setRange], but with no bounds checking.
Expand Down
44 changes: 43 additions & 1 deletion pkgs/typed_data/lib/src/typed_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {

// Iterable interface.

@override
int get length => (_tail - _head) & (_table.length - 1);

@override
List<E> toList({bool growable = true}) {
var list = growable ? _createBuffer(length) : _createList(length);
_writeToList(list);
return list;
}

@override
QueueList<T> cast<T>() {
if (this is QueueList<T>) return this as QueueList<T>;
throw UnsupportedError("$this cannot be cast to the desired type.");
}

@deprecated
@Deprecated('Use `cast` instead')
QueueList<T> retype<T>() => cast<T>();

// Queue interface.
Expand All @@ -65,6 +68,7 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
return result;
}

@override
E removeLast() {
if (_head == _tail) throw StateError("No element");
_tail = (_tail - 1) & (_table.length - 1);
Expand All @@ -73,8 +77,10 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {

// List interface.

@override
void add(E value) => addLast(value);

@override
set length(int value) {
RangeError.checkNotNegative(value, "length");

Expand All @@ -93,16 +99,19 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
}
}

@override
E operator [](int index) {
RangeError.checkValidIndex(index, this, null, length);
return _table[(_head + index) & (_table.length - 1)];
}

@override
void operator []=(int index, E value) {
RangeError.checkValidIndex(index, this);
_table[(_head + index) & (_table.length - 1)] = value;
}

@override
void removeRange(int start, int end) {
var length = this.length;
RangeError.checkValidRange(start, end, length);
Expand Down Expand Up @@ -132,6 +141,7 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
}
}

@override
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
RangeError.checkValidRange(start, end, length);
if (start == end) return;
Expand Down Expand Up @@ -231,6 +241,7 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
}
}

@override
void fillRange(int start, int end, [E? value]) {
var startInTable = (_head + start) & (_table.length - 1);
var endInTable = (_head + end) & (_table.length - 1);
Expand All @@ -242,6 +253,7 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
}
}

@override
L sublist(int start, [int? end]) {
var length = this.length;
var nonNullEnd = RangeError.checkValidRange(start, end, length);
Expand Down Expand Up @@ -327,13 +339,15 @@ abstract class _TypedQueue<E, L extends List<E>> with ListMixin<E> {
abstract class _IntQueue<L extends List<int>> extends _TypedQueue<int, L> {
_IntQueue(L queue) : super(queue);

@override
int get _defaultValue => 0;
}

abstract class _FloatQueue<L extends List<double>>
extends _TypedQueue<double, L> {
_FloatQueue(L queue) : super(queue);

@override
double get _defaultValue => 0.0;
}

Expand All @@ -354,7 +368,9 @@ class Uint8Queue extends _IntQueue<Uint8List> implements QueueList<int> {
factory Uint8Queue.fromList(List<int> elements) =>
Uint8Queue(elements.length)..addAll(elements);

@override
Uint8List _createList(int size) => Uint8List(size);
@override
Uint8Buffer _createBuffer(int size) => Uint8Buffer(size);
}

Expand All @@ -376,7 +392,9 @@ class Int8Queue extends _IntQueue<Int8List> implements QueueList<int> {
factory Int8Queue.fromList(List<int> elements) =>
Int8Queue(elements.length)..addAll(elements);

@override
Int8List _createList(int size) => Int8List(size);
@override
Int8Buffer _createBuffer(int size) => Int8Buffer(size);
}

Expand All @@ -400,7 +418,9 @@ class Uint8ClampedQueue extends _IntQueue<Uint8ClampedList>
factory Uint8ClampedQueue.fromList(List<int> elements) =>
Uint8ClampedQueue(elements.length)..addAll(elements);

@override
Uint8ClampedList _createList(int size) => Uint8ClampedList(size);
@override
Uint8ClampedBuffer _createBuffer(int size) => Uint8ClampedBuffer(size);
}

Expand All @@ -421,7 +441,9 @@ class Uint16Queue extends _IntQueue<Uint16List> implements QueueList<int> {
factory Uint16Queue.fromList(List<int> elements) =>
Uint16Queue(elements.length)..addAll(elements);

@override
Uint16List _createList(int size) => Uint16List(size);
@override
Uint16Buffer _createBuffer(int size) => Uint16Buffer(size);
}

Expand All @@ -443,7 +465,9 @@ class Int16Queue extends _IntQueue<Int16List> implements QueueList<int> {
factory Int16Queue.fromList(List<int> elements) =>
Int16Queue(elements.length)..addAll(elements);

@override
Int16List _createList(int size) => Int16List(size);
@override
Int16Buffer _createBuffer(int size) => Int16Buffer(size);
}

Expand All @@ -464,7 +488,9 @@ class Uint32Queue extends _IntQueue<Uint32List> implements QueueList<int> {
factory Uint32Queue.fromList(List<int> elements) =>
Uint32Queue(elements.length)..addAll(elements);

@override
Uint32List _createList(int size) => Uint32List(size);
@override
Uint32Buffer _createBuffer(int size) => Uint32Buffer(size);
}

Expand All @@ -486,7 +512,9 @@ class Int32Queue extends _IntQueue<Int32List> implements QueueList<int> {
factory Int32Queue.fromList(List<int> elements) =>
Int32Queue(elements.length)..addAll(elements);

@override
Int32List _createList(int size) => Int32List(size);
@override
Int32Buffer _createBuffer(int size) => Int32Buffer(size);
}

Expand All @@ -508,7 +536,9 @@ class Uint64Queue extends _IntQueue<Uint64List> implements QueueList<int> {
factory Uint64Queue.fromList(List<int> elements) =>
Uint64Queue(elements.length)..addAll(elements);

@override
Uint64List _createList(int size) => Uint64List(size);
@override
Uint64Buffer _createBuffer(int size) => Uint64Buffer(size);
}

Expand All @@ -530,7 +560,9 @@ class Int64Queue extends _IntQueue<Int64List> implements QueueList<int> {
factory Int64Queue.fromList(List<int> elements) =>
Int64Queue(elements.length)..addAll(elements);

@override
Int64List _createList(int size) => Int64List(size);
@override
Int64Buffer _createBuffer(int size) => Int64Buffer(size);
}

Expand All @@ -553,7 +585,9 @@ class Float32Queue extends _FloatQueue<Float32List>
factory Float32Queue.fromList(List<double> elements) =>
Float32Queue(elements.length)..addAll(elements);

@override
Float32List _createList(int size) => Float32List(size);
@override
Float32Buffer _createBuffer(int size) => Float32Buffer(size);
}

Expand All @@ -573,7 +607,9 @@ class Float64Queue extends _FloatQueue<Float64List>
factory Float64Queue.fromList(List<double> elements) =>
Float64Queue(elements.length)..addAll(elements);

@override
Float64List _createList(int size) => Float64List(size);
@override
Float64Buffer _createBuffer(int size) => Float64Buffer(size);
}

Expand All @@ -594,8 +630,11 @@ class Int32x4Queue extends _TypedQueue<Int32x4, Int32x4List>
factory Int32x4Queue.fromList(List<Int32x4> elements) =>
Int32x4Queue(elements.length)..addAll(elements);

@override
Int32x4List _createList(int size) => Int32x4List(size);
@override
Int32x4Buffer _createBuffer(int size) => Int32x4Buffer(size);
@override
Int32x4 get _defaultValue => _zero;
}

Expand All @@ -614,8 +653,11 @@ class Float32x4Queue extends _TypedQueue<Float32x4, Float32x4List>
factory Float32x4Queue.fromList(List<Float32x4> elements) =>
Float32x4Queue(elements.length)..addAll(elements);

@override
Float32x4List _createList(int size) => Float32x4List(size);
@override
Float32x4Buffer _createBuffer(int size) => Float32x4Buffer(size);
@override
Float32x4 get _defaultValue => Float32x4.zero();
}

Expand Down
8 changes: 4 additions & 4 deletions pkgs/typed_data/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: typed_data
version: 1.3.0
version: 1.3.1-dev

description: >-
Utility functions and classes related to the dart:typed_data library.
homepage: https://github.com/dart-lang/typed_data

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
collection: ^1.15.0

dev_dependencies:
pedantic: ^1.10.0-nullsafety
test: ^1.16.0-nullsafety
lints: ^1.0.0
test: ^1.16.0
2 changes: 2 additions & 0 deletions pkgs/typed_data/test/typed_buffers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,11 @@ class MatchesInt32x4 extends Matcher {

MatchesInt32x4(this.result);

@override
Description describe(Description description) =>
description.add('Int32x4.==');

@override
bool matches(item, Map matchState) =>
item is Int32x4 &&
result.x == item.x &&
Expand Down

0 comments on commit e0762b0

Please sign in to comment.