mirror of
https://github.com/flutter/flutter
synced 2024-10-12 11:12:54 +00:00
enable lint avoid_bool_literals_in_conditional_expressions (#35055)
This commit is contained in:
parent
9a3a7490c8
commit
fecf99ff1e
|
@ -52,7 +52,7 @@ linter:
|
|||
- annotate_overrides
|
||||
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
|
||||
- avoid_as
|
||||
# - avoid_bool_literals_in_conditional_expressions # not yet tested
|
||||
- avoid_bool_literals_in_conditional_expressions
|
||||
# - avoid_catches_without_on_clauses # we do this commonly
|
||||
# - avoid_catching_errors # we do this commonly
|
||||
- avoid_classes_with_only_static_members
|
||||
|
|
|
@ -430,7 +430,7 @@ class SampleChecker {
|
|||
startLine = Line('', filename: relativeFilePath, line: lineNumber + 1, indent: 3);
|
||||
inPreamble = true;
|
||||
} else if (sampleMatch != null) {
|
||||
inSnippet = sampleMatch != null ? sampleMatch[1] == 'snippet' : false;
|
||||
inSnippet = sampleMatch != null && sampleMatch[1] == 'snippet';
|
||||
if (inSnippet) {
|
||||
startLine = Line(
|
||||
'',
|
||||
|
|
|
@ -247,7 +247,7 @@ class _ChipDemoState extends State<ChipDemo> {
|
|||
return FilterChip(
|
||||
key: ValueKey<String>(name),
|
||||
label: Text(_capitalize(name)),
|
||||
selected: _tools.contains(name) ? _selectedTools.contains(name) : false,
|
||||
selected: _tools.contains(name) && _selectedTools.contains(name),
|
||||
onSelected: !_tools.contains(name)
|
||||
? null
|
||||
: (bool value) {
|
||||
|
|
|
@ -618,9 +618,9 @@ class _CupertinoBackGestureController<T> {
|
|||
// or after mid screen, we should animate the page out. Otherwise, the page
|
||||
// should be animated back in.
|
||||
if (velocity.abs() >= _kMinFlingVelocity)
|
||||
animateForward = velocity > 0 ? false : true;
|
||||
animateForward = velocity <= 0;
|
||||
else
|
||||
animateForward = controller.value > 0.5 ? true : false;
|
||||
animateForward = controller.value > 0.5;
|
||||
|
||||
if (animateForward) {
|
||||
// The closer the panel is to dismissing, the shorter the animation is.
|
||||
|
|
|
@ -1469,7 +1469,7 @@ abstract class DiagnosticsNode {
|
|||
///
|
||||
/// If `minLevel` is [DiagnosticLevel.hidden] no diagnostics will be filtered.
|
||||
/// If `minLevel` is [DiagnosticLevel.off] all diagnostics will be filtered.
|
||||
bool isFiltered(DiagnosticLevel minLevel) => kReleaseMode ? true : level.index < minLevel.index;
|
||||
bool isFiltered(DiagnosticLevel minLevel) => kReleaseMode || level.index < minLevel.index;
|
||||
|
||||
/// Priority level of the diagnostic used to control which diagnostics should
|
||||
/// be shown and filtered.
|
||||
|
|
|
@ -197,7 +197,7 @@ class BottomNavigationBar extends StatefulWidget {
|
|||
assert(elevation != null && elevation >= 0.0),
|
||||
assert(iconSize != null && iconSize >= 0.0),
|
||||
assert(
|
||||
selectedItemColor != null ? fixedColor == null : true,
|
||||
selectedItemColor == null || fixedColor == null,
|
||||
'Either selectedItemColor or fixedColor can be specified, but not both'
|
||||
),
|
||||
assert(selectedFontSize != null && selectedFontSize >= 0.0),
|
||||
|
|
|
@ -1410,7 +1410,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
|
|||
}
|
||||
|
||||
bool _isTapping = false;
|
||||
bool get isTapping => !canTap ? false : _isTapping;
|
||||
bool get isTapping => canTap && _isTapping;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -616,7 +616,7 @@ class DataTable extends StatelessWidget {
|
|||
label: column.label,
|
||||
tooltip: column.tooltip,
|
||||
numeric: column.numeric,
|
||||
onSort: () => column.onSort != null ? column.onSort(dataColumnIndex, sortColumnIndex == dataColumnIndex ? !sortAscending : true) : null,
|
||||
onSort: () => column.onSort != null ? column.onSort(dataColumnIndex, sortColumnIndex != dataColumnIndex || !sortAscending) : null,
|
||||
sorted: dataColumnIndex == sortColumnIndex,
|
||||
ascending: sortAscending,
|
||||
);
|
||||
|
|
|
@ -346,7 +346,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
|||
break;
|
||||
}
|
||||
|
||||
final bool opened = _controller.value > 0.5 ? true : false;
|
||||
final bool opened = _controller.value > 0.5;
|
||||
if (opened != _previouslyOpened && widget.drawerCallback != null)
|
||||
widget.drawerCallback(opened);
|
||||
_previouslyOpened = opened;
|
||||
|
|
|
@ -2173,7 +2173,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
|
|||
);
|
||||
|
||||
// extendBody locked when keyboard is open
|
||||
final bool _extendBody = minInsets.bottom > 0 ? false : widget.extendBody;
|
||||
final bool _extendBody = minInsets.bottom <= 0 && widget.extendBody;
|
||||
|
||||
return _ScaffoldScope(
|
||||
hasDrawer: hasDrawer,
|
||||
|
|
|
@ -150,7 +150,7 @@ class TabController extends ChangeNotifier {
|
|||
void _changeIndex(int value, { Duration duration, Curve curve }) {
|
||||
assert(value != null);
|
||||
assert(value >= 0 && (value < length || length == 0));
|
||||
assert(duration == null ? curve == null : true);
|
||||
assert(duration != null || curve == null);
|
||||
assert(_indexIsChangingCount >= 0);
|
||||
if (value == _index || length < 2)
|
||||
return;
|
||||
|
|
|
@ -2969,7 +2969,7 @@ class RenderIgnorePointer extends RenderProxyBox {
|
|||
|
||||
@override
|
||||
bool hitTest(BoxHitTestResult result, { Offset position }) {
|
||||
return ignoring ? false : super.hitTest(result, position: position);
|
||||
return !ignoring && super.hitTest(result, position: position);
|
||||
}
|
||||
|
||||
// TODO(ianh): figure out a way to still include labels and flags in
|
||||
|
|
|
@ -469,7 +469,7 @@ class RawFloatingCursorPoint {
|
|||
this.offset,
|
||||
@required this.state,
|
||||
}) : assert(state != null),
|
||||
assert(state == FloatingCursorDragState.Update ? offset != null : true);
|
||||
assert(state != FloatingCursorDragState.Update || offset != null);
|
||||
|
||||
/// The raw position of the floating cursor as determined by the iOS sdk.
|
||||
final Offset offset;
|
||||
|
|
|
@ -95,7 +95,7 @@ class Dismissible extends StatefulWidget {
|
|||
this.crossAxisEndOffset = 0.0,
|
||||
this.dragStartBehavior = DragStartBehavior.start,
|
||||
}) : assert(key != null),
|
||||
assert(secondaryBackground != null ? background != null : true),
|
||||
assert(secondaryBackground == null || background != null),
|
||||
assert(dragStartBehavior != null),
|
||||
super(key: key);
|
||||
|
||||
|
|
|
@ -75,9 +75,11 @@ class WidgetSpan extends PlaceholderSpan {
|
|||
TextBaseline baseline,
|
||||
TextStyle style,
|
||||
}) : assert(child != null),
|
||||
assert((identical(alignment, ui.PlaceholderAlignment.aboveBaseline) ||
|
||||
identical(alignment, ui.PlaceholderAlignment.belowBaseline) ||
|
||||
identical(alignment, ui.PlaceholderAlignment.baseline)) ? baseline != null : true),
|
||||
assert(baseline != null || !(
|
||||
identical(alignment, ui.PlaceholderAlignment.aboveBaseline) ||
|
||||
identical(alignment, ui.PlaceholderAlignment.belowBaseline) ||
|
||||
identical(alignment, ui.PlaceholderAlignment.baseline)
|
||||
)),
|
||||
super(
|
||||
alignment: alignment,
|
||||
baseline: baseline,
|
||||
|
|
|
@ -25,7 +25,7 @@ class FakeMissingSizeRenderBox extends RenderBox {
|
|||
}
|
||||
|
||||
@override
|
||||
bool get hasSize => fakeMissingSize ? false : super.hasSize;
|
||||
bool get hasSize => !fakeMissingSize && super.hasSize;
|
||||
|
||||
bool fakeMissingSize = false;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class FooMaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLoc
|
|||
|
||||
@override
|
||||
bool isSupported(Locale locale) {
|
||||
return supportedLanguage == 'allLanguages' ? true : locale.languageCode == supportedLanguage;
|
||||
return supportedLanguage == 'allLanguages' || locale.languageCode == supportedLanguage;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -175,7 +175,7 @@ class AOTSnapshotter {
|
|||
'entryPoint': mainPath,
|
||||
'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '),
|
||||
'engineHash': Cache.instance.engineRevision,
|
||||
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
|
||||
'buildersUsed': '${flutterProject != null && flutterProject.hasBuilders}',
|
||||
},
|
||||
depfilePaths: <String>[],
|
||||
);
|
||||
|
|
|
@ -163,7 +163,7 @@ class Stdio {
|
|||
bool get hasTerminal => io.stdout.hasTerminal;
|
||||
int get terminalColumns => hasTerminal ? io.stdout.terminalColumns : null;
|
||||
int get terminalLines => hasTerminal ? io.stdout.terminalLines : null;
|
||||
bool get supportsAnsiEscapes => hasTerminal ? io.stdout.supportsAnsiEscapes : false;
|
||||
bool get supportsAnsiEscapes => hasTerminal && io.stdout.supportsAnsiEscapes;
|
||||
}
|
||||
|
||||
Stdio get stdio => context.get<Stdio>() ?? const Stdio();
|
||||
|
|
|
@ -148,7 +148,7 @@ Future<int> runCommandAndStreamOutput(
|
|||
final StreamSubscription<String> stdoutSubscription = process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.where((String line) => filter == null ? true : filter.hasMatch(line))
|
||||
.where((String line) => filter == null || filter.hasMatch(line))
|
||||
.listen((String line) {
|
||||
if (mapFunction != null)
|
||||
line = mapFunction(line);
|
||||
|
@ -163,7 +163,7 @@ Future<int> runCommandAndStreamOutput(
|
|||
final StreamSubscription<String> stderrSubscription = process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.where((String line) => filter == null ? true : filter.hasMatch(line))
|
||||
.where((String line) => filter == null || filter.hasMatch(line))
|
||||
.listen((String line) {
|
||||
if (mapFunction != null)
|
||||
line = mapFunction(line);
|
||||
|
|
|
@ -246,7 +246,7 @@ class KernelCompiler {
|
|||
'trackWidgetCreation': trackWidgetCreation.toString(),
|
||||
'linkPlatformKernelIn': linkPlatformKernelIn.toString(),
|
||||
'engineHash': Cache.instance.engineRevision,
|
||||
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
|
||||
'buildersUsed': '${flutterProject != null && flutterProject.hasBuilders}',
|
||||
},
|
||||
depfilePaths: <String>[depFilePath],
|
||||
pathFilter: (String path) => !path.startsWith('/b/build/slave/'),
|
||||
|
|
Loading…
Reference in a new issue