From 9a4dc4e0283342f8474f4c4a625356e64a43824e Mon Sep 17 00:00:00 2001 From: mcmah309 Date: Mon, 11 Dec 2023 01:17:01 -0500 Subject: [PATCH] refactor: Formatting --- lib/src/cell/cell/bool_cell.dart | 4 +--- lib/src/cell/cell/const_cell.dart | 2 +- lib/src/cell/cell/double_cell.dart | 4 ---- lib/src/cell/cell/int_cell.dart | 3 --- lib/src/cell/cell/string_cell.dart | 2 +- .../lazy_cell/const_non_nullable_lazy_cell.dart | 9 +++++---- .../cell/lazy_cell/const_nullable_lazy_cell.dart | 9 +++++---- lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart | 11 +++++++---- lib/src/cell/lazy_cell/nullable_lazy_cell.dart | 14 +++++++++----- .../once_cell/const_non_nullable_once_cell.dart | 7 ++++--- .../cell/once_cell/const_nullable_once_cell.dart | 7 ++++--- lib/src/cell/once_cell/non_nullable_once_cell.dart | 11 +++++++---- lib/src/cell/once_cell/nullable_once_cell.dart | 11 +++++++---- test/cell/cell_test.dart | 2 +- test/cell/lazy_call_test.dart | 12 ++++++------ test/cell/once_cell_test.dart | 4 ++-- 16 files changed, 60 insertions(+), 52 deletions(-) diff --git a/lib/src/cell/cell/bool_cell.dart b/lib/src/cell/cell/bool_cell.dart index 67fd00e..3946008 100644 --- a/lib/src/cell/cell/bool_cell.dart +++ b/lib/src/cell/cell/bool_cell.dart @@ -1,7 +1,6 @@ part of 'cell.dart'; extension BoolConstCellExtensions on ConstCell { - /// Equal to bool eq(bool val) { return _val == val; @@ -9,9 +8,8 @@ extension BoolConstCellExtensions on ConstCell { } extension BoolCellExtensions on Cell { - /// "!" on the inner bool value. e.g. val = !val; void not() { _val = !_val; } -} \ No newline at end of file +} diff --git a/lib/src/cell/cell/const_cell.dart b/lib/src/cell/cell/const_cell.dart index 341edc3..ba11892 100644 --- a/lib/src/cell/cell/const_cell.dart +++ b/lib/src/cell/cell/const_cell.dart @@ -28,4 +28,4 @@ class ConstCell { String toString() { return "$runtimeType($_val)"; } -} \ No newline at end of file +} diff --git a/lib/src/cell/cell/double_cell.dart b/lib/src/cell/cell/double_cell.dart index c8e5741..816d8bf 100644 --- a/lib/src/cell/cell/double_cell.dart +++ b/lib/src/cell/cell/double_cell.dart @@ -68,7 +68,6 @@ extension DoubleConstCellExtensions on ConstCell { } extension DoubleCellExtensions on Cell { - /// Add void add(double val) { _val = _val + val; @@ -79,13 +78,11 @@ extension DoubleCellExtensions on Cell { _val = _val - val; } - /// multiply void mul(double val) { _val = _val * val; } - /// divide void div(double val) { _val = _val / val; @@ -96,7 +93,6 @@ extension DoubleCellExtensions on Cell { _val = _val % val; } - /// Negate void neg() { _val = -_val; diff --git a/lib/src/cell/cell/int_cell.dart b/lib/src/cell/cell/int_cell.dart index 7883b45..e3f0921 100644 --- a/lib/src/cell/cell/int_cell.dart +++ b/lib/src/cell/cell/int_cell.dart @@ -69,7 +69,6 @@ extension IntConstCellExtensions on ConstCell { } extension IntCellExtensions on Cell { - /// Add void add(int val) { _val = _val + val; @@ -85,7 +84,6 @@ extension IntCellExtensions on Cell { _val = _val * val; } - /// Performs integer division of this object. Truncate Divide void truncDiv(int val) { _val = _val ~/ val; @@ -96,7 +94,6 @@ extension IntCellExtensions on Cell { _val = _val % val; } - /// Negate void neg() { _val = -_val; diff --git a/lib/src/cell/cell/string_cell.dart b/lib/src/cell/cell/string_cell.dart index 7f233e2..4324ce0 100644 --- a/lib/src/cell/cell/string_cell.dart +++ b/lib/src/cell/cell/string_cell.dart @@ -16,4 +16,4 @@ extension StringCellExtensions on Cell { void add(String val) { _val = _val + val; } -} \ No newline at end of file +} diff --git a/lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart b/lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart index 01e045f..6190ae4 100644 --- a/lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart +++ b/lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart @@ -26,8 +26,8 @@ class ConstNonNullableLazyCell implements LazyCell { } @override - bool isEvaluated(){ - return (_cache[this] as T?) == null ? false : true; + bool isEvaluated() { + return (_cache[this] as T?) == null ? false : true; } @override @@ -38,8 +38,9 @@ class ConstNonNullableLazyCell implements LazyCell { @override bool operator ==(Object other) { - return other is NullableLazyCell && ((isEvaluated() && other - .isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated())); + return other is NullableLazyCell && + ((isEvaluated() && other.isEvaluated() && this() == other()) || + (!isEvaluated() && !other.isEvaluated())); } @override diff --git a/lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart b/lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart index fe483a2..c49b266 100644 --- a/lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart +++ b/lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart @@ -25,8 +25,8 @@ class ConstNullableLazyCell implements NullableLazyCell { } @override - bool isEvaluated(){ - return (_cache[this] as (T,)?) == null ? false : true; + bool isEvaluated() { + return (_cache[this] as (T,)?) == null ? false : true; } @override @@ -37,8 +37,9 @@ class ConstNullableLazyCell implements NullableLazyCell { @override bool operator ==(Object other) { - return other is NullableLazyCell && ((isEvaluated() && other - .isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated())); + return other is NullableLazyCell && + ((isEvaluated() && other.isEvaluated() && this() == other()) || + (!isEvaluated() && !other.isEvaluated())); } @override diff --git a/lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart b/lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart index 3a03a79..f86b177 100644 --- a/lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart +++ b/lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart @@ -21,7 +21,7 @@ class NonNullableLazyCell implements LazyCell { } @override - bool isEvaluated(){ + bool isEvaluated() { return _val == null ? false : true; } @@ -33,12 +33,15 @@ class NonNullableLazyCell implements LazyCell { @override bool operator ==(Object other) { - return other is NullableLazyCell && ((isEvaluated() && other - .isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated())); + return other is NullableLazyCell && + ((isEvaluated() && other.isEvaluated() && this() == other()) || + (!isEvaluated() && !other.isEvaluated())); } @override String toString() { - return (_val == null ? "Uninitialized $runtimeType" : "Initialized $runtimeType($_val)"); + return (_val == null + ? "Uninitialized $runtimeType" + : "Initialized $runtimeType($_val)"); } } diff --git a/lib/src/cell/lazy_cell/nullable_lazy_cell.dart b/lib/src/cell/lazy_cell/nullable_lazy_cell.dart index 2a16b17..4ce29af 100644 --- a/lib/src/cell/lazy_cell/nullable_lazy_cell.dart +++ b/lib/src/cell/lazy_cell/nullable_lazy_cell.dart @@ -12,7 +12,8 @@ class NullableLazyCell { NullableLazyCell(this._func); - const factory NullableLazyCell.constant(T Function() func, Object id) = ConstNullableLazyCell; + const factory NullableLazyCell.constant(T Function() func, Object id) = + ConstNullableLazyCell; /// Lazily evaluates the function passed into the constructor. T call() { @@ -25,7 +26,7 @@ class NullableLazyCell { } /// Returns true if this has already been called, otherwise false. - bool isEvaluated(){ + bool isEvaluated() { return _isSet; } @@ -37,12 +38,15 @@ class NullableLazyCell { @override bool operator ==(Object other) { - return other is NullableLazyCell && ((isEvaluated() && other - .isEvaluated() && this() == other()) || (!isEvaluated() && !other.isEvaluated())); + return other is NullableLazyCell && + ((isEvaluated() && other.isEvaluated() && this() == other()) || + (!isEvaluated() && !other.isEvaluated())); } @override String toString() { - return (_isSet ? "Initialized $runtimeType($_val)" : "Uninitialized $runtimeType"); + return (_isSet + ? "Initialized $runtimeType($_val)" + : "Uninitialized $runtimeType"); } } diff --git a/lib/src/cell/once_cell/const_non_nullable_once_cell.dart b/lib/src/cell/once_cell/const_non_nullable_once_cell.dart index e3d1183..330e555 100644 --- a/lib/src/cell/once_cell/const_non_nullable_once_cell.dart +++ b/lib/src/cell/once_cell/const_non_nullable_once_cell.dart @@ -93,7 +93,7 @@ class ConstNonNullableOnceCell implements OnceCell { } @override - bool isSet(){ + bool isSet() { return (_cache[this] as T?) == null ? false : true; } @@ -105,8 +105,9 @@ class ConstNonNullableOnceCell implements OnceCell { @override bool operator ==(Object other) { - return other is NullableOnceCell && ((isSet() && other - .isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet())); + return other is NullableOnceCell && + ((isSet() && other.isSet() && getOrNull() == other.getOrNull()) || + (!isSet() && !other.isSet())); } @override diff --git a/lib/src/cell/once_cell/const_nullable_once_cell.dart b/lib/src/cell/once_cell/const_nullable_once_cell.dart index a7882ae..82592a9 100644 --- a/lib/src/cell/once_cell/const_nullable_once_cell.dart +++ b/lib/src/cell/once_cell/const_nullable_once_cell.dart @@ -72,7 +72,7 @@ class ConstNullableOnceCell implements NullableOnceCell { } @override - bool isSet(){ + bool isSet() { return (_cache[this] as (T,)?) == null ? false : true; } @@ -84,8 +84,9 @@ class ConstNullableOnceCell implements NullableOnceCell { @override bool operator ==(Object other) { - return other is NullableOnceCell && ((isSet() && other - .isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet())); + return other is NullableOnceCell && + ((isSet() && other.isSet() && getOrNull() == other.getOrNull()) || + (!isSet() && !other.isSet())); } @override diff --git a/lib/src/cell/once_cell/non_nullable_once_cell.dart b/lib/src/cell/once_cell/non_nullable_once_cell.dart index 96b9094..c423dd3 100644 --- a/lib/src/cell/once_cell/non_nullable_once_cell.dart +++ b/lib/src/cell/once_cell/non_nullable_once_cell.dart @@ -83,7 +83,7 @@ class NonNullableOnceCell implements OnceCell { } @override - bool isSet(){ + bool isSet() { return _val == null ? false : true; } @@ -95,12 +95,15 @@ class NonNullableOnceCell implements OnceCell { @override bool operator ==(Object other) { - return other is NullableOnceCell && ((isSet() && other - .isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet())); + return other is NullableOnceCell && + ((isSet() && other.isSet() && getOrNull() == other.getOrNull()) || + (!isSet() && !other.isSet())); } @override String toString() { - return (_val == null ? "Uninitialized $runtimeType" : "Initialized $runtimeType($_val)"); + return (_val == null + ? "Uninitialized $runtimeType" + : "Initialized $runtimeType($_val)"); } } diff --git a/lib/src/cell/once_cell/nullable_once_cell.dart b/lib/src/cell/once_cell/nullable_once_cell.dart index e65c3fd..ecab304 100644 --- a/lib/src/cell/once_cell/nullable_once_cell.dart +++ b/lib/src/cell/once_cell/nullable_once_cell.dart @@ -68,7 +68,7 @@ class NullableOnceCell { } /// Returns true if the value has been set. Returns false otherwise. - bool isSet(){ + bool isSet() { return _isSet; } @@ -80,12 +80,15 @@ class NullableOnceCell { @override bool operator ==(Object other) { - return other is NullableOnceCell && ((isSet() && other - .isSet() && getOrNull() == other.getOrNull()) || (!isSet() && !other.isSet())); + return other is NullableOnceCell && + ((isSet() && other.isSet() && getOrNull() == other.getOrNull()) || + (!isSet() && !other.isSet())); } @override String toString() { - return (_isSet ? "Initialized $runtimeType($_val)" : "Uninitialized $runtimeType"); + return (_isSet + ? "Initialized $runtimeType($_val)" + : "Uninitialized $runtimeType"); } } diff --git a/test/cell/cell_test.dart b/test/cell/cell_test.dart index 9d9539a..8684dba 100644 --- a/test/cell/cell_test.dart +++ b/test/cell/cell_test.dart @@ -372,7 +372,7 @@ void main() { }); }); - test('const cell', (){ + test('const cell', () { const constCell = ConstCell(1); var cell = Cell(1); expect(constCell, equals(cell)); diff --git a/test/cell/lazy_call_test.dart b/test/cell/lazy_call_test.dart index 5d041d6..716618f 100644 --- a/test/cell/lazy_call_test.dart +++ b/test/cell/lazy_call_test.dart @@ -181,7 +181,7 @@ void main() { }); }); - test("LazyCell",(){ + test("LazyCell", () { int callCount = 0; final lazyCell = LazyCell(() { callCount++; @@ -195,11 +195,12 @@ void main() { expect(secondCall, equals(20)); }); - test("LazyCell Equality",(){ + test("LazyCell Equality", () { final nullableLazyCell = NullableLazyCell(() { return 20; }); - const constNonNullableLazyCell = ConstNonNullableLazyCell(_constReturn20, "dfasdfas"); + const constNonNullableLazyCell = + ConstNonNullableLazyCell(_constReturn20, "dfasdfas"); expect(nullableLazyCell, equals(constNonNullableLazyCell)); nullableLazyCell(); expect(nullableLazyCell, isNot(equals(constNonNullableLazyCell))); @@ -208,7 +209,6 @@ void main() { }); } - -int _constReturn20(){ +int _constReturn20() { return 20; -} \ No newline at end of file +} diff --git a/test/cell/once_cell_test.dart b/test/cell/once_cell_test.dart index 16d696d..0984838 100644 --- a/test/cell/once_cell_test.dart +++ b/test/cell/once_cell_test.dart @@ -402,7 +402,7 @@ void main() { expect(cell.hashCode, equals(cell2.hashCode)); }); - test("OnceCell",(){ + test("OnceCell", () { final cell = OnceCell(); var result = cell.set(10); expect(result, const Ok(())); @@ -410,7 +410,7 @@ void main() { expect(result, const Err(20)); }); - test("OnceCell Equality",(){ + test("OnceCell Equality", () { final cell = OnceCell(); const constNullableOnceCell = ConstNullableOnceCell("agsagddg"); expect(cell, equals(constNullableOnceCell));