diff --git a/Dockerfile b/Dockerfile index 64a72cbd..d01b7b13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ FROM scalameta/scalafmt:v3.7.17 as scalafmt FROM zricethezav/gitleaks:v8.18.1 as gitleaks FROM yoheimuta/protolint:0.47.3 as protolint FROM ghcr.io/clj-kondo/clj-kondo:2023.05.18-alpine as clj-kondo +FROM dart:3.2.4-sdk as dart FROM python:3.12.1-alpine3.19 as base_image @@ -221,6 +222,13 @@ RUN --mount=type=secret,id=GITHUB_TOKEN /install-glibc.sh && rm -rf /install-gli ##################### COPY --from=clj-kondo /bin/clj-kondo /usr/bin/ +#################### +# Install dart-sdk # +#################### +ENV DART_SDK /usr/lib/dart +COPY --from=dart "${DART_SDK}" "${DART_SDK}" +RUN chmod 755 "${DART_SDK}" && chmod 755 "${DART_SDK}/bin" + ################# # Install Lintr # ################# @@ -259,13 +267,6 @@ RUN --mount=type=secret,id=GITHUB_TOKEN /install-ktlint.sh && rm -rf /install-kt ################################################# RUN apk add --no-cache rakudo zef -#################### -# Install dart-sdk # -#################### -ARG DART_VERSION='2.8.4' -COPY scripts/install-dart-sdk.sh / -RUN /install-dart-sdk.sh && rm -rf /install-dart-sdk.sh - ###################### # Install CheckStyle # ###################### @@ -320,6 +321,7 @@ ENV PATH="${PATH}:/venvs/yamllint/bin" ENV PATH="${PATH}:/venvs/yq/bin" ENV PATH="${PATH}:/node_modules/.bin" ENV PATH="${PATH}:/usr/lib/go/bin" +ENV PATH="${PATH}:${DART_SDK}/bin:/root/.pub-cache/bin" # Configure TFLint plugin folder ENV TFLINT_PLUGIN_DIR="/root/.tflint.d/plugins" diff --git a/TEMPLATES/analysis_options.yml b/TEMPLATES/analysis_options.yml deleted file mode 100644 index 0c444f44..00000000 --- a/TEMPLATES/analysis_options.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -########################## -########################## -## Dart Linter rules ## -########################## -########################## - -# Pedantic Rules -# https://github.com/dart-lang/pedantic - -linter: - rules: - - always_declare_return_types - - always_require_non_null_named_parameters - - annotate_overrides - - avoid_empty_else - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_relative_lib_imports - - avoid_return_types_on_setters - - avoid_shadowing_type_parameters - - avoid_types_as_parameter_names - - camel_case_extensions - - curly_braces_in_flow_control_structures - - empty_catches - - empty_constructor_bodies - - library_names - - library_prefixes - - no_duplicate_case_values - - null_closures - - omit_local_variable_types - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_contains - - prefer_equal_for_default_values - - prefer_final_fields - - prefer_for_elements_to_map_fromIterable - - prefer_generic_function_type_aliases - - prefer_if_null_operators - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType - - prefer_single_quotes - - prefer_spread_collections - - recursive_getters - - slash_for_doc_comments - - type_init_formals - - unawaited_futures - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - unnecessary_this - - unrelated_type_equality_checks - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - valid_regexps diff --git a/docs/upgrade-guide.md b/docs/upgrade-guide.md index df957e79..ade33fbc 100644 --- a/docs/upgrade-guide.md +++ b/docs/upgrade-guide.md @@ -8,6 +8,15 @@ This document helps you upgrade from a super-linter version to newer ones: This section helps you migrate from super-linter `v5` to `v6`. +### Dart + +- super-linter doesn't include a default configuration file for `dart analyzer` + because the Dart SDK doesn't support running `dart analyzer` against an + arbitrary configuration file anymore. For more information about how to + customize static analysis of Dart files, see + [Customizing static analysis](https://dart.dev/tools/analysis) in the Dart SDK + documentation. + ### Experimental batch workers - Experimental batch support is deprecated. You can safely remove the diff --git a/lib/linter.sh b/lib/linter.sh index 4c7e8d2c..360b7b55 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -140,8 +140,6 @@ CLOUDFORMATION_FILE_NAME=".cfnlintrc.yml" # shellcheck disable=SC2034 # Variable is referenced indirectly COFFEESCRIPT_FILE_NAME=".coffee-lint.json" CSS_FILE_NAME="${CSS_FILE_NAME:-.stylelintrc.json}" -# shellcheck disable=SC2034 # Variable is referenced indirectly -DART_FILE_NAME="analysis_options.yml" DOCKERFILE_HADOLINT_FILE_NAME="${DOCKERFILE_HADOLINT_FILE_NAME:-.hadolint.yaml}" EDITORCONFIG_FILE_NAME="${EDITORCONFIG_FILE_NAME:-.ecrc}" # shellcheck disable=SC2034 # Variable is referenced indirectly @@ -947,7 +945,7 @@ LINTER_COMMANDS_ARRAY['COFFEESCRIPT']="coffeelint -f ${COFFEESCRIPT_LINTER_RULES LINTER_COMMANDS_ARRAY['CPP']="cpplint" LINTER_COMMANDS_ARRAY['CSHARP']="dotnet format whitespace --folder --verify-no-changes --exclude / --include" LINTER_COMMANDS_ARRAY['CSS']="stylelint --config ${CSS_LINTER_RULES}" -LINTER_COMMANDS_ARRAY['DART']="dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" +LINTER_COMMANDS_ARRAY['DART']="dart analyze --fatal-infos --fatal-warnings" LINTER_COMMANDS_ARRAY['DOCKERFILE_HADOLINT']="hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" LINTER_COMMANDS_ARRAY['EDITORCONFIG']="editorconfig-checker -config ${EDITORCONFIG_LINTER_RULES}" LINTER_COMMANDS_ARRAY['ENV']="dotenv-linter" diff --git a/scripts/install-dart-sdk.sh b/scripts/install-dart-sdk.sh deleted file mode 100755 index 9fe8fe98..00000000 --- a/scripts/install-dart-sdk.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -case $TARGETARCH in -amd64) - target=x64 - ;; -arm64) - target=arm64 - ;; -*) - echo "$TARGETARCH is not supported" - exit 1 - ;; -esac - -curl --retry 5 --retry-delay 5 -sO "https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-${target}-release.zip" -unzip -q dartsdk-linux-${target}-release.zip -chmod +x dart-sdk/bin/dart* -mv -v dart-sdk/bin/* /usr/bin/ -mv -v dart-sdk/lib/* /usr/lib/ -mv -v dart-sdk/include/* /usr/include/ -rm -rv dart-sdk/ dartsdk-linux-${target}-release.zip diff --git a/test/inspec/super-linter/controls/super_linter.rb b/test/inspec/super-linter/controls/super_linter.rb index 22344968..02d9ed01 100644 --- a/test/inspec/super-linter/controls/super_linter.rb +++ b/test/inspec/super-linter/controls/super_linter.rb @@ -483,7 +483,6 @@ control "super-linter-validate-files" do "/action/lib/.automation/.stylelintrc.json", "/action/lib/.automation/.tflint.hcl", "/action/lib/.automation/.yaml-lint.yml", - "/action/lib/.automation/analysis_options.yml", "/action/lib/.automation/phpcs.xml", "/action/lib/.automation/phpstan.neon", "/action/lib/.automation/psalm.xml", diff --git a/test/linters/dart/dart_bad_1.dart b/test/linters/dart/dart_bad_1.dart index c8e4746e..bdde4a98 100644 --- a/test/linters/dart/dart_bad_1.dart +++ b/test/linters/dart/dart_bad_1.dart @@ -1,5 +1,3 @@ -// empty_constructor_bodies bad {} -class Point { - int x, y; - Point(this.x, this.y) {} +void increment() { + count++; } diff --git a/test/linters/dart/dart_good_1.dart b/test/linters/dart/dart_good_1.dart index ba9c09c5..233cc40c 100644 --- a/test/linters/dart/dart_good_1.dart +++ b/test/linters/dart/dart_good_1.dart @@ -1,4 +1,3 @@ -// empty_constructor_bodies good ; class Point { int x, y; Point(this.x, this.y);