From 1fcdf8d6040d1d16e492ca002c26e68801786ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 25 Oct 2024 10:58:12 -0700 Subject: [PATCH] Fix dart analyze warnings --- lib/src/deprecation.dart | 1 + lib/src/embedded/compilation_dispatcher.dart | 14 +++++++------- lib/src/functions/color.dart | 2 +- lib/src/parse/parser.dart | 2 +- lib/src/visitor/async_evaluate.dart | 2 +- lib/src/visitor/evaluate.dart | 4 ++-- test/util/string_test.dart | 2 +- tool/grind/bump_version.dart | 8 ++++---- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/src/deprecation.dart b/lib/src/deprecation.dart index e7c4e6a4e..3281e720d 100644 --- a/lib/src/deprecation.dart +++ b/lib/src/deprecation.dart @@ -181,6 +181,7 @@ enum Deprecation { isFuture = false; /// Constructs a future deprecation. + // ignore: unused_element const Deprecation.future(this.id, {this.description}) : _deprecatedIn = null, _obsoleteIn = null, diff --git a/lib/src/embedded/compilation_dispatcher.dart b/lib/src/embedded/compilation_dispatcher.dart index a8c84c8eb..9862a97c1 100644 --- a/lib/src/embedded/compilation_dispatcher.dart +++ b/lib/src/embedded/compilation_dispatcher.dart @@ -145,7 +145,7 @@ final class CompilationDispatcher { try { var importers = request.importers.map((importer) => - _decodeImporter(request, importer) ?? + _decodeImporter(importer) ?? (throw mandatoryError("Importer.importer"))); var globalFunctions = request.globalFunctions @@ -159,7 +159,7 @@ final class CompilationDispatcher { color: request.alertColor, logger: logger, importers: importers, - importer: _decodeImporter(request, input.importer) ?? + importer: _decodeImporter(input.importer) ?? (input.url.startsWith("file:") ? null : sass.Importer.noOp), functions: globalFunctions, syntax: syntaxToSyntax(input.syntax), @@ -234,7 +234,7 @@ final class CompilationDispatcher { } /// Converts [importer] into a [sass.Importer]. - sass.Importer? _decodeImporter(InboundMessage_CompileRequest request, + sass.Importer? _decodeImporter( InboundMessage_CompileRequest_Importer importer) { switch (importer.whichImporter()) { case InboundMessage_CompileRequest_Importer_Importer.path: @@ -249,13 +249,13 @@ final class CompilationDispatcher { _checkNoNonCanonicalScheme(importer); return FileImporter(this, importer.fileImporterId); - case InboundMessage_CompileRequest_Importer_Importer.notSet: - _checkNoNonCanonicalScheme(importer); - return null; - case InboundMessage_CompileRequest_Importer_Importer.nodePackageImporter: return npi.NodePackageImporter( importer.nodePackageImporter.entryPointDirectory); + + case InboundMessage_CompileRequest_Importer_Importer.notSet: + _checkNoNonCanonicalScheme(importer); + return null; } } diff --git a/lib/src/functions/color.dart b/lib/src/functions/color.dart index 7f0acd1fb..abbf9d00a 100644 --- a/lib/src/functions/color.dart +++ b/lib/src/functions/color.dart @@ -1610,7 +1610,7 @@ BuiltInCallable _channelFunction( warnForDeprecation( "${global ? '' : 'color.'}$name() is deprecated. Suggestion:\n" "\n" - 'color.channel(\$color, \"$name\", \$space: $space)\n' + 'color.channel(\$color, "$name", \$space: $space)\n' "\n" "More info: https://sass-lang.com/d/color-functions", Deprecation.colorFunctions); diff --git a/lib/src/parse/parser.dart b/lib/src/parse/parser.dart index 4c4d6ba5e..19ef3971c 100644 --- a/lib/src/parse/parser.dart +++ b/lib/src/parse/parser.dart @@ -651,7 +651,7 @@ class Parser { var span = scanner.spanFrom(state); return _interpolationMap == null ? span - : LazyFileSpan(() => _interpolationMap!.mapSpan(span)); + : LazyFileSpan(() => _interpolationMap.mapSpan(span)); } /// Throws an error associated with [span]. diff --git a/lib/src/visitor/async_evaluate.dart b/lib/src/visitor/async_evaluate.dart index 4dc806e67..aba5cee7c 100644 --- a/lib/src/visitor/async_evaluate.dart +++ b/lib/src/visitor/async_evaluate.dart @@ -1812,7 +1812,7 @@ final class _EvaluateVisitor if (result != null) { isDependency = _inDependency; } else { - result = await _nodeImporter!.loadAsync(originalUrl, previous, forImport); + result = await _nodeImporter.loadAsync(originalUrl, previous, forImport); if (result == null) return null; isDependency = true; } diff --git a/lib/src/visitor/evaluate.dart b/lib/src/visitor/evaluate.dart index e06601361..f9990c828 100644 --- a/lib/src/visitor/evaluate.dart +++ b/lib/src/visitor/evaluate.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_evaluate.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: 396c8f169d95c601598b8c3be1f4b948ca22effa +// Checksum: 3986f5db33dd220dcd971a39e8587ca4e52d9a3f // // ignore_for_file: unused_import @@ -1808,7 +1808,7 @@ final class _EvaluateVisitor if (result != null) { isDependency = _inDependency; } else { - result = _nodeImporter!.load(originalUrl, previous, forImport); + result = _nodeImporter.load(originalUrl, previous, forImport); if (result == null) return null; isDependency = true; } diff --git a/test/util/string_test.dart b/test/util/string_test.dart index db8607098..9aa6563de 100644 --- a/test/util/string_test.dart +++ b/test/util/string_test.dart @@ -77,7 +77,7 @@ void main() { group("at the very beginning that's", () { for (var (name, (char, escape)) in chars.pairs) { - test(name, () => expect(char.toCssIdentifier(), equals('$escape'))); + test(name, () => expect(char.toCssIdentifier(), equals(escape))); } }); diff --git a/tool/grind/bump_version.dart b/tool/grind/bump_version.dart index a7adc5ea0..fcce6be91 100644 --- a/tool/grind/bump_version.dart +++ b/tool/grind/bump_version.dart @@ -59,14 +59,14 @@ void _bumpVersion(bool patch, bool dev) { void addChangelogEntry(String dir, Version version) { var path = p.join(dir, "CHANGELOG.md"); var text = File(path).readAsStringSync(); - if (!dev && text.startsWith("## ${version}-dev\n")) { + if (!dev && text.startsWith("## $version-dev\n")) { File(path).writeAsStringSync( - text.replaceFirst("## ${version}-dev\n", "## ${version}\n")); - } else if (text.startsWith("## ${version}\n")) { + text.replaceFirst("## $version-dev\n", "## $version\n")); + } else if (text.startsWith("## $version\n")) { return; } else { File(path).writeAsStringSync( - "## ${version}\n\n* No user-visible changes.\n\n$text"); + "## $version\n\n* No user-visible changes.\n\n$text"); } }