Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
santitigaga committed Sep 4, 2024
1 parent 2dd7f28 commit 87d7ce3
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.13.8"
}
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ doc/api/

.vscode/launch.json
test/fake_test.dart

# FVM Version Cache
.fvm/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.13.8"
}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ dev_dependencies:
#dart_code_linter: <USE-THE-LATEST-VERSION>
dart_code_linter:
path: ../
flutter_test:
sdk: flutter

flutter:
uses-material-design: true
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
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

This file was deleted.

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', () {
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

0 comments on commit 87d7ce3

Please sign in to comment.