Skip to content

Commit ec3d0dd

Browse files
committed
Fix new pedantic lints
1 parent 08d0b8d commit ec3d0dd

File tree

17 files changed

+57
-48
lines changed

17 files changed

+57
-48
lines changed

analysis/lib/analysis_options.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ analyzer:
1414
# This has tons of false positives for StreamSubscription.close().
1515
unawaited_futures: ignore
1616

17+
# These are style preferences rather than potential semantic issues. While
18+
# we're not intrinsically opposed to adopting them for consistency with the
19+
# Dart ecosystem, there aren't currently any automated tools to help us
20+
# migrate to and remain consistent with these style rules, so achieving
21+
# consistency isn't worth the engineering time we'd spend getting there.
22+
annotate_overrides: ignore
23+
prefer_single_quotes: ignore
24+
use_function_type_syntax_for_parameters: ignore
25+
1726
include: package:pedantic/analysis_options.yaml

lib/src/ast/css/media_query.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CssMediaQuery {
8181
} else {
8282
return MediaQueryMergeResult.unrepresentable;
8383
}
84-
} else if (this.matchesAllTypes || other.matchesAllTypes) {
84+
} else if (matchesAllTypes || other.matchesAllTypes) {
8585
return MediaQueryMergeResult.unrepresentable;
8686
}
8787

@@ -116,7 +116,7 @@ class CssMediaQuery {
116116
// Otherwise, there's no way to represent the intersection.
117117
return MediaQueryMergeResult.unrepresentable;
118118
}
119-
} else if (this.matchesAllTypes) {
119+
} else if (matchesAllTypes) {
120120
modifier = theirModifier;
121121
// Omit the type if either input query did, since that indicates that they
122122
// aren't targeting a browser that requires "all and".

lib/src/ast/selector/list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class SelectorList extends Selector {
169169
return null;
170170
}
171171

172-
Iterable<SimpleSelector> resolvedMembers = containsSelectorPseudo
172+
var resolvedMembers = containsSelectorPseudo
173173
? compound.components.map((simple) {
174174
if (simple is PseudoSelector) {
175175
if (simple.selector == null) return simple;

lib/src/ast/selector/pseudo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class PseudoSelector extends SimpleSelector {
135135
if (simple is PseudoSelector && simple.isElement) {
136136
// A given compound selector may only contain one pseudo element. If
137137
// [compound] has a different one than [this], unification fails.
138-
if (this.isElement) return null;
138+
if (isElement) return null;
139139

140140
// Otherwise, this is a pseudo selector and should come before pseduo
141141
// elements.

lib/src/callable/built_in.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ class BuiltInCallable implements Callable, AsyncBuiltInCallable {
8686

8787
/// Returns a copy of this callable with the given [name].
8888
BuiltInCallable withName(String name) =>
89-
BuiltInCallable._(name, this._overloads);
89+
BuiltInCallable._(name, _overloads);
9090
}

lib/src/executable/options.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ExecutableOptions {
243243
var stdin = _options['stdin'] as bool;
244244
if (_options.rest.isEmpty && !stdin) _fail("Compile Sass to CSS.");
245245

246-
var directories = Set<String>();
246+
var directories = <String>{};
247247
var colonArgs = false;
248248
var positionalArgs = false;
249249
for (var argument in _options.rest) {
@@ -314,7 +314,7 @@ class ExecutableOptions {
314314
// Track [seen] separately from `sourcesToDestinations.keys` because we want
315315
// to report errors for sources as users entered them, rather than after
316316
// directories have been resolved.
317-
var seen = Set<String>();
317+
var seen = <String>{};
318318
var sourcesToDestinations = p.PathMap<String>();
319319
var sourceDirectoriesToDestinations = p.PathMap<String>();
320320
for (var argument in _options.rest) {

lib/src/executable/watch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class _Watcher {
224224
///
225225
/// Returns whether all recompilations succeeded.
226226
Future<bool> _recompileDownstream(Iterable<StylesheetNode> nodes) async {
227-
var seen = Set<StylesheetNode>();
227+
var seen = <StylesheetNode>{};
228228
var toRecompile = Queue.of(nodes);
229229

230230
var allSucceeded = true;

lib/src/extend/extender.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Extender {
199199
for (var component in complex.components) {
200200
if (component is CompoundSelector) {
201201
for (var simple in component.components) {
202-
_selectors.putIfAbsent(simple, () => Set()).add(selector);
202+
_selectors.putIfAbsent(simple, () => {}).add(selector);
203203

204204
if (simple is PseudoSelector && simple.selector != null) {
205205
_registerSelector(simple.selector, selector);
@@ -415,7 +415,7 @@ class Extender {
415415
// Find existing selectors to extend.
416416
var selectorsForTarget = _selectors[target];
417417
if (selectorsForTarget != null) {
418-
selectorsToExtend ??= Set();
418+
selectorsToExtend ??= {};
419419
selectorsToExtend.addAll(selectorsForTarget);
420420
}
421421

@@ -568,7 +568,7 @@ class Extender {
568568
// which targets are actually extended.
569569
var targetsUsed = _mode == ExtendMode.normal || extensions.length < 2
570570
? null
571-
: Set<SimpleSelector>();
571+
: <SimpleSelector>{};
572572

573573
// The complex selectors produced from each component of [compound].
574574
List<List<Extension>> options;
@@ -904,12 +904,12 @@ class Extender {
904904
var newSelectors =
905905
<SimpleSelector, Set<ModifiableCssValue<SelectorList>>>{};
906906
var newMediaContexts =
907-
Map<ModifiableCssValue<SelectorList>, List<CssMediaQuery>>();
907+
<ModifiableCssValue<SelectorList>, List<CssMediaQuery>>{};
908908
var oldToNewSelectors =
909909
<CssValue<SelectorList>, ModifiableCssValue<SelectorList>>{};
910910

911911
_selectors.forEach((simple, selectors) {
912-
var newSelectorSet = Set<ModifiableCssValue<SelectorList>>();
912+
var newSelectorSet = <ModifiableCssValue<SelectorList>>{};
913913
newSelectors[simple] = newSelectorSet;
914914

915915
for (var selector in selectors) {

lib/src/functions/color.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ final _adjust = BuiltInCallable("adjust", r"$color, $kwargs...", (arguments) {
379379
}
380380

381381
var keywords = Map.of(argumentList.keywords);
382-
getInRange(String name, num min, num max) =>
382+
num getInRange(String name, num min, num max) =>
383383
keywords.remove(name)?.assertNumber(name)?.valueInRange(min, max, name);
384384

385385
var red = _fuzzyRoundOrNull(getInRange("red", -255, 255));
@@ -432,15 +432,15 @@ final _scale = BuiltInCallable("scale", r"$color, $kwargs...", (arguments) {
432432
}
433433

434434
var keywords = Map.of(argumentList.keywords);
435-
getScale(String name) {
435+
num getScale(String name) {
436436
var value = keywords.remove(name);
437437
if (value == null) return null;
438438
var number = value.assertNumber(name);
439439
number.assertUnit("%", name);
440440
return number.valueInRange(-100, 100, name) / 100;
441441
}
442442

443-
scaleValue(num current, num scale, num max) {
443+
num scaleValue(num current, num scale, num max) {
444444
if (scale == null) return current;
445445
return current + (scale > 0 ? max - current : current) * scale;
446446
}
@@ -493,7 +493,7 @@ final _change = BuiltInCallable("change", r"$color, $kwargs...", (arguments) {
493493
}
494494

495495
var keywords = Map.of(argumentList.keywords);
496-
getInRange(String name, num min, num max) =>
496+
num getInRange(String name, num min, num max) =>
497497
keywords.remove(name)?.assertNumber(name)?.valueInRange(min, max, name);
498498

499499
var red = _fuzzyRoundOrNull(getInRange("red", 0, 255));
@@ -531,7 +531,7 @@ final _change = BuiltInCallable("change", r"$color, $kwargs...", (arguments) {
531531

532532
final _ieHexStr = BuiltInCallable("ie-hex-str", r"$color", (arguments) {
533533
var color = arguments[0].assertColor("color");
534-
hexString(int component) =>
534+
String hexString(int component) =>
535535
component.toRadixString(16).padLeft(2, '0').toUpperCase();
536536
return SassString(
537537
"#${hexString(fuzzyRound(color.alpha * 255))}${hexString(color.red)}"

lib/src/parse/at_root_query.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AtRootQueryParser extends Parser {
2323
scanner.expectChar($colon);
2424
whitespace();
2525

26-
var atRules = Set<String>();
26+
var atRules = <String>{};
2727
do {
2828
atRules.add(identifier().toLowerCase());
2929
whitespace();

0 commit comments

Comments
 (0)