From 407f411e21af54f9802b11053e75ec44e94a5c14 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 01:17:20 -0700 Subject: [PATCH 01/11] adding dart support --- .automation/test/dart/README.md | 13 ++++++ .automation/test/dart/dart_bad_1.dart | 6 +++ .automation/test/dart/dart_good_1.dart | 6 +++ .github/linters/.dart-lint.yml | 57 ++++++++++++++++++++++++++ Dockerfile | 9 ++++ README.md | 2 + docs/disabling-linters.md | 29 +++++++++++++ lib/buildFileList.sh | 9 ++++ lib/linter.sh | 25 +++++++++-- lib/validation.sh | 22 +++++++++- lib/worker.sh | 1 + 11 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 .automation/test/dart/README.md create mode 100644 .automation/test/dart/dart_bad_1.dart create mode 100644 .automation/test/dart/dart_good_1.dart create mode 100644 .github/linters/.dart-lint.yml diff --git a/.automation/test/dart/README.md b/.automation/test/dart/README.md new file mode 100644 index 00000000..21299b50 --- /dev/null +++ b/.automation/test/dart/README.md @@ -0,0 +1,13 @@ +# Dart Test Cases +This folder holds the test cases for **Dart**. + +## Additional Docs +No Additional information is needed for this test case. + +## Good Test Cases +The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted. +- **Note:** They are linted utilizing the default linter rules. + +## Bad Test Cases +The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted. +- **Note:** They are linted utilizing the default linter rules. diff --git a/.automation/test/dart/dart_bad_1.dart b/.automation/test/dart/dart_bad_1.dart new file mode 100644 index 00000000..55ef95a4 --- /dev/null +++ b/.automation/test/dart/dart_bad_1.dart @@ -0,0 +1,6 @@ +// empty_constructor_bodies bad {} + +class Point { + int x, y; + Point(this.x, this.y) {} +} diff --git a/.automation/test/dart/dart_good_1.dart b/.automation/test/dart/dart_good_1.dart new file mode 100644 index 00000000..d336bbef --- /dev/null +++ b/.automation/test/dart/dart_good_1.dart @@ -0,0 +1,6 @@ +// empty_constructor_bodies good ; + +class Point { + int x, y; + Point(this.x, this.y); +} diff --git a/.github/linters/.dart-lint.yml b/.github/linters/.dart-lint.yml new file mode 100644 index 00000000..0c444f44 --- /dev/null +++ b/.github/linters/.dart-lint.yml @@ -0,0 +1,57 @@ +--- +########################## +########################## +## 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/Dockerfile b/Dockerfile index 56bc44a8..171ee259 100644 --- a/Dockerfile +++ b/Dockerfile @@ -159,6 +159,14 @@ RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KON RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && chmod a+x ktlint \ && mv "ktlint" /usr/bin/ +#################### +# Install dart-sdk # +#################### +ARG DART_VERSION='2.8.4' +RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip - \ + && mv dart-sdk/bin/* /usr/bin \ + && rm -r "dart-sdk" + ########################################### # Load GitHub Env Vars for GitHub Actions # ########################################### @@ -190,6 +198,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \ VALIDATE_ENV=${VALIDATE_ENV} \ VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \ VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \ + VALIDATE_DART=${VALIDATE_DART} \ VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \ VALIDATE_OPENAPI=${VALIDATE_OPENAPI} \ VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \ diff --git a/README.md b/README.md index 6c1b6520..d29a7676 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **CSS** | [stylelint](https://stylelint.io/) | | **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | +| **Dart** | [dartanalyzer](https://dart.dev/tools/dartanalyzer) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | @@ -176,6 +177,7 @@ and won't run anything unexpected. | **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. | +| **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_OPENAPI** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_PROTOBUF** | `true` | Flag to enable or disable the linting process of the language. | diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 93800eb7..e8ceabe3 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -658,6 +658,35 @@ import package.b.* -------------------------------------------------------------------------------- +## Dart +- [dartanalyzer](https://dart.dev/tools/dartanalyzer) + +### dartanalyzer standard Config file +- `.github/linters/.dart-lint.yml` +- You can pass multiple rules and overwrite default rules +- File should be located at: `.github/linters/.dart-lint.yml` + +### dartanalyzer disable single line +```dart +int x = ''; // ignore: invalid_assignment +``` + +### dartanalyzer disable code block +- You can make [rule exceptions](https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis) for the entire file. +```dart +// ignore_for_file: unused_import, unused_local_variable +``` + +### dartanalyzer disable entire file +- You can disable entire files with the `analyzer.exclude` property in `.dart-lint.yml` +```dart +analyzer: + exclude: + - file +``` + +-------------------------------------------------------------------------------- + ## OpenAPI - [spectral](https://github.com/stoplightio/spectral) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 7334b447..2c274e75 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -336,6 +336,15 @@ function BuildFileList() { ############################ # Get the Protocol Buffers files # ############################ + elif [ "$FILE_TYPE" == "dart" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_DART+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 elif [ "$FILE_TYPE" == "proto" ]; then ################################ # Append the file to the array # diff --git a/lib/linter.sh b/lib/linter.sh index a036dc2c..dc089a6a 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -77,6 +77,9 @@ PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path to th # Clojure Vars CLOJURE_FILE_NAME='.clj-kondo/config.edn' CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" +# Dart Vars +DART_FILE_NAME='.dart-lint.yml' +DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" ####################################### # Linter array for information prints # @@ -85,7 +88,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" "pylint" "perl" "rubocop" "coffeelint" "eslint" "standard" "ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" "stylelint" "dotenv-linter" "pwsh" "ktlint" "protolint" "clj-kondo" - "spectral" "cfn-lint") + "spectral" "cfn-lint" "dart") ############################# # Language array for prints # @@ -93,7 +96,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON' 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' - 'CSS' 'ENV' 'POWERSHELL' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CFN') + 'CSS' 'ENV' 'POWERSHELL' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CFN' 'DART') ################### # GitHub ENV Vars # @@ -129,6 +132,7 @@ VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to vali VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language VALIDATE_OPENAPI="${VALIDATE_OPENAPI}" # Boolean to validate language +VALIDATE_DART="${VALIDATE_DART}" # Boolean to validate language TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors @@ -219,6 +223,7 @@ ERRORS_FOUND_CLOJURE=0 # Count of errors found ERRORS_FOUND_KOTLIN=0 # Count of errors found ERRORS_FOUND_PROTOBUF=0 # Count of errors found ERRORS_FOUND_OPENAPI=0 # Count of errors found +ERRORS_FOUND_DART=0 # Count of errors found ################################################################################ ########################## FUNCTIONS BELOW ##################################### @@ -727,7 +732,8 @@ Footer() { [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || - [ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then + [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || + [ "$ERRORS_FOUND_DART" -ne 0 ]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" exit 1 @@ -795,6 +801,8 @@ GetLinterRules "POWERSHELL" GetLinterRules "CSS" # Get CFN rules GetLinterRules "CFN" +# Get DART rules +GetLinterRules "DART" ################################# # Check if were in verbose mode # @@ -1069,6 +1077,17 @@ if [ "$VALIDATE_KOTLIN" == "true" ]; then LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_KOTLIN[@]}" fi +################## +# DART LINTING # +################## +if [ "$VALIDATE_DART" == "true" ]; then + ####################### + # Lint the Dart files # + ####################### + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "DART" "dart" "dartanalyzer --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" +fi + ################## # DOCKER LINTING # ################## diff --git a/lib/validation.sh b/lib/validation.sh index 988abea5..2850dbf5 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -100,7 +100,8 @@ function GetValidationInfo() { $VALIDATE_CLOJURE || -n \ $VALIDATE_PROTOBUF || -n \ $VALIDATE_OPENAPI || -n \ - $VALIDATE_KOTLIN ]]; then + $VALIDATE_KOTLIN || -n \ + $VALIDATE_DART ]]; then ANY_SET="true" fi @@ -412,6 +413,20 @@ function GetValidationInfo() { VALIDATE_KOTLIN="true" fi + #################################### + # Validate if we should check DART # + #################################### + if [[ $ANY_SET == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z $VALIDATE_DART ]]; then + # ENV flag was not set - default to false + VALIDATE_DART="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_DART="true" + fi + ####################################### # Validate if we should check OPENAPI # ####################################### @@ -582,6 +597,11 @@ function GetValidationInfo() { else PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...") fi + if [[ $VALIDATE_DART == "true" ]]; then + PRINT_ARRAY+=("- Validating [DART] files in code base...") + else + PRINT_ARRAY+=("- Excluding [DART] files in code base...") + fi ############################## # Validate Ansible Directory # diff --git a/lib/worker.sh b/lib/worker.sh index 4382620a..6fb6e52d 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -477,6 +477,7 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" + TestCodebase "DART" "dart" "dartanalyzer --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" ################# # Footer prints # From b4fe702ec414d6f54c90880be2a8c5eda65c112b Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 10:51:49 -0700 Subject: [PATCH 02/11] add glibc compat layer for alpine via apk --- Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 171ee259..a7791132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -162,10 +162,18 @@ RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktli #################### # Install dart-sdk # #################### +# install alpine-pkg-glibc (glibc compatibility layer package for Alpine Linux) +ARG GLIBC_VERSION='2.31-r0' +RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub +RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk +RUN apk add glibc-${GLIBC_VERSION}.apk + +# install dart sdk ARG DART_VERSION='2.8.4' RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip - \ - && mv dart-sdk/bin/* /usr/bin \ - && rm -r "dart-sdk" + && chmod +x dart-sdk/bin/dart* \ + && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \ + && rm -r dart-sdk/ ########################################### # Load GitHub Env Vars for GitHub Actions # From 05e73c61270cbe2e84117712069788f97cfbbdc5 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 11:14:55 -0700 Subject: [PATCH 03/11] fix merge conflict, whoops --- lib/validation.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/validation.sh b/lib/validation.sh index ad7f2f29..b7a1ce28 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -105,12 +105,9 @@ function GetValidationInfo() { $VALIDATE_PROTOBUF || -n \ $VALIDATE_OPENAPI || -n \ $VALIDATE_KOTLIN || -n \ -<<<<<<< HEAD - $VALIDATE_DART ]]; then -======= + $VALIDATE_DART || -n \ $VALIDATE_EDITORCONFIG || -n \ $VALIDATE_HTML ]]; then ->>>>>>> master ANY_SET="true" fi From 4ea4aef02ea78a95ffe8a25b2bb11f5b46178650 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 15:06:56 -0700 Subject: [PATCH 04/11] update documentation for dart --- .automation/test/dart/dart_bad_1.dart | 1 - .automation/test/dart/dart_good_1.dart | 1 - Dockerfile | 2 +- README.md | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.automation/test/dart/dart_bad_1.dart b/.automation/test/dart/dart_bad_1.dart index 55ef95a4..c8e4746e 100644 --- a/.automation/test/dart/dart_bad_1.dart +++ b/.automation/test/dart/dart_bad_1.dart @@ -1,5 +1,4 @@ // empty_constructor_bodies bad {} - class Point { int x, y; Point(this.x, this.y) {} diff --git a/.automation/test/dart/dart_good_1.dart b/.automation/test/dart/dart_good_1.dart index d336bbef..ba9c09c5 100644 --- a/.automation/test/dart/dart_good_1.dart +++ b/.automation/test/dart/dart_good_1.dart @@ -1,5 +1,4 @@ // empty_constructor_bodies good ; - class Point { int x, y; Point(this.x, this.y); diff --git a/Dockerfile b/Dockerfile index 6e8f6322..f4f2d806 100644 --- a/Dockerfile +++ b/Dockerfile @@ -190,7 +190,7 @@ RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/s RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk RUN apk add glibc-${GLIBC_VERSION}.apk -# install dart sdk +# stable dart sdk: https://dart.dev/get-dart#release-channels ARG DART_VERSION='2.8.4' RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip - \ && chmod +x dart-sdk/bin/dart* \ diff --git a/README.md b/README.md index 5875572e..d6c14050 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base | **CSS** | [stylelint](https://stylelint.io/) | | **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | -| **Dart** | [dartanalyzer](https://dart.dev/tools/dartanalyzer) | +| **Dart** | [dartanalyzer](https://dart.dev/guides/language/analysis-options) | | **Dockerfile** | [dockerfilelint](https://github.com/replicatedhq/dockerfilelint.git) | | **EDITORCONFIG** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | | **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | From 433b10bdc9bc2a8e78df5ada8b3b4b2e91ff94f9 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 21:18:17 -0700 Subject: [PATCH 05/11] fix sytax error, missing fi --- lib/validation.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/validation.sh b/lib/validation.sh index b7a1ce28..707836dc 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -654,6 +654,7 @@ function GetValidationInfo() { PRINT_ARRAY+=("- Validating [DART] files in code base...") else PRINT_ARRAY+=("- Excluding [DART] files in code base...") + fi if [[ $VALIDATE_EDITORCONFIG == "true" ]]; then PRINT_ARRAY+=("- Validating [EDITORCONFIG] files in code base...") else From 8f7b2bcc749d629a76299d11c5da19eb397cf4aa Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 21:42:29 -0700 Subject: [PATCH 06/11] add suggested changes from @devoncarew - use analysis_options.yaml file (dart convention), mv .dart-lint.yml - add --fatal-infos switch for testing - add VALIDATE_DART, because I missed it before --- .github/linters/{.dart-lint.yml => analysis_options.yaml} | 0 lib/linter.sh | 2 +- lib/validation.sh | 1 + lib/worker.sh | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename .github/linters/{.dart-lint.yml => analysis_options.yaml} (100%) diff --git a/.github/linters/.dart-lint.yml b/.github/linters/analysis_options.yaml similarity index 100% rename from .github/linters/.dart-lint.yml rename to .github/linters/analysis_options.yaml diff --git a/lib/linter.sh b/lib/linter.sh index a86fcec3..52f45332 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -81,7 +81,7 @@ PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path t CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # Path to the Clojure lint rules # Dart Vars -DART_FILE_NAME='.dart-lint.yml' # Name of the file +DART_FILE_NAME='analysis_options.yaml' # Name of the file DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" # Path to the DART lint rules # HTML Vars HTML_FILE_NAME='.htmlhintrc' # Name of the file diff --git a/lib/validation.sh b/lib/validation.sh index 707836dc..bc4f2682 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -73,6 +73,7 @@ function GetValidationInfo() { VALIDATE_PROTOBUF=$(echo "$VALIDATE_PROTOBUF" | awk '{print tolower($0)}') VALIDATE_OPENAPI=$(echo "$VALIDATE_OPENAPI" | awk '{print tolower($0)}') VALIDATE_EDITORCONFIG=$(echo "$VALIDATE_EDITORCONFIG" | awk '{print tolower($0)}') + VALIDATE_DART=$(echo "$VALIDATE_DART" | awk '{print tolower($0)}') VALIDATE_HTML=$(echo "$VALIDATE_HTML" | awk '{print tolower($0)}') ################################################ diff --git a/lib/worker.sh b/lib/worker.sh index 3240dca1..48a7a9a9 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -478,7 +478,7 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" - TestCodebase "DART" "dart" "dartanalyzer --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" + TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" TestCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "html" ################# From 20162f330e3533d9b5ef40b3938bda95475ab1b7 Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 22:06:27 -0700 Subject: [PATCH 07/11] add -q flag to unzip for less verbosity --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b98e5579..340e3ff1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -198,7 +198,7 @@ RUN apk add glibc-${GLIBC_VERSION}.apk # stable dart sdk: https://dart.dev/get-dart#release-channels ARG DART_VERSION='2.8.4' -RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip - \ +RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip -q - \ && chmod +x dart-sdk/bin/dart* \ && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \ && rm -r dart-sdk/ From 2cdea4f076c692f8f4cb39a3169bbc74319013ef Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 22:18:31 -0700 Subject: [PATCH 08/11] add --no-cache to apk per linter sugestion --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 340e3ff1..fb8ea84c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -194,7 +194,7 @@ RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktli ARG GLIBC_VERSION='2.31-r0' RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -RUN apk add glibc-${GLIBC_VERSION}.apk +RUN apk --no-cache add glibc-${GLIBC_VERSION}.apk # stable dart sdk: https://dart.dev/get-dart#release-channels ARG DART_VERSION='2.8.4' From abf0bdbf663501c269da630e77bdd64356a1162f Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Mon, 6 Jul 2020 22:23:06 -0700 Subject: [PATCH 09/11] pay respect to the Dockerfile linter, fix apk add --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fb8ea84c..a041c850 100644 --- a/Dockerfile +++ b/Dockerfile @@ -194,7 +194,7 @@ RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktli ARG GLIBC_VERSION='2.31-r0' RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -RUN apk --no-cache add glibc-${GLIBC_VERSION}.apk +RUN apk add --no-cache glibc-${GLIBC_VERSION}.apk # stable dart sdk: https://dart.dev/get-dart#release-channels ARG DART_VERSION='2.8.4' From 95f0c2d534fa3b34f4389ec9e687ad7842d2df9f Mon Sep 17 00:00:00 2001 From: Casey Vega Date: Tue, 14 Jul 2020 23:36:22 -0700 Subject: [PATCH 10/11] add dart pub get and --fatal flags - add `pub get || true` - add --fatal flags to throw 1 on exit Adding `pub get` enables dart to import dev/project dependencies before analysis/linting. It is set to always return true in the event this has already occured somewhere else in the CI workflow a pubspec.yaml does not exist Using `--fatal-(infos|warnings)` allows super-linter to fail when a lint is reported. --- lib/linter.sh | 2 +- lib/worker.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 778c2aef..4950ff7d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1185,7 +1185,7 @@ if [ "$VALIDATE_DART" == "true" ]; then # Lint the Dart files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "DART" "dart" "dartanalyzer --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" + LintCodebase "DART" "dart" "pub get || true && dartanalyzer --fatal-infos --fatal-warnings --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" fi ################## diff --git a/lib/worker.sh b/lib/worker.sh index a8589ea8..3400871a 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -479,7 +479,7 @@ function RunTestCases() { TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" - TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" + TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" TestCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "html" ################# From d180d7082633d2e279ff40fab56e91f8080247a8 Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Wed, 15 Jul 2020 15:49:42 -0500 Subject: [PATCH 11/11] cleanup docker --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 93c10701..494e97ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,11 @@ ARG ARM_TTK_DIRECTORY='/opt/microsoft' ARG RAKU_VER="2020.06" ARG RAKU_INSTALL_PATH=/usr ARG RAKUBREW_HOME=/tmp/rakubrew +# Dart Linter +## stable dart sdk: https://dart.dev/get-dart#release-channels +ARG DART_VERSION='2.8.4' +## install alpine-pkg-glibc (glibc compatibility layer package for Alpine Linux) +ARG GLIBC_VERSION='2.31-r0' #################### # Run APK installs # @@ -162,14 +167,9 @@ RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktli #################### # Install dart-sdk # #################### -# install alpine-pkg-glibc (glibc compatibility layer package for Alpine Linux) -ARG GLIBC_VERSION='2.31-r0' RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk RUN apk add --no-cache glibc-${GLIBC_VERSION}.apk - -# stable dart sdk: https://dart.dev/get-dart#release-channels -ARG DART_VERSION='2.8.4' RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip -q - \ && chmod +x dart-sdk/bin/dart* \ && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \