Skip to content

Commit

Permalink
chore(sort_box): migrate lint rules
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolas Rimikis <[email protected]>
  • Loading branch information
Leptopoda committed Dec 19, 2023
1 parent 4064c0e commit d82019e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions packages/sort_box/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
include: package:neon_lints/dart.yaml

linter:
rules:
prefer_final_parameters: true
avoid_final_parameters: false
14 changes: 7 additions & 7 deletions packages/sort_box/lib/sort_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class SortBox<T extends Enum, R> {
///
/// This function sorts the input in place and a reference to it mutating the provided list.
List<R> sort(
final List<R> input,
final Box<T> box, [
final Set<Box<T>>? presort,
List<R> input,
Box<T> box, [
Set<Box<T>>? presort,
]) {
if (input.length <= 1) {
return input;
Expand All @@ -46,15 +46,15 @@ class SortBox<T extends Enum, R> {
...?_boxes[box.property],
};

final sorted = input..sort((final item1, final item2) => _compare(item1, item2, boxes.iterator..moveNext()));
final sorted = input..sort((item1, item2) => _compare(item1, item2, boxes.iterator..moveNext()));

return sorted;
}

int _compare(
final R item1,
final R item2,
final Iterator<Box<T>> iterator,
R item1,
R item2,
Iterator<Box<T>> iterator,
) {
final box = iterator.current;
final comparableGetter = _properties[box.property]!;
Expand Down
6 changes: 3 additions & 3 deletions packages/sort_box/test/sort_box_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Fruit {
void main() {
final sortBox = SortBox<FruitSort, Fruit>(
{
FruitSort.alphabetical: (final fruit) => fruit.name.toLowerCase(),
FruitSort.count: (final fruit) => fruit.count,
FruitSort.price: (final fruit) => fruit.price!,
FruitSort.alphabetical: (fruit) => fruit.name.toLowerCase(),
FruitSort.count: (fruit) => fruit.count,
FruitSort.price: (fruit) => fruit.price!,
},
{
FruitSort.alphabetical: {
Expand Down

0 comments on commit d82019e

Please sign in to comment.