From 5f89247097adfb647b9902b7236a596d8145ac10 Mon Sep 17 00:00:00 2001 From: Till Friebe Date: Sat, 27 Mar 2021 15:41:28 +0100 Subject: [PATCH] Remove unnecessary parenthesis --- analysis_options.yaml | 1 + lib/models/documents/document.dart | 4 ++-- lib/models/documents/nodes/leaf.dart | 2 +- lib/models/quill_delta.dart | 2 +- lib/models/rules/rule.dart | 2 +- lib/utils/color.dart | 2 +- lib/utils/diff_delta.dart | 4 ++-- lib/widgets/editor.dart | 8 ++++---- lib/widgets/raw_editor.dart | 2 +- lib/widgets/text_block.dart | 4 ++-- lib/widgets/text_line.dart | 6 +++--- lib/widgets/text_selection.dart | 6 +++--- 12 files changed, 22 insertions(+), 21 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 57f3028e..099921dd 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -8,3 +8,4 @@ analyzer: linter: rules: - avoid_print + - unnecessary_parenthesis diff --git a/lib/models/documents/document.dart b/lib/models/documents/document.dart index d52e89a4..ee49034e 100644 --- a/lib/models/documents/document.dart +++ b/lib/models/documents/document.dart @@ -144,11 +144,11 @@ class Document { try { _delta = _delta.compose(delta); } catch (e) { - throw ('_delta compose failed'); + throw '_delta compose failed'; } if (_delta != _root.toDelta()) { - throw ('Compose failed'); + throw 'Compose failed'; } final change = Tuple3(originalDelta, delta, changeSource); _observer.add(change); diff --git a/lib/models/documents/nodes/leaf.dart b/lib/models/documents/nodes/leaf.dart index efb2ccde..6cb9af24 100644 --- a/lib/models/documents/nodes/leaf.dart +++ b/lib/models/documents/nodes/leaf.dart @@ -26,7 +26,7 @@ abstract class Leaf extends Node { @override void applyStyle(Style value) { - assert((value.isInline || value.isIgnored || value.isEmpty), + assert(value.isInline || value.isIgnored || value.isEmpty, 'Unable to apply Style to leaf: $value'); super.applyStyle(value); } diff --git a/lib/models/quill_delta.dart b/lib/models/quill_delta.dart index bced9b88..7fb215b8 100644 --- a/lib/models/quill_delta.dart +++ b/lib/models/quill_delta.dart @@ -118,7 +118,7 @@ class Operation { bool get isRetain => key == Operation.retainKey; /// Returns `true` if this operation has no attributes, e.g. is plain text. - bool get isPlain => (_attributes == null || _attributes!.isEmpty); + bool get isPlain => _attributes == null || _attributes!.isEmpty; /// Returns `true` if this operation sets at least one attribute. bool get isNotPlain => !isPlain; diff --git a/lib/models/rules/rule.dart b/lib/models/rules/rule.dart index bff58b44..df8e0b4a 100644 --- a/lib/models/rules/rule.dart +++ b/lib/models/rules/rule.dart @@ -67,6 +67,6 @@ class Rules { rethrow; } } - throw ('Apply rules failed'); + throw 'Apply rules failed'; } } diff --git a/lib/utils/color.dart b/lib/utils/color.dart index 4bc1c55a..4e206644 100644 --- a/lib/utils/color.dart +++ b/lib/utils/color.dart @@ -115,7 +115,7 @@ Color stringToColor(String? s) { } if (!s.startsWith('#')) { - throw ('Color code not supported'); + throw 'Color code not supported'; } String hex = s.replaceFirst('#', ''); diff --git a/lib/utils/diff_delta.dart b/lib/utils/diff_delta.dart index 8733c48f..127c2d8b 100644 --- a/lib/utils/diff_delta.dart +++ b/lib/utils/diff_delta.dart @@ -79,11 +79,11 @@ int getPositionDelta(Delta user, Delta actual) { Operation userOperation = userItr.next(length as int); Operation actualOperation = actualItr.next(length); if (userOperation.length != actualOperation.length) { - throw ('userOp ' + + throw 'userOp ' + userOperation.length.toString() + ' does not match ' + ' actualOp ' + - actualOperation.length.toString()); + actualOperation.length.toString(); } if (userOperation.key == actualOperation.key) { continue; diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index 305a58c8..6256aa6e 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -372,7 +372,7 @@ class _QuillEditorSelectionGestureDetectorBuilder ); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } @@ -523,7 +523,7 @@ class _QuillEditorSelectionGestureDetectorBuilder Feedback.forLongPress(_state.context); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } } @@ -961,7 +961,7 @@ class RenderEditableContainerBox extends RenderBox targetChild = childAfter(targetChild); } if (targetChild == null) { - throw ('targetChild should not be null'); + throw 'targetChild should not be null'; } return targetChild; } @@ -991,7 +991,7 @@ class RenderEditableContainerBox extends RenderBox dy += child.size.height; child = childAfter(child); } - throw ('No child'); + throw 'No child'; } @override diff --git a/lib/widgets/raw_editor.dart b/lib/widgets/raw_editor.dart index 04b4aaf8..b4e6756b 100644 --- a/lib/widgets/raw_editor.dart +++ b/lib/widgets/raw_editor.dart @@ -652,7 +652,7 @@ class RawEditorState extends EditorState case 3: return defaultStyles!.h3!.verticalSpacing; default: - throw ('Invalid level $level'); + throw 'Invalid level $level'; } } diff --git a/lib/widgets/text_block.dart b/lib/widgets/text_block.dart index 4d2a5cc3..603ee461 100644 --- a/lib/widgets/text_block.dart +++ b/lib/widgets/text_block.dart @@ -219,7 +219,7 @@ class EditableTextBlock extends StatelessWidget { bottom = defaultStyles.h3!.verticalSpacing.item2; break; default: - throw ('Invalid level $level'); + throw 'Invalid level $level'; } } else { late Tuple2 lineSpacing; @@ -496,7 +496,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox offset.translate(decorationPadding.left, decorationPadding.top); _painter!.paint(context.canvas, decorationOffset, filledConfiguration); if (debugSaveCount != context.canvas.getSaveCount()) { - throw ('${_decoration.runtimeType} painter had mismatching save and restore calls.'); + throw '${_decoration.runtimeType} painter had mismatching save and restore calls.'; } if (decoration.isComplex) { context.setIsComplexHint(); diff --git a/lib/widgets/text_line.dart b/lib/widgets/text_line.dart index 0da1e64f..1b081ea7 100644 --- a/lib/widgets/text_line.dart +++ b/lib/widgets/text_line.dart @@ -551,7 +551,7 @@ class RenderEditableTextLine extends RenderEditableBox { Rect.fromLTWH(0.0, 2.0, cursorWidth, cursorHeight - 4.0); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } @@ -732,7 +732,7 @@ class RenderEditableTextLine extends RenderEditableBox { if (_body != null) { final parentData = _body!.parentData as BoxParentData; final effectiveOffset = offset + parentData.offset; - if ((enableInteractiveSelection) && + if (enableInteractiveSelection && line.getDocumentOffset() <= textSelection.end && textSelection.start <= line.getDocumentOffset() + line.length - 1) { final local = localSelection(line, textSelection, false); @@ -860,7 +860,7 @@ class _TextLineElement extends RenderObjectElement { renderObject.setLeading(child); break; case TextLineSlot.BODY: - renderObject.setBody((child) as RenderContentProxyBox?); + renderObject.setBody(child as RenderContentProxyBox?); break; default: throw UnimplementedError(); diff --git a/lib/widgets/text_selection.dart b/lib/widgets/text_selection.dart index 4d9cb564..b03dd2bb 100644 --- a/lib/widgets/text_selection.dart +++ b/lib/widgets/text_selection.dart @@ -104,8 +104,8 @@ class EditorTextSelectionOverlay { Widget _buildHandle( BuildContext context, _TextSelectionHandlePosition position) { - if ((_selection.isCollapsed && - position == _TextSelectionHandlePosition.END)) { + if (_selection.isCollapsed && + position == _TextSelectionHandlePosition.END) { return Container(); } return Visibility( @@ -152,7 +152,7 @@ class EditorTextSelectionOverlay { : TextPosition(offset: 0); break; default: - throw ('Invalid position'); + throw 'Invalid position'; } selectionDelegate.textEditingValue = value.copyWith(selection: newSelection, composing: TextRange.empty);