Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test bug #121

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/Handler-Comment-Issues.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ jobs:
channel: stable
version: 3.13.8
- name: Install dependencies
run: dart pub get
run: dart pub get
- name: Run Tests
run: dart test
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# Changelog

## 1.1.3

- Fix: bug tests

## 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)
14 changes: 7 additions & 7 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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)
1 change: 0 additions & 1 deletion TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const packageVersion = '1.1.2';
const packageVersion = '1.1.3';
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -12,7 +12,7 @@ platforms:
macos:

dependencies:
analyzer: ^6.0.0
analyzer: ^5.13.0
Copy link
Contributor

@santitigaga santitigaga Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR #110 fixed that, please continue using analyzer: ^6.0.0

thanks for your help

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your response. I attempted to upgrade to the latest version 6.0.0, but it doesn't work with this PR because of the incompatibility introduced by analyzer 6.0.0, which implemented 'final' and this affects the functionality. I tried to clone the analyzer project, but it's out of my reach. I hope you consider this regarding the PR. In my opinion, this PR will be closed due to being out of scope.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can complete issues in separated PR: feat: add job test on CI/CD pipeline maybe in one PR,
finally in other PR you can complete style: smell code.

Regards

analyzer_plugin: ^0.11.0
ansicolor: ^2.0.1
args: ^2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Future<void> main() async {
final visitor = CyclomaticComplexityFlowVisitor();
declaration.visitChildren(visitor);

expect(visitor.complexityEntities, hasLength(14));
expect(visitor.complexityEntities, hasLength(13));
});

test('common function', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Future<void> 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);
Expand All @@ -46,7 +46,6 @@ Future<void> 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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Future<void> 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', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
'Entity',
).outerHtml,
equals(
'<div class="metrics-source-code__tooltip"><div class="metrics-source-code__tooltip-title">Entity&amp;nbsp;stats:</div><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/metric%202" target="_blank" rel="noopener noreferrer" title="metric 2">metric 2:&amp;nbsp;</a><span>2</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric 2 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--noted">noted</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/number-of-methods" target="_blank" rel="noopener noreferrer" title="metric1">metric1:&amp;nbsp;</a><span>0</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric1 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--none">none</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/weight-of-class" target="_blank" rel="noopener noreferrer" title="metric2">metric2:&amp;nbsp;</a><span>1</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric2 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--none">none</span></p></div></p></div>',
'<div class="metrics-source-code__tooltip"><div class="metrics-source-code__tooltip-title">Entity&amp;nbsp;stats:</div><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/metric%202" target="_blank" rel="noopener noreferrer" title="metric 2">metric 2:&amp;nbsp;</a><span>2</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric 2 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--noted">noted</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/number-of-methods" target="_blank" rel="noopener noreferrer" title="metric1">metric1:&amp;nbsp;</a><span>0</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric1 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--none">none</span></p></div></p><p class="metrics-source-code__tooltip-text"><div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/weight-of-class" target="_blank" rel="noopener noreferrer" title="metric2">metric2:&amp;nbsp;</a><span>1</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric2 violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--none">none</span></p></div></p></div>',
),
);
},
Expand All @@ -46,7 +46,7 @@ void main() {
),
).outerHtml,
equals(
'<div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div>',
'<div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div>',
),
);

Expand All @@ -60,7 +60,7 @@ void main() {
),
).outerHtml,
equals(
'<div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10 units</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div>',
'<div class="metrics-source-code__tooltip-section"><p class="metrics-source-code__tooltip-text"><a class="metrics-source-code__tooltip-link" href="https://dcl.apps.bancolombia.com/docs/metrics/metric" target="_blank" rel="noopener noreferrer" title="metric">metric:&amp;nbsp;</a><span>10 units</span></p><p class="metrics-source-code__tooltip-text"><span class="metrics-source-code__tooltip-label">metric violation level:&amp;nbsp;</span><span class="metrics-source-code__tooltip-level metrics-source-code__tooltip-level--warning">warning</span></p></div>',
),
);
},
Expand Down
4 changes: 2 additions & 2 deletions test/src/analyzers/lint_analyzer/rules/rule_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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',
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/src/config_builder/analysis_options_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tools/analyzer_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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