From 1a4b35d78bb1e7c1576eb462960edda3c0f1a9d7 Mon Sep 17 00:00:00 2001 From: i10416 Date: Mon, 28 Feb 2022 03:32:13 +0900 Subject: [PATCH] small housekeeping - add github actions to run linter and test for PR - update analysis_options.yaml more pedantic - address linter warning - --- .github/workflows/test.yaml | 21 +++++++++++++++++++ .travis.yml | 7 ------- analysis_options.yaml | 19 ++++++++++++++++- test/parser_test.dart | 13 ++++++------ tool/travis.sh | 42 ------------------------------------- 5 files changed, 45 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml delete mode 100755 tool/travis.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..d4eb306 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,21 @@ +name: test +on: + pull_request: + types: [opened, synchronize] + push: + branches: [ master ] +jobs: + test: + name: test + runs-on: ubuntu-latest + container: + image: google/dart:latest + steps: + - name: set up repository + uses: actions/checkout@v2 + - name: install deps + run: pub get + - name: analyzer + run: dartanalyzer --fatal-warnings --fatal-infos . + - name: test + run: dart test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b6991b8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -node_js: - - "0.11" -before_install: - - export DISPLAY=:99.0 -script: - - ./tool/travis.sh diff --git a/analysis_options.yaml b/analysis_options.yaml index cba1723..9fb9bc6 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,4 +2,21 @@ linter: rules: unawaited_futures: true curly_braces_in_flow_control_structures: true - avoid_catches_without_on_clauses: true \ No newline at end of file + avoid_catches_without_on_clauses: true + avoid_empty_else: true + avoid_print: true + empty_catches: true + prefer_const_constructors_in_immutables: true + prefer_const_constructors: true + prefer_const_declarations: true + unnecessary_const: true + prefer_final_fields: true + prefer_null_aware_operators: true + provide_deprecation_message: true + unnecessary_new: true + unnecessary_null_aware_assignments: true + unnecessary_null_in_if_null_operators: true + unnecessary_overrides: true + unnecessary_parenthesis: true + unnecessary_statements: true + valid_regexps: true diff --git a/test/parser_test.dart b/test/parser_test.dart index 98e4291..484478f 100644 --- a/test/parser_test.dart +++ b/test/parser_test.dart @@ -312,7 +312,9 @@ void main() { fail('Did not throw.'); } on Exception catch (ex, st) { if (ex is! TemplateException) { + // ignore: avoid_print print(ex); + // ignore: avoid_print print(st); } return ex; @@ -381,28 +383,25 @@ bool nodeEqual(a, b) { a.start == b.start && a.end == b.end; } else if (a is VariableNode) { - return a is VariableNode && - a.name == b.name && + return a.name == b.name && a.escape == b.escape && a.start == b.start && a.end == b.end; } else if (a is SectionNode) { - return a is SectionNode && - a.name == b.name && + return a.name == b.name && a.delimiters == b.delimiters && a.inverse == b.inverse && a.start == b.start && a.end == b.end; } else if (a is PartialNode) { - return a is PartialNode && a.name == b.name && a.indent == b.indent; + return a.name == b.name && a.indent == b.indent; } else { return false; } } bool tokenEqual(Token a, Token b) { - return a is Token && - a.type == b.type && + return a.type == b.type && a.value == b.value && a.start == b.start && a.end == b.end; diff --git a/tool/travis.sh b/tool/travis.sh deleted file mode 100755 index 03add83..0000000 --- a/tool/travis.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details. -# All rights reserved. Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# Fast fail the script on failures. -set -e - -# Get the Dart SDK (only for travis-ci.org; otherwise, assume that Dart is already available). -if [ "$TRAVIS" = "true" ]; then - DART_DIST=dartsdk-linux-x64-release.zip - curl http://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/$DART_DIST > $DART_DIST - unzip $DART_DIST > /dev/null - rm $DART_DIST - export DART_SDK="$PWD/dart-sdk" - export PATH="$DART_SDK/bin:$PATH" -fi - -# Display installed versions. -dart --version - -export PATH="$PATH":"~/.pub-cache/bin" - -# Get our packages. -pub get - -# Verify that the libraries are error free. -dartanalyzer lib/mustache.dart -dartanalyzer test/mustache_test.dart - -# Download spec tests -git clone https://github.com/mustache/spec.git test/spec - -# Run the tests. -dart --checked test/all.dart - -# Gather and send coverage data. -if [ "$REPO_TOKEN" ]; then - pub global activate dart_coveralls - pub global run dart_coveralls report --token $REPO_TOKEN --retry 2 --exclude-test-files test/all.dart -fi