From 87d7ce3e618f7706d750aa0ecc410b0b1fe4666b Mon Sep 17 00:00:00 2001 From: Santiago Garcia Gil Date: Wed, 4 Sep 2024 10:38:13 -0500 Subject: [PATCH] fix: tests --- .fvmrc | 3 +++ .github/workflows/build.yaml | 4 +++- .gitignore | 3 +++ .vscode/settings.json | 3 +++ CHANGELOG.md | 5 ++++- example/pubspec.yaml | 2 -- lib/src/version.dart | 2 +- pubspec.yaml | 4 ++-- .../cyclomatic_complexity_flow_visitor_test.dart | 2 +- .../cyclomatic_complexity_metric_test.dart | 5 ++--- .../source_lines_of_code_metric_test.dart | 4 ++-- .../html/components/report_details_tooltip_test.dart | 6 +++--- test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart | 4 ++-- .../list_all_equatable_fields_rule_test.dart | 2 +- .../examples/invalid_class_example.dart | 1 - test/src/config_builder/analysis_options_utils_test.dart | 2 +- tools/analyzer_plugin/pubspec.yaml | 4 ++-- 17 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 .fvmrc create mode 100644 .vscode/settings.json delete mode 100644 test/src/analyzers/lint_analyzer/rules/rules_list/prefer_correct_type_name/examples/invalid_class_example.dart diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 000000000..3072dbc61 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.13.8" +} \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f22003c4c..3c81a9417 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,4 +17,6 @@ jobs: channel: stable version: 3.13.8 - name: Install dependencies - run: dart pub get \ No newline at end of file + run: dart pub get + - name: Run tests + run: dart test \ No newline at end of file diff --git a/.gitignore b/.gitignore index bea1987ff..21b089d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ doc/api/ .vscode/launch.json test/fake_test.dart + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..da7c81b58 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dart.flutterSdkPath": ".fvm/versions/3.13.8" +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f6fbbc44..ba357f0ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog +## 1.1.3 +- Fix some test +- Revert `analyzer` ^6.0.0 to ^5.14.0 ## 1.1.2 -- append new presset `analysis_options.1.0.0.yaml` +- Append new presset `analysis_options.1.0.0.yaml` ## 1.1.1 - Rename common rules to dart rules ## 1.1.0 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a1d79cc86..b0003a49b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,8 +17,6 @@ dev_dependencies: #dart_code_linter: dart_code_linter: path: ../ - flutter_test: - sdk: flutter flutter: uses-material-design: true diff --git a/lib/src/version.dart b/lib/src/version.dart index 32f1a9bc5..94905116a 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1 +1 @@ -const packageVersion = '1.1.2'; +const packageVersion = '1.1.3'; diff --git a/pubspec.yaml b/pubspec.yaml index ac8f4f10c..0b01a39d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_code_linter -version: 1.1.2 +version: 1.1.3 description: Dart Code Linter is a software analytics tool that helps developers analyse and improve software quality. Dart Code Linter is based on a fork of Dart Code Metrics. repository: https://github.com/bancolombia/dart-code-linter @@ -12,7 +12,7 @@ platforms: macos: dependencies: - analyzer: ^6.0.0 + analyzer: ^5.13.0 analyzer_plugin: ^0.11.0 ansicolor: ^2.0.1 args: ^2.0.0 diff --git a/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_flow_visitor_test.dart b/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_flow_visitor_test.dart index 33a190c39..b91764651 100644 --- a/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_flow_visitor_test.dart +++ b/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_flow_visitor_test.dart @@ -22,7 +22,7 @@ Future main() async { final visitor = CyclomaticComplexityFlowVisitor(); declaration.visitChildren(visitor); - expect(visitor.complexityEntities, hasLength(14)); + expect(visitor.complexityEntities, hasLength(13)); }); test('common function', () { diff --git a/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric_test.dart b/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric_test.dart index 41ce917ed..591b4b4fd 100644 --- a/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric_test.dart +++ b/test/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric_test.dart @@ -29,12 +29,12 @@ Future main() async { ); expect(metricValue.metricsId, equals(metric.id)); - expect(metricValue.value, equals(15)); + expect(metricValue.value, equals(14)); expect(metricValue.level, equals(MetricValueLevel.warning)); expect( metricValue.comment, equals( - 'This function has a cyclomatic complexity of 15, which exceeds the maximum of 10 allowed.', + 'This function has a cyclomatic complexity of 14, which exceeds the maximum of 10 allowed.', ), ); expect(metricValue.recommendation, isNull); @@ -46,7 +46,6 @@ Future main() async { 'Conditional expression increases complexity', 'For statement increases complexity', 'If statement increases complexity', - 'Switch case increases complexity', 'Switch default increases complexity', 'While statement increases complexity', 'Yield statement increases complexity', diff --git a/test/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric_test.dart b/test/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric_test.dart index 6cc606139..2ae3543e2 100644 --- a/test/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric_test.dart +++ b/test/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric_test.dart @@ -41,8 +41,8 @@ Future main() async { metricValue.context.single.message, equals('line contains source code'), ); - expect(metricValue.context.single.location.start.offset, equals(450)); - expect(metricValue.context.single.location.end.offset, equals(450)); + expect(metricValue.context.single.location.start.offset, equals(446)); + expect(metricValue.context.single.location.end.offset, equals(446)); }); test('class method', () { diff --git a/test/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip_test.dart b/test/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip_test.dart index 996bfe657..616d3b318 100644 --- a/test/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip_test.dart +++ b/test/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip_test.dart @@ -28,7 +28,7 @@ void main() { 'Entity', ).outerHtml, equals( - '
Entity stats:

metric: 10

metric violation level: warning

metric 2: 2

metric 2 violation level: noted

metric1: 0

metric1 violation level: none

metric2: 1

metric2 violation level: none

', + '
Entity stats:

metric: 10

metric violation level: warning

metric 2: 2

metric 2 violation level: noted

metric1: 0

metric1 violation level: none

metric2: 1

metric2 violation level: none

', ), ); }, @@ -46,7 +46,7 @@ void main() { ), ).outerHtml, equals( - '

metric: 10

metric violation level: warning

', + '

metric: 10

metric violation level: warning

', ), ); @@ -60,7 +60,7 @@ void main() { ), ).outerHtml, equals( - '

metric: 10 units

metric violation level: warning

', + '

metric: 10 units

metric violation level: warning

', ), ); }, diff --git a/test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart b/test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart index d1e3cce37..c5809e49a 100644 --- a/test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart +++ b/test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart @@ -16,7 +16,7 @@ void main() { () { const id = 'rule-id'; final documentationUrl = Uri.parse( - 'https://dcl.apps.bancolombia.com/rules/flutter/rule-id', + 'https://dcl.apps.bancolombia.com/docs/rules/flutter/rule-id', ); const severity = Severity.none; @@ -72,7 +72,7 @@ void main() { expect( documentation(rule1).toString(), equals( - 'https://dcl.apps.bancolombia.com/rules/flutter/$ruleId1', + 'https://dcl.apps.bancolombia.com/docs/rules/flutter/$ruleId1', ), ); diff --git a/test/src/analyzers/lint_analyzer/rules/rules_list/list_all_equatable_fields/list_all_equatable_fields_rule_test.dart b/test/src/analyzers/lint_analyzer/rules/rules_list/list_all_equatable_fields/list_all_equatable_fields_rule_test.dart index e17a17453..219f8e094 100644 --- a/test/src/analyzers/lint_analyzer/rules/rules_list/list_all_equatable_fields/list_all_equatable_fields_rule_test.dart +++ b/test/src/analyzers/lint_analyzer/rules/rules_list/list_all_equatable_fields/list_all_equatable_fields_rule_test.dart @@ -22,7 +22,7 @@ void main() { expect( documentationUri.path, - equals('/docs/individuals/rules/common/list-all-equatable-fields'), + equals('/docs/rules/dart/list-all-equatable-fields'), ); }); diff --git a/test/src/analyzers/lint_analyzer/rules/rules_list/prefer_correct_type_name/examples/invalid_class_example.dart b/test/src/analyzers/lint_analyzer/rules/rules_list/prefer_correct_type_name/examples/invalid_class_example.dart deleted file mode 100644 index 8440d1571..000000000 --- a/test/src/analyzers/lint_analyzer/rules/rules_list/prefer_correct_type_name/examples/invalid_class_example.dart +++ /dev/null @@ -1 +0,0 @@ -class \ No newline at end of file diff --git a/test/src/config_builder/analysis_options_utils_test.dart b/test/src/config_builder/analysis_options_utils_test.dart index 15779b773..d54212251 100644 --- a/test/src/config_builder/analysis_options_utils_test.dart +++ b/test/src/config_builder/analysis_options_utils_test.dart @@ -45,7 +45,7 @@ const _merged = { }; void main() { - group('', () { + group('analysis_options_utils_test', () { test('isIterableOfStrings checks type of provided object', () { expect(isIterableOfStrings(null), isFalse); expect(isIterableOfStrings(Object()), isFalse); diff --git a/tools/analyzer_plugin/pubspec.yaml b/tools/analyzer_plugin/pubspec.yaml index 71ece8e52..426bc5721 100644 --- a/tools/analyzer_plugin/pubspec.yaml +++ b/tools/analyzer_plugin/pubspec.yaml @@ -1,12 +1,12 @@ name: dart_code_linter_plugin_loader description: This pubspec determines the version of the analyzer plugin to load. -version: 1.1.2 +version: 1.1.3 environment: sdk: ">=2.14.0 <3.0.0" dependencies: - dart_code_linter: 1.1.2 + dart_code_linter: 1.1.3 dev_dependencies: lints: ^1.0.1