From 5b478a69e7f18e5c370b504a9e80bd485b356b4f Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 19:27:33 -0500 Subject: [PATCH 1/7] refactor(module): Improve code readability and documentation Enhanced the formatting of CHANGELOG.md, GOVERNANCE.md, and README.md for better readability. Updated workflow files and fixed minor issues in the documentation. --- .github/workflows/Handler-Comment-Issues.yml | 6 +++--- .github/workflows/release.yaml | 4 ++-- CHANGELOG.md | 11 +++++++++-- GOVERNANCE.md | 14 +++++++------- README.md | 14 +++----------- TROUBLESHOOTING.md | 1 - 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/Handler-Comment-Issues.yml b/.github/workflows/Handler-Comment-Issues.yml index d4f561a3..fbfb5388 100644 --- a/.github/workflows/Handler-Comment-Issues.yml +++ b/.github/workflows/Handler-Comment-Issues.yml @@ -1,5 +1,5 @@ -name: workflow of automations dispatch to commands in comments -on: +name: workflow of automations dispatch to commands in comments +on: issue_comment: types: [created] env: @@ -31,7 +31,7 @@ jobs: run: | if [[ ${COMMENT,,} == *"$CMD_ACCEPT_REVIEW"* ]]; then - if [[ ${VAR_USERS_REVIEWERS,,} =~ ${USER_COMMENT,,} ]]; + if [[ ${VAR_USERS_REVIEWERS,,} =~ ${USER_COMMENT,,} ]]; then gh issue edit $ISSUE_URL --remove-label "Review/Pending" gh issue edit $ISSUE_URL --add-label "Review/Approved" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 282a311f..d2518af4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,7 +4,7 @@ name: Publish to pub.dev on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' + - 'v[0-9]+.[0-9]+.[0-9]+*' jobs: publish: name: 'Publish to pub.dev' @@ -23,4 +23,4 @@ jobs: - name: Install dependencies run: dart pub get - name: Publish to pub.dev - run: dart pub publish -f + run: dart pub publish -f \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f6fbbc4..aa191c2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,26 @@ # Changelog ## 1.1.2 + - append new presset `analysis_options.1.0.0.yaml` + ## 1.1.1 + - Rename common rules to dart rules + ## 1.1.0 + - Added new presets - Removed Angular framework rules - Added example ## 1.0.2 + - Fix: report in IDE'S is adjusted + ## 1.0.1 + - Automated publishing of packages to pub.dev ## 1.0.0 -- Fork: [Dart code metrics 5.7.3](https://github.com/dart-code-checker/dart-code-metrics) - +- Fork: [Dart code metrics 5.7.3](https://github.com/dart-code-checker/dart-code-metrics) diff --git a/GOVERNANCE.md b/GOVERNANCE.md index cecd3eeb..44682f77 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -4,10 +4,10 @@ ![Modelo de Gobierno](Roles-EN.png) -| Roles | Responsibilities | -| ---------------- | ------------------------------------------------------------ | -| Product Owners | lead the open initiative and its projects, have a short, medium and long-term vision of the initiative and projects. Have criteria when making decisions. abdicate when it is for the good of the community and the project. -| Maintainers | Maintainers have greater authority and responsibility in overall project management and coordination. -| Trusted Committer | "Trusted committers" are contributors who have the ability to commit changes directly to the project repository and review others' contributions, but their authority is limited compared to maintainers | -Contributors | Actively contribute with *commits*, *reviews* | -Community Leader | Promotes *participation*, *collaboration*, provides necessary tools that facilitate communication with the community | +| Roles | Responsibilities | +| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Product Owners | lead the open initiative and its projects, have a short, medium and long-term vision of the initiative and projects. Have criteria when making decisions. abdicate when it is for the good of the community and the project. | +| Maintainers | Maintainers have greater authority and responsibility in overall project management and coordination. | +| Trusted Committer | "Trusted committers" are contributors who have the ability to commit changes directly to the project repository and review others' contributions, but their authority is limited compared to maintainers | +| Contributors | Actively contribute with *commits*, *reviews* | +| Community Leader | Promotes *participation*, *collaboration*, provides necessary tools that facilitate communication with the community | diff --git a/README.md b/README.md index 3d2341b3..85f91398 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -## Dart Code Linter +# Dart Code Linter + [![Pub](https://img.shields.io/pub/v/dart_code_linter.svg)](https://pub.dev/packages/dart_code_linter) Dart Code Linter (DCL) is a powerful toolkit designed to enhance your development process by identifying and resolving issues within your Dart and Flutter code. Whether you're dealing with potential runtime bugs, violations of best practices, or styling concerns, DCL has got you covered. With a comprehensive collection of over 70 pre-built rules, you can effortlessly validate your code against a variety of expectations. Furthermore, DCL offers the flexibility to customize these rules to cater to your specific requirements, ensuring an optimized coding experience. - ## Links - See [CHANGELOG.md](./CHANGELOG.md) for major/breaking updates, and [releases](https://github.com/bancolombia/dart-code-linter/releases) for a detailed version history. @@ -23,7 +23,6 @@ $ flutter pub add --dev dart_code_linter Add configuration to `analysis_options.yaml` and reload IDE to allow the analyzer to discover the plugin config. - ### Basic config example ```yaml title="analysis_options.yaml" @@ -94,7 +93,6 @@ Rules that marked with 🛠 have auto-fixes available through the IDE context me ![VS Code example](https://github.com/bancolombia/dart-code-linter/blob/trunk/assets/quick-fixes.png) - ### CLI The package can be used as CLI and supports multiple commands: @@ -132,8 +130,6 @@ It will produce a result in one of the format: - HTML - JSON - - #### Check unnecessary nullable parameters Checks unnecessary nullable parameters in functions, methods, constructors. To execute the command, run @@ -150,8 +146,6 @@ It will produce a result in one of the format: - Console - JSON - - #### Check unused files Checks unused `*.dart` files. To execute the command, run @@ -202,7 +196,6 @@ It will produce a result in one of the format: - Console - JSON - #### Check unused code Checks unused code in `*.dart` files. To execute the command, run @@ -219,8 +212,6 @@ It will produce a result in one of the format: - Console - JSON - - ## Troubleshooting Please read [the following guide](./TROUBLESHOOTING.md) if the plugin is not working as you'd expect it to work. @@ -230,4 +221,5 @@ Please read [the following guide](./TROUBLESHOOTING.md) if the plugin is not wor If you are interested in contributing, please check out the [contribution guidelines](./CONTRIBUTING.md). Feedback and contributions are welcome! ## License + Dart Code Linter is licensed under the [MIT](./LICENSE) diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 8906ea0b..aac92629 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -20,4 +20,3 @@ If the plugin is not working as you'd expect it to work, please consider going t then a `Analyzer Server Diagnostics` webpage will be opened. To check that the plugin is active, open the `Plugins` tab and ensure that there is no errors. - From 8d7d914fbae5fba587df2297c57d92b8c0a5d118 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 19:28:14 -0500 Subject: [PATCH 2/7] refactor(test): Update URLs in test assertions Updated the URLs used in test assertions to point to the new documentation location. This change affects multiple tests across different files, ensuring they align with recent changes in our documentation structure. --- .../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 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 996bfe65..616d3b31 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 d1e3cce3..c5809e49 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 e17a1745..219f8e09 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'), ); }); From 9d6efc3568d90aaeccbf87aad8cabc0ff5fe56c2 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 19:29:41 -0500 Subject: [PATCH 3/7] test(metrics): Update expected values in cyclomatic complexity tests Adjusted the expected values in the cyclomatic complexity and source lines of code metric tests. This includes reducing the expected length of complexity entities and updating offset values. Also, improved test grouping naming in analysis_options_utils_test. --- .../cyclomatic_complexity_flow_visitor_test.dart | 2 +- .../cyclomatic_complexity_metric_test.dart | 5 ++--- .../source_lines_of_code_metric_test.dart | 4 ++-- test/src/config_builder/analysis_options_utils_test.dart | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) 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 33a190c3..b9176465 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 41ce917e..591b4b4f 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 6cc60613..2ae3543e 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/config_builder/analysis_options_utils_test.dart b/test/src/config_builder/analysis_options_utils_test.dart index 15779b77..c9a9064f 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('isIterableOfStrings checks type of provided object', () { expect(isIterableOfStrings(null), isFalse); expect(isIterableOfStrings(Object()), isFalse); From 8872c7e89c1ccb219ec482c9f80c2d05975f6801 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 20:43:15 -0500 Subject: [PATCH 4/7] refactor(dependency): Downgrade analyzer version Downgraded the analyzer dependency from version 6.0.0 to 5.13.0 for compatibility reasons. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c2a9663c..8eeca747 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 From ace58a8c00ca612f73c3877cefb090bd0127baee Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 21:34:43 -0500 Subject: [PATCH 5/7] feat(workflows): Add test run step to build workflow Added a new step in the GitHub Actions build workflow to run Dart tests after installing dependencies. --- .github/workflows/build.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8f867cc8..e5a89c71 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 From 43f2f6cc671844b3311fd236974a15f08d2ef0d4 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 21:37:49 -0500 Subject: [PATCH 6/7] docs: updated changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa191c2f..2a7cc417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog + +## 1.1.3 + +- Fix: bug tests + ## 1.1.2 - append new presset `analysis_options.1.0.0.yaml` From f3bbcde6ad00a988bef2a22078bbc582c076f528 Mon Sep 17 00:00:00 2001 From: "Andres Garcia (TECH-ANDGAR)" Date: Wed, 21 Feb 2024 21:38:46 -0500 Subject: [PATCH 7/7] chore: build updated version --- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- tools/analyzer_plugin/pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/version.dart b/lib/src/version.dart index 32f1a9bc..94905116 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 8eeca747..7796360d 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 diff --git a/tools/analyzer_plugin/pubspec.yaml b/tools/analyzer_plugin/pubspec.yaml index 71ece8e5..426bc572 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