Skip to content

Commit

Permalink
Fix new recommended lints (#2139)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Dec 5, 2023
1 parent cd3b0cc commit 13830a5
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 98 deletions.
9 changes: 2 additions & 7 deletions lib/src/ast/sass/statement/function_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import 'package:source_span/source_span.dart';

import '../../../util/span.dart';
import '../../../visitor/interface/statement.dart';
import '../argument_declaration.dart';
import '../declaration.dart';
import '../statement.dart';
import 'callable_declaration.dart';
import 'silent_comment.dart';

/// A function declaration.
///
Expand All @@ -21,10 +18,8 @@ final class FunctionRule extends CallableDeclaration
implements SassDeclaration {
FileSpan get nameSpan => span.withoutInitialAtRule().initialIdentifier();

FunctionRule(String name, ArgumentDeclaration arguments,
Iterable<Statement> children, FileSpan span,
{SilentComment? comment})
: super(name, arguments, children, span, comment: comment);
FunctionRule(super.name, super.arguments, super.children, super.span,
{super.comment});

T accept<T>(StatementVisitor<T> visitor) => visitor.visitFunctionRule(this);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/statement/if_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final class IfClause extends IfRuleClause {
///
/// {@category AST}
final class ElseClause extends IfRuleClause {
ElseClause(Iterable<Statement> children) : super(children);
ElseClause(super.children);

String toString() => "@else {${children.join(' ')}}";
}
9 changes: 2 additions & 7 deletions lib/src/ast/sass/statement/mixin_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import 'package:source_span/source_span.dart';
import '../../../util/span.dart';
import '../../../visitor/interface/statement.dart';
import '../../../visitor/statement_search.dart';
import '../argument_declaration.dart';
import '../declaration.dart';
import '../statement.dart';
import 'callable_declaration.dart';
import 'content_rule.dart';
import 'silent_comment.dart';

/// A mixin declaration.
///
Expand All @@ -31,10 +28,8 @@ final class MixinRule extends CallableDeclaration implements SassDeclaration {
return startSpan.initialIdentifier();
}

MixinRule(String name, ArgumentDeclaration arguments,
Iterable<Statement> children, FileSpan span,
{SilentComment? comment})
: super(name, arguments, children, span, comment: comment);
MixinRule(super.name, super.arguments, super.children, super.span,
{super.comment});

T accept<T>(StatementVisitor<T> visitor) => visitor.visitMixinRule(this);

Expand Down
5 changes: 2 additions & 3 deletions lib/src/ast/selector/complex.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ final class ComplexSelector extends Selector {
}

ComplexSelector(Iterable<CssValue<Combinator>> leadingCombinators,
Iterable<ComplexSelectorComponent> components, FileSpan span,
Iterable<ComplexSelectorComponent> components, super.span,
{this.lineBreak = false})
: leadingCombinators = List.unmodifiable(leadingCombinators),
components = List.unmodifiable(components),
super(span) {
components = List.unmodifiable(components) {
if (this.leadingCombinators.isEmpty && this.components.isEmpty) {
throw ArgumentError(
"leadingCombinators and components may not both be empty.");
Expand Down
6 changes: 2 additions & 4 deletions lib/src/ast/selector/compound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../../extend/functions.dart';
import '../../logger.dart';
Expand Down Expand Up @@ -43,9 +42,8 @@ final class CompoundSelector extends Selector {
SimpleSelector? get singleSimple =>
components.length == 1 ? components.first : null;

CompoundSelector(Iterable<SimpleSelector> components, FileSpan span)
: components = List.unmodifiable(components),
super(span) {
CompoundSelector(Iterable<SimpleSelector> components, super.span)
: components = List.unmodifiable(components) {
if (this.components.isEmpty) {
throw ArgumentError("components may not be empty.");
}
Expand Down
6 changes: 2 additions & 4 deletions lib/src/ast/selector/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../../exception.dart';
import '../../extend/functions.dart';
Expand Down Expand Up @@ -49,9 +48,8 @@ final class SelectorList extends Selector {
}), ListSeparator.comma);
}

SelectorList(Iterable<ComplexSelector> components, FileSpan span)
: components = List.unmodifiable(components),
super(span) {
SelectorList(Iterable<ComplexSelector> components, super.span)
: components = List.unmodifiable(components) {
if (this.components.isEmpty) {
throw ArgumentError("components may not be empty.");
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/ast/selector/parent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../../visitor/interface/selector.dart';
import '../selector.dart';
Expand All @@ -22,7 +21,7 @@ final class ParentSelector extends SimpleSelector {
/// indicating that the parent selector will not be modified.
final String? suffix;

ParentSelector(FileSpan span, {this.suffix}) : super(span);
ParentSelector(super.span, {this.suffix});

T accept<T>(SelectorVisitor<T> visitor) => visitor.visitParentSelector(this);

Expand Down
3 changes: 1 addition & 2 deletions lib/src/ast/selector/simple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../../exception.dart';
import '../../logger.dart';
Expand Down Expand Up @@ -35,7 +34,7 @@ abstract base class SimpleSelector extends Selector {
/// sequence will contain 1000 simple selectors.
int get specificity => 1000;

SimpleSelector(FileSpan span) : super(span);
SimpleSelector(super.span);

/// Parses a simple selector from [contents].
///
Expand Down
3 changes: 1 addition & 2 deletions lib/src/ast/selector/universal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';

import '../../extend/functions.dart';
import '../../visitor/interface/selector.dart';
Expand All @@ -23,7 +22,7 @@ final class UniversalSelector extends SimpleSelector {

int get specificity => 0;

UniversalSelector(FileSpan span, {this.namespace}) : super(span);
UniversalSelector(super.span, {this.namespace});

T accept<T>(SelectorVisitor<T> visitor) =>
visitor.visitUniversalSelector(this);
Expand Down
3 changes: 1 addition & 2 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ final class ExplicitConfiguration extends Configuration {

/// Creates a base [ExplicitConfiguration] with a [values] map and a
/// [nodeWithSpan].
ExplicitConfiguration(Map<String, ConfiguredValue> values, this.nodeWithSpan)
: super.implicit(values);
ExplicitConfiguration(super.values, this.nodeWithSpan) : super.implicit();

/// Creates an [ExplicitConfiguration] with a [values] map, a [nodeWithSpan]
/// and if this is a copy a reference to the [_originalConfiguration].
Expand Down
4 changes: 1 addition & 3 deletions lib/src/embedded/importer/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://opensource.org/licenses/MIT.

import '../../importer.dart';
import '../compilation_dispatcher.dart';
import '../embedded_sass.pb.dart' hide SourceSpan;
import 'base.dart';

Expand All @@ -19,8 +18,7 @@ final class FileImporter extends ImporterBase {
/// The host-provided ID of the importer to invoke.
final int _importerId;

FileImporter(CompilationDispatcher dispatcher, this._importerId)
: super(dispatcher);
FileImporter(super.dispatcher, this._importerId);

Uri? canonicalize(Uri url) {
if (url.scheme == 'file') return _filesystemImporter.canonicalize(url);
Expand Down
8 changes: 3 additions & 5 deletions lib/src/embedded/importer/host.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../../exception.dart';
import '../../importer.dart';
import '../../importer/utils.dart';
import '../../util/span.dart';
import '../compilation_dispatcher.dart';
import '../embedded_sass.pb.dart' hide SourceSpan;
import '../utils.dart';
import 'base.dart';
Expand All @@ -20,10 +19,9 @@ final class HostImporter extends ImporterBase {
/// [canonicalize].
final Set<String> _nonCanonicalSchemes;

HostImporter(CompilationDispatcher dispatcher, this._importerId,
Iterable<String> nonCanonicalSchemes)
: _nonCanonicalSchemes = Set.unmodifiable(nonCanonicalSchemes),
super(dispatcher) {
HostImporter(
super.dispatcher, this._importerId, Iterable<String> nonCanonicalSchemes)
: _nonCanonicalSchemes = Set.unmodifiable(nonCanonicalSchemes) {
for (var scheme in _nonCanonicalSchemes) {
if (isValidUrlScheme(scheme)) continue;
throw SassException(
Expand Down
21 changes: 8 additions & 13 deletions lib/src/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class SassException extends SourceSpanException {
/// compilation, before it failed.
final Set<Uri> loadedUrls;

SassException(String message, FileSpan span, [Iterable<Uri>? loadedUrls])
SassException(super.message, FileSpan super.span, [Iterable<Uri>? loadedUrls])
: loadedUrls =
loadedUrls == null ? const {} : Set.unmodifiable(loadedUrls),
super(message, span);
loadedUrls == null ? const {} : Set.unmodifiable(loadedUrls);

/// Converts this to a [MultiSpanSassException] with the additional [span] and
/// [label].
Expand Down Expand Up @@ -224,9 +223,7 @@ class SassFormatException extends SassException
SassFormatException withLoadedUrls(Iterable<Uri> loadedUrls) =>
SassFormatException(message, span, loadedUrls);

SassFormatException(String message, FileSpan span,
[Iterable<Uri>? loadedUrls])
: super(message, span, loadedUrls);
SassFormatException(super.message, super.span, [super.loadedUrls]);
}

/// A [SassFormatException] that's also a [MultiSpanFormatException].
Expand All @@ -248,10 +245,9 @@ class MultiSpanSassFormatException extends MultiSpanSassException
MultiSpanSassFormatException(
message, span, primaryLabel, secondarySpans, loadedUrls);

MultiSpanSassFormatException(String message, FileSpan span,
String primaryLabel, Map<FileSpan, String> secondarySpans,
[Iterable<Uri>? loadedUrls])
: super(message, span, primaryLabel, secondarySpans, loadedUrls);
MultiSpanSassFormatException(
super.message, super.span, super.primaryLabel, super.secondarySpans,
[super.loadedUrls]);
}

/// An exception thrown by SassScript.
Expand Down Expand Up @@ -287,9 +283,8 @@ class MultiSpanSassScriptException extends SassScriptException {
final Map<FileSpan, String> secondarySpans;

MultiSpanSassScriptException(
String message, this.primaryLabel, Map<FileSpan, String> secondarySpans)
: secondarySpans = Map.unmodifiable(secondarySpans),
super(message);
super.message, this.primaryLabel, Map<FileSpan, String> secondarySpans)
: secondarySpans = Map.unmodifiable(secondarySpans);

/// Converts this to a [SassException] with the given primary [span].
MultiSpanSassException withSpan(FileSpan span) =>
Expand Down
1 change: 1 addition & 0 deletions lib/src/extend/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/// aren't instance methods on other objects because their APIs aren't a good
/// fit—usually because they deal with raw component lists rather than selector
/// classes, to reduce allocations.
library;

import 'dart:collection';

Expand Down
8 changes: 2 additions & 6 deletions lib/src/parse/at_root_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
import 'package:charcode/charcode.dart';

import '../ast/sass.dart';
import '../interpolation_map.dart';
import '../logger.dart';
import 'parser.dart';

/// A parser for `@at-root` queries.
class AtRootQueryParser extends Parser {
AtRootQueryParser(String contents,
{Object? url, Logger? logger, InterpolationMap? interpolationMap})
: super(contents,
url: url, logger: logger, interpolationMap: interpolationMap);
AtRootQueryParser(super.contents,
{super.url, super.logger, super.interpolationMap});

AtRootQuery parse() {
return wrapSpanFormatException(() {
Expand Down
4 changes: 1 addition & 3 deletions lib/src/parse/css.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:string_scanner/string_scanner.dart';

import '../ast/sass.dart';
import '../functions.dart';
import '../logger.dart';
import 'scss.dart';

/// The set of all function names disallowed in plain CSS.
Expand All @@ -31,8 +30,7 @@ final _disallowedFunctionNames =
class CssParser extends ScssParser {
bool get plainCss => true;

CssParser(String contents, {Object? url, Logger? logger})
: super(contents, url: url, logger: logger);
CssParser(super.contents, {super.url, super.logger});

void silentComment() {
var start = scanner.state;
Expand Down
8 changes: 2 additions & 6 deletions lib/src/parse/keyframe_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

import 'package:charcode/charcode.dart';

import '../interpolation_map.dart';
import '../logger.dart';
import '../util/character.dart';
import 'parser.dart';

/// A parser for `@keyframes` block selectors.
class KeyframeSelectorParser extends Parser {
KeyframeSelectorParser(String contents,
{Object? url, Logger? logger, InterpolationMap? interpolationMap})
: super(contents,
url: url, logger: logger, interpolationMap: interpolationMap);
KeyframeSelectorParser(super.contents,
{super.url, super.logger, super.interpolationMap});

List<String> parse() {
return wrapSpanFormatException(() {
Expand Down
8 changes: 2 additions & 6 deletions lib/src/parse/media_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
import 'package:charcode/charcode.dart';

import '../ast/css.dart';
import '../interpolation_map.dart';
import '../logger.dart';
import '../utils.dart';
import 'parser.dart';

/// A parser for `@media` queries.
class MediaQueryParser extends Parser {
MediaQueryParser(String contents,
{Object? url, Logger? logger, InterpolationMap? interpolationMap})
: super(contents,
url: url, logger: logger, interpolationMap: interpolationMap);
MediaQueryParser(super.contents,
{super.url, super.logger, super.interpolationMap});

List<CssMediaQuery> parse() {
return wrapSpanFormatException(() {
Expand Down
4 changes: 1 addition & 3 deletions lib/src/parse/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:string_scanner/string_scanner.dart';

import '../ast/sass.dart';
import '../interpolation_buffer.dart';
import '../logger.dart';
import '../util/character.dart';
import '../value.dart';
import 'stylesheet.dart';
Expand Down Expand Up @@ -38,8 +37,7 @@ class SassParser extends StylesheetParser {

bool get indented => true;

SassParser(String contents, {Object? url, Logger? logger})
: super(contents, url: url, logger: logger);
SassParser(super.contents, {super.url, super.logger});

Interpolation styleRuleSelector() {
var start = scanner.state;
Expand Down
3 changes: 1 addition & 2 deletions lib/src/parse/scss.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class ScssParser extends StylesheetParser {
bool get indented => false;
int get currentIndentation => 0;

ScssParser(String contents, {Object? url, Logger? logger})
: super(contents, url: url, logger: logger);
ScssParser(super.contents, {super.url, super.logger});

Interpolation styleRuleSelector() => almostAnyValue();

Expand Down
Loading

0 comments on commit 13830a5

Please sign in to comment.