diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a1d3fb5..a969f092 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,6 +82,22 @@ code_analyze: - dart format lib/ test/ test_driver/ --set-exit-if-changed - dart analyze +code_quality: + tags: + - docker + stage: coverage + image: google/dart + before_script: + - dart pub global activate dart_code_metrics + script: + - dart pub global run dart_code_metrics:metrics lib -r gitlab > code-quality-report.json + artifacts: + reports: + codequality: code-quality-report.json + # also create an actual artifact for inspection purposes + paths: + - code-quality-report.json + build_doc: tags: - docker diff --git a/analysis_options.yaml b/analysis_options.yaml index 9e295c27..2d42f778 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -19,3 +19,36 @@ analyzer: - example/main.dart # needed until crypto packages upgrade - lib/src/database/database.g.dart + plugins: + # Show code metrics in IDE + - dart_code_metrics + +dart_code_metrics: + metrics: + cyclomatic-complexity: 20 + number-of-arguments: 4 + maximum-nesting-level: 5 + source-lines-of-code: 50 + # This is still unstable, so handle with care + maintainability-index: 40 + metrics-exclude: + - test/** + rules: + #- newline-before-return + - no-boolean-literal-compare + - no-empty-block + #- prefer-trailing-comma + - prefer-conditional-expressions + - no-equal-arguments + - no-equal-then-else + - no-magic-number: + severity: style # too noisy otherwise atm + - avoid-late-keyword: + severity: style # too noisy otherwise atm + - avoid-non-null-assertion: + severity: style # too noisy otherwise atm + - avoid-unused-parameters + - binary-expression-operand-order + anti-patterns: + - long-method + - long-parameter-list diff --git a/pubspec.yaml b/pubspec.yaml index a1c83749..3e0a82b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: collection: ^1.15.0 dev_dependencies: + dart_code_metrics: ^4.4.0 pedantic: ^1.11.0 test: ^1.15.7 coverage: ">=0.15.0 <2.0.0"