Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 997dfd3

Browse files
authored
fix: remove some typos (#699)
* chore: update cSpell dictionary * fix: format comments like sentences * fix: remove some typos * breaking change: cli arguments `--fatal-unused` and `--fatal-warnings` activate by default. * chore: fix tests * chore: restrict `analyzer` version to `>=2.8.0 <3.3.0` * docs: fix documentation
1 parent d9abbf0 commit 997dfd3

File tree

48 files changed

+94
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+94
-81
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
"files.insertFinalNewline": true,
44
"cSpell.words": [
55
"ansicolor",
6-
"Backport",
6+
"backport",
7+
"behaviour",
78
"bools",
89
"codeclimate",
910
"codecov",
1011
"codequality",
1112
"commitlint",
1213
"cyclomatic",
1314
"dartanalyzer",
15+
"dartcodemetrics",
1416
"dartdocs",
1517
"dependabot",
1618
"dkrutskikh",
@@ -24,6 +26,7 @@
2426
"lcov",
2527
"McCabe's",
2628
"mocktail",
29+
"negatable",
2730
"nullsafety",
2831
"pubignore",
2932
"pubspec",

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* **Breaking Change:** cli arguments `--fatal-unused` and `--fatal-warnings` activate by default.
6+
* chore: restrict `analyzer` version to `>=2.8.0 <3.3.0`.
7+
38
## 4.11.0
49

510
* feat: add static code diagnostics `format-comment`.

example/example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import 'dart:io';
33
import 'package:dart_code_metrics/lint_analyzer.dart';
44

55
Future<void> main() async {
6-
// Get some folder you would like to analyze
6+
// Get some folder you would like to analyze.
77
const foldersToAnalyze = ['lib', 'test'];
88

9-
// Root folder path is used to resolve relative file paths
9+
// Root folder path is used to resolve relative file paths.
1010
const rootFolder = 'projectRoot';
1111

12-
// First of all config has to be created for a checker
12+
// First of all config has to be created for a checker.
1313
const config = LintConfig(
1414
excludePatterns: ['test/resources/**'],
1515
excludeForMetricsPatterns: ['test/**'],

lib/src/analyzer_plugin/analyzer_plugin.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ class AnalyzerPlugin extends ServerPlugin {
147147
) async {
148148
try {
149149
final driver = driverForPath(parameters.file) as AnalysisDriver;
150-
// ignore: deprecated_member_use
151-
final analysisResult = await driver.getResult2(parameters.file);
150+
final analysisResult = await driver.getResult(parameters.file);
152151

153152
if (analysisResult is! ResolvedUnitResult) {
154153
return plugin.EditGetFixesResult([]);
@@ -287,7 +286,7 @@ class AnalyzerPlugin extends ServerPlugin {
287286
...(driver2 as AnalysisDriver).addedFiles,
288287
};
289288

290-
// From ServerPlugin.handleAnalysisSetPriorityFiles
289+
// From ServerPlugin.handleAnalysisSetPriorityFiles.
291290
final filesByDriver = <AnalysisDriverGeneric, List<String>>{};
292291
for (final file in filesToFullyResolve) {
293292
final contextRoot = contextRootContaining(file);

lib/src/analyzers/lint_analyzer/anti_patterns/anti_patterns_list/long_method.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ import '../pattern_utils.dart';
2222
class LongMethod extends Pattern {
2323
static const String patternId = 'long-method';
2424

25-
final int? _sourceLinesOfCodeMetricTreshold;
25+
final int? _sourceLinesOfCodeMetricThreshold;
2626

2727
@override
2828
Iterable<String> get dependentMetricIds => [SourceLinesOfCodeMetric.metricId];
2929

3030
LongMethod({
3131
Map<String, Object> patternSettings = const {},
32-
Map<String, Object> metricstTresholds = const {},
33-
}) : _sourceLinesOfCodeMetricTreshold = readNullableThreshold<int>(
34-
metricstTresholds,
32+
Map<String, Object> metricsThresholds = const {},
33+
}) : _sourceLinesOfCodeMetricThreshold = readNullableThreshold<int>(
34+
metricsThresholds,
3535
SourceLinesOfCodeMetric.metricId,
3636
),
3737
super(
@@ -50,12 +50,13 @@ class LongMethod extends Pattern {
5050
functionMetrics.entries
5151
.where((entry) => !_isExcluded(entry.key))
5252
.expand((entry) => [
53-
if (_sourceLinesOfCodeMetricTreshold != null)
53+
if (_sourceLinesOfCodeMetricThreshold != null)
5454
...entry.value.metrics
5555
.where((metricValue) =>
5656
metricValue.metricsId ==
5757
SourceLinesOfCodeMetric.metricId &&
58-
metricValue.value > _sourceLinesOfCodeMetricTreshold!)
58+
metricValue.value >
59+
_sourceLinesOfCodeMetricThreshold!)
5960
.map(
6061
(metricValue) => createIssue(
6162
pattern: this,
@@ -68,12 +69,12 @@ class LongMethod extends Pattern {
6869
functionType: entry.key.type,
6970
),
7071
verboseMessage: _compileRecommendationMessage(
71-
maximumLines: _sourceLinesOfCodeMetricTreshold,
72+
maximumLines: _sourceLinesOfCodeMetricThreshold,
7273
functionType: entry.key.type,
7374
),
7475
),
7576
),
76-
if (_sourceLinesOfCodeMetricTreshold == null)
77+
if (_sourceLinesOfCodeMetricThreshold == null)
7778
// ignore: deprecated_member_use_from_same_package
7879
..._legacyBehaviour(source, entry),
7980
])

lib/src/analyzers/lint_analyzer/anti_patterns/anti_patterns_list/long_parameter_list.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ import '../pattern_utils.dart';
1919
class LongParameterList extends Pattern {
2020
static const String patternId = 'long-parameter-list';
2121

22-
final int? _numberOfParametersMetricTreshold;
22+
final int? _numberOfParametersMetricThreshold;
2323

2424
@override
2525
Iterable<String> get dependentMetricIds =>
2626
[NumberOfParametersMetric.metricId];
2727

2828
LongParameterList({
2929
Map<String, Object> patternSettings = const {},
30-
Map<String, Object> metricstTresholds = const {},
31-
}) : _numberOfParametersMetricTreshold = readNullableThreshold<int>(
32-
metricstTresholds,
30+
Map<String, Object> metricsThresholds = const {},
31+
}) : _numberOfParametersMetricThreshold = readNullableThreshold<int>(
32+
metricsThresholds,
3333
NumberOfParametersMetric.metricId,
3434
),
3535
super(
@@ -47,13 +47,13 @@ class LongParameterList extends Pattern {
4747
) =>
4848
functionMetrics.entries
4949
.expand((entry) => [
50-
if (_numberOfParametersMetricTreshold != null)
50+
if (_numberOfParametersMetricThreshold != null)
5151
...entry.value.metrics
5252
.where((metricValue) =>
5353
metricValue.metricsId ==
5454
NumberOfParametersMetric.metricId &&
5555
metricValue.value >
56-
_numberOfParametersMetricTreshold!)
56+
_numberOfParametersMetricThreshold!)
5757
.map(
5858
(metricValue) => createIssue(
5959
pattern: this,
@@ -66,12 +66,13 @@ class LongParameterList extends Pattern {
6666
functionType: entry.key.type,
6767
),
6868
verboseMessage: _compileRecommendationMessage(
69-
maximumArguments: _numberOfParametersMetricTreshold,
69+
maximumArguments:
70+
_numberOfParametersMetricThreshold,
7071
functionType: entry.key.type,
7172
),
7273
),
7374
),
74-
if (_numberOfParametersMetricTreshold == null)
75+
if (_numberOfParametersMetricThreshold == null)
7576
// ignore: deprecated_member_use_from_same_package
7677
..._legacyBehaviour(source, entry),
7778
])

lib/src/analyzers/lint_analyzer/anti_patterns/patterns_factory.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import 'models/pattern.dart';
55

66
typedef CreatePattern = Pattern Function(
77
Map<String, Object> patternSettings,
8-
Map<String, Object> metricstTresholds,
8+
Map<String, Object> metricsThresholds,
99
);
1010

1111
final _implementedPatterns = <String, CreatePattern>{
12-
LongMethod.patternId: (settings, tresholds) =>
13-
LongMethod(patternSettings: settings, metricstTresholds: tresholds),
14-
LongParameterList.patternId: (settings, tresholds) => LongParameterList(
12+
LongMethod.patternId: (settings, thresholds) =>
13+
LongMethod(patternSettings: settings, metricsThresholds: thresholds),
14+
LongParameterList.patternId: (settings, thresholds) => LongParameterList(
1515
patternSettings: settings,
16-
metricstTresholds: tresholds,
16+
metricsThresholds: thresholds,
1717
),
1818
};
1919

lib/src/analyzers/lint_analyzer/metrics/metric_utils.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ T? readConfigValue<T extends Object>(
4242
return null;
4343
}
4444

45-
/// Returns calculated [MetricValueLevel] based on the [value] to [warningLevel] ratio
45+
/// Returns calculated [MetricValueLevel] based on the [value] to [warningLevel] ratio.
4646
MetricValueLevel valueLevel(num? value, num? warningLevel) {
4747
if (value == null || warningLevel == null) {
4848
return MetricValueLevel.none;
@@ -59,7 +59,7 @@ MetricValueLevel valueLevel(num? value, num? warningLevel) {
5959
return MetricValueLevel.none;
6060
}
6161

62-
/// Returns calculated [MetricValueLevel] based on the [value] to [warningLevel] inverted ratio
62+
/// Returns calculated [MetricValueLevel] based on the [value] to [warningLevel] inverted ratio.
6363
MetricValueLevel invertValueLevel(num? value, num? warningLevel) {
6464
if (value == null || warningLevel == null) {
6565
return MetricValueLevel.none;
@@ -76,7 +76,7 @@ MetricValueLevel invertValueLevel(num? value, num? warningLevel) {
7676
return MetricValueLevel.none;
7777
}
7878

79-
/// Determines if the [level] warns about need to be a report about a metric value
79+
/// Determines if the [level] warns about need to be a report about a metric value.
8080
bool isReportLevel(MetricValueLevel level) =>
8181
level == MetricValueLevel.warning || level == MetricValueLevel.alarm;
8282

lib/src/analyzers/lint_analyzer/metrics/metrics_factory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final _implementedMetrics = <String, Metric Function(Map<String, Object>)>{
3030
// Depend on CyclomaticComplexityMetric, HalsteadVolumeMetric and SourceLinesOfCodeMetric metrics
3131
MaintainabilityIndexMetric.metricId: (config) =>
3232
MaintainabilityIndexMetric(config: config),
33-
// Depend on all metrics
33+
// Depend on all metrics.
3434
TechnicalDebtMetric.metricId: (config) => TechnicalDebtMetric(config: config),
3535
};
3636

lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_ast_visitor.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ class HalsteadVolumeAstVisitor extends RecursiveAstVisitor<void> {
99
final _operators = <String, int>{};
1010
final _operands = <String, int>{};
1111

12-
/// the number of operators
12+
/// The number of operators.
1313
int get operators => _operators.values.sum;
1414

15-
/// the number of unique operators
15+
/// The number of unique operators.
1616
int get uniqueOperators => _operators.keys.length;
1717

18-
/// the number of operands
18+
/// The number of operands.
1919
int get operands => _operands.values.sum;
2020

21-
/// the number of unique operands
21+
/// The number of unique operands.
2222
int get uniqueOperands => _operands.keys.length;
2323

2424
@override

0 commit comments

Comments
 (0)