diff --git a/.vscode/settings.json b/.vscode/settings.json index 1b1fad04cf..da087975ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,6 +27,7 @@ "setstate", "SLOC", "todos", - "unawaited" + "unawaited", + "writeln" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f6af6df2f..b661f48de4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,11 @@ ## Unreleased * feat: add static code diagnostics `avoid-border-all`. -* chore: activate new lint rules. * feat: improve `avoid-returning-widgets` builder functions handling. * fix: correctly handle const maps in `no-magic-number`. * fix: correctly handle excluded files for `check-unused-code`. +* chore: activate new lint rules. +* refactor: prepare for complex metric values. ## 4.11.0-dev.1 diff --git a/lib/src/analyzers/lint_analyzer/lint_analyzer.dart b/lib/src/analyzers/lint_analyzer/lint_analyzer.dart index f81e590692..0383b3e906 100644 --- a/lib/src/analyzers/lint_analyzer/lint_analyzer.dart +++ b/lib/src/analyzers/lint_analyzer/lint_analyzer.dart @@ -296,7 +296,7 @@ class LintAnalyzer { final classRecords = {}; for (final classDeclaration in visitor.classes) { - final metrics = >[]; + final metrics = []; for (final metric in config.classesMetrics) { if (metric.supports( @@ -336,7 +336,7 @@ class LintAnalyzer { InternalResolvedUnitResult source, LintAnalysisConfig config, ) { - final metrics = >[]; + final metrics = []; for (final metric in config.fileMetrics) { if (metric.supports( @@ -371,7 +371,7 @@ class LintAnalyzer { final functionRecords = {}; for (final function in visitor.functions) { - final metrics = >[]; + final metrics = []; for (final metric in config.methodsMetrics) { if (metric.supports( diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric.dart index 3f6ae72cae..7a305d23d5 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric.dart @@ -20,7 +20,7 @@ const _documentation = MetricDocumentation( name: 'Cyclomatic Complexity', shortName: 'CYCLO', measuredType: EntityType.methodEntity, - recomendedThreshold: 20, + recommendedThreshold: 20, ); /// Cyclomatic Complexity (CYCLO) @@ -45,7 +45,7 @@ class CyclomaticComplexityMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final visitor = CyclomaticComplexityFlowVisitor(); node.visitChildren(visitor); diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_metric.dart index bc529598d8..9026bd3b9e 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_metric.dart @@ -17,7 +17,7 @@ const _documentation = MetricDocumentation( name: 'Halstead Volume', shortName: 'HALVOL', measuredType: EntityType.methodEntity, - recomendedThreshold: 150, + recommendedThreshold: 150, ); /// Halstead Volume (HALVOL) @@ -45,7 +45,7 @@ class HalsteadVolumeMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final visitor = HalsteadVolumeAstVisitor(); node.visitChildren(visitor); diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/lines_of_code_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/lines_of_code_metric.dart index 53cb539c4c..6bd9f38dbe 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/lines_of_code_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/lines_of_code_metric.dart @@ -14,7 +14,7 @@ const _documentation = MetricDocumentation( name: 'Lines of Code', shortName: 'LOC', measuredType: EntityType.methodEntity, - recomendedThreshold: 100, + recommendedThreshold: 100, ); /// Lines of Code (LOC) @@ -39,7 +39,7 @@ class LinesOfCodeMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) => MetricComputationResult( value: 1 + diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maintainability_index_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maintainability_index_metric.dart index 033586b4e4..3f53cae495 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maintainability_index_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maintainability_index_metric.dart @@ -19,7 +19,7 @@ const _documentation = MetricDocumentation( name: 'Maintainability Index', shortName: 'MI', measuredType: EntityType.methodEntity, - recomendedThreshold: 50, + recommendedThreshold: 50, ); /// Maintainability Index (MI) @@ -43,7 +43,7 @@ class MaintainabilityIndexMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) => super.supports( node, @@ -65,7 +65,7 @@ class MaintainabilityIndexMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final halVol = otherMetricsValues.firstWhere( (value) => value.metricsId == HalsteadVolumeMetric.metricId, diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maximum_nesting_level/maximum_nesting_level_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maximum_nesting_level/maximum_nesting_level_metric.dart index f1e6957f1d..9f99c3c7f4 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maximum_nesting_level/maximum_nesting_level_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/maximum_nesting_level/maximum_nesting_level_metric.dart @@ -18,7 +18,7 @@ const _documentation = MetricDocumentation( name: 'Maximum Nesting Level', shortName: 'MAXNESTING', measuredType: EntityType.methodEntity, - recomendedThreshold: 5, + recommendedThreshold: 5, ); /// Maximum Nesting Level (MAXNESTING) @@ -44,7 +44,7 @@ class MaximumNestingLevelMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final visitor = NestingLevelVisitor(node); node.visitChildren(visitor); diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_methods_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_methods_metric.dart index 67c5cac8d2..f3e08cf26a 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_methods_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_methods_metric.dart @@ -17,7 +17,7 @@ const _documentation = MetricDocumentation( name: 'Number of Methods', shortName: 'NOM', measuredType: EntityType.classEntity, - recomendedThreshold: 10, + recommendedThreshold: 10, ); /// Number of Methods (NOM) @@ -41,7 +41,7 @@ class NumberOfMethodsMetric extends ClassMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final methods = classMethods(node, functionDeclarations); diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_parameters_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_parameters_metric.dart index bdea0f8426..b9e7736055 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_parameters_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_parameters_metric.dart @@ -15,7 +15,7 @@ const _documentation = MetricDocumentation( name: 'Number of Parameters', shortName: 'NOP', measuredType: EntityType.methodEntity, - recomendedThreshold: 4, + recommendedThreshold: 4, ); /// Number of Parameters (NOP) @@ -39,7 +39,7 @@ class NumberOfParametersMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { if (node is FunctionDeclaration) { return true; @@ -64,7 +64,7 @@ class NumberOfParametersMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { int? parametersCount; diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric.dart index 718bfa5675..ebd6d4ca8e 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric.dart @@ -17,7 +17,7 @@ const _documentation = MetricDocumentation( name: 'Source lines of Code', shortName: 'SLOC', measuredType: EntityType.methodEntity, - recomendedThreshold: 50, + recommendedThreshold: 50, ); /// Source lines of Code (SLOC) @@ -44,7 +44,7 @@ class SourceLinesOfCodeMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final visitor = SourceCodeVisitor(source.lineInfo); node.visitChildren(visitor); diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/technical_debt/technical_debt_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/technical_debt/technical_debt_metric.dart index 45e9025657..1635064b99 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/technical_debt/technical_debt_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/technical_debt/technical_debt_metric.dart @@ -22,7 +22,7 @@ const _documentation = MetricDocumentation( name: 'Technical Debt', shortName: 'TECHDEBT', measuredType: EntityType.fileEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ); /// Technical Debt (TECHDEBT) @@ -77,7 +77,7 @@ class TechnicalDebtMetric extends FileMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { var debt = 0.0; diff --git a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/weight_of_class_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/weight_of_class_metric.dart index 36c574e831..91446396d9 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/metrics_list/weight_of_class_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/metrics_list/weight_of_class_metric.dart @@ -18,7 +18,7 @@ const _documentation = MetricDocumentation( name: 'Weight Of a Class', shortName: 'WOC', measuredType: EntityType.classEntity, - recomendedThreshold: 0.33, + recommendedThreshold: 0.33, ); /// Weight Of a Class (WOC) @@ -42,7 +42,7 @@ class WeightOfClassMetric extends ClassMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) => super.supports( node, @@ -61,7 +61,7 @@ class WeightOfClassMetric extends ClassMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final totalPublicMethods = classMethods(node, functionDeclarations) .where(_isPublicMethod) diff --git a/lib/src/analyzers/lint_analyzer/metrics/models/file_metric.dart b/lib/src/analyzers/lint_analyzer/metrics/models/file_metric.dart index 32f3889cfa..891a293522 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/models/file_metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/models/file_metric.dart @@ -29,7 +29,7 @@ abstract class FileMetric extends Metric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) => node is CompilationUnit; diff --git a/lib/src/analyzers/lint_analyzer/metrics/models/metric.dart b/lib/src/analyzers/lint_analyzer/metrics/models/metric.dart index 1722d6b44f..52c41d3425 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/models/metric.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/models/metric.dart @@ -39,7 +39,7 @@ abstract class Metric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) => true; @@ -49,7 +49,7 @@ abstract class Metric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final result = computeImplementation( node, @@ -80,7 +80,7 @@ abstract class Metric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ); /// Returns the message for the user containing information about the computed value. diff --git a/lib/src/analyzers/lint_analyzer/metrics/models/metric_documentation.dart b/lib/src/analyzers/lint_analyzer/metrics/models/metric_documentation.dart index c38143f836..9ba36c2819 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/models/metric_documentation.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/models/metric_documentation.dart @@ -11,8 +11,8 @@ class MetricDocumentation { /// The type of entities which will be measured by the metric. final EntityType measuredType; - /// The recomended threshold value for this metric - final num recomendedThreshold; + /// The recommended threshold value for this metric + final num recommendedThreshold; /// Initialize a newly created [MetricDocumentation]. /// @@ -21,6 +21,6 @@ class MetricDocumentation { required this.name, required this.shortName, required this.measuredType, - required this.recomendedThreshold, + required this.recommendedThreshold, }); } diff --git a/lib/src/analyzers/lint_analyzer/metrics/models/metric_value.dart b/lib/src/analyzers/lint_analyzer/metrics/models/metric_value.dart index 42bf535dae..944d31d008 100644 --- a/lib/src/analyzers/lint_analyzer/metrics/models/metric_value.dart +++ b/lib/src/analyzers/lint_analyzer/metrics/models/metric_value.dart @@ -3,7 +3,7 @@ import 'metric_documentation.dart'; import 'metric_value_level.dart'; /// Represents a value computed by the metric. -class MetricValue { +class MetricValue { /// The id of the computed metric. final String metricsId; diff --git a/lib/src/analyzers/lint_analyzer/models/report.dart b/lib/src/analyzers/lint_analyzer/models/report.dart index cb5d9dba2c..b92517bc6b 100644 --- a/lib/src/analyzers/lint_analyzer/models/report.dart +++ b/lib/src/analyzers/lint_analyzer/models/report.dart @@ -14,10 +14,10 @@ class Report { final AstNode declaration; /// Target entity metrics. - final Iterable> metrics; + final Iterable metrics; /// Returns a certain target metric. - MetricValue? metric(String id) => + MetricValue? metric(String id) => metrics.firstWhereOrNull((metric) => metric.metricsId == id); /// The highest reported level of a metric. diff --git a/lib/src/analyzers/lint_analyzer/models/summary_lint_report_record.dart b/lib/src/analyzers/lint_analyzer/models/summary_lint_report_record.dart index 4b54e79f1e..3e8949f28e 100644 --- a/lib/src/analyzers/lint_analyzer/models/summary_lint_report_record.dart +++ b/lib/src/analyzers/lint_analyzer/models/summary_lint_report_record.dart @@ -1,7 +1,7 @@ import 'summary_lint_report_record_status.dart'; /// Represents a summary for a lint report. -class SummaryLintReportRecord { +class SummaryLintReportRecord { final SummaryLintReportRecordStatus status; final String title; diff --git a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter.dart b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter.dart index 5c5b0f9987..db18c74055 100644 --- a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter.dart +++ b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter.dart @@ -85,6 +85,6 @@ class LintConsoleReporter extends ConsoleReporter metric) => + bool _isNeedToReport(MetricValue metric) => metric.level > MetricValueLevel.none; } diff --git a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter_helper.dart b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter_helper.dart index 2233b29d4c..d8b2b737c5 100644 --- a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter_helper.dart +++ b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/console/lint_console_reporter_helper.dart @@ -6,7 +6,7 @@ import '../../../models/issue.dart'; import '../../../models/severity.dart'; final _alarmPen = AnsiPen()..rgb(r: 0.88, g: 0.32, b: 0.36); -final _warnigPen = AnsiPen()..rgb(r: 0.98, g: 0.68, b: 0.4); +final _warningPen = AnsiPen()..rgb(r: 0.98, g: 0.68, b: 0.4); final _bluePen = AnsiPen()..rgb(r: 0.08, g: 0.11, b: 0.81); final _whitePen = AnsiPen()..white(); @@ -16,14 +16,14 @@ final _linkPen = AnsiPen()..rgb(r: 0.0, g: 0.78, b: 1.0); class LintConsoleReporterHelper { static final _colorPens = { MetricValueLevel.alarm: _alarmPen, - MetricValueLevel.warning: _warnigPen, + MetricValueLevel.warning: _warningPen, MetricValueLevel.noted: _bluePen, MetricValueLevel.none: _whitePen, }; final _severityPens = { Severity.error: _alarmPen, - Severity.warning: _warnigPen, + Severity.warning: _warningPen, Severity.performance: _bluePen, Severity.style: _bluePen, Severity.none: _whitePen, @@ -75,7 +75,7 @@ class LintConsoleReporterHelper { } /// Converts a [metric] to the metric message string. - String getMetricReport(MetricValue metric) { + String getMetricReport(MetricValue metric) { final color = _colorPens[metric.level]; if (color != null) { diff --git a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip.dart b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip.dart index 80bee00547..82d1eebfa6 100644 --- a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip.dart +++ b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/html/components/report_details_tooltip.dart @@ -23,7 +23,7 @@ Element renderDetailsTooltip(Report entityReport, String entityType) { return tooltip; } -Element renderDetailsTooltipMetric(MetricValue metric) { +Element renderDetailsTooltipMetric(MetricValue metric) { final metricName = metric.documentation.name.toLowerCase(); final violationLevel = metric.level.toString(); diff --git a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/json/lint_json_reporter.dart b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/json/lint_json_reporter.dart index db5c02e25c..1fb205f161 100644 --- a/lib/src/analyzers/lint_analyzer/reporters/reporters_list/json/lint_json_reporter.dart +++ b/lib/src/analyzers/lint_analyzer/reporters/reporters_list/json/lint_json_reporter.dart @@ -93,7 +93,7 @@ class LintJsonReporter extends JsonReporter> _metricValuesToJson( - Iterable> metrics, + Iterable metrics, ) => metrics.map((metric) { final unitType = metric.unitType; diff --git a/lib/src/analyzers/lint_analyzer/reporters/utility_selector.dart b/lib/src/analyzers/lint_analyzer/reporters/utility_selector.dart index 8a2d64945e..fbc3f65ecd 100644 --- a/lib/src/analyzers/lint_analyzer/reporters/utility_selector.dart +++ b/lib/src/analyzers/lint_analyzer/reporters/utility_selector.dart @@ -124,7 +124,7 @@ class UtilitySelector { ); } -MetricValue _buildMetricValueStub({ +MetricValue _buildMetricValueStub({ required String id, required T value, EntityType type = EntityType.methodEntity, @@ -136,7 +136,7 @@ MetricValue _buildMetricValueStub({ name: id, shortName: id.toUpperCase(), measuredType: type, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: value, level: level, diff --git a/lib/src/analyzers/lint_analyzer/utils/report_utils.dart b/lib/src/analyzers/lint_analyzer/utils/report_utils.dart index f1358f889e..d36ec165e0 100644 --- a/lib/src/analyzers/lint_analyzer/utils/report_utils.dart +++ b/lib/src/analyzers/lint_analyzer/utils/report_utils.dart @@ -17,7 +17,7 @@ MetricValueLevel maxMetricViolationLevel(Iterable records) => ) .max; -bool hasIssueWithSevetiry( +bool hasIssueWithSeverity( Iterable records, Severity severity, ) => diff --git a/lib/src/cli/commands/analyze_command.dart b/lib/src/cli/commands/analyze_command.dart index 29a2fd36a8..c69906fe60 100644 --- a/lib/src/cli/commands/analyze_command.dart +++ b/lib/src/cli/commands/analyze_command.dart @@ -68,10 +68,10 @@ class AnalyzeCommand extends BaseCommand { additionalParams: LintReportParams(congratulate: !noCongratulate), ); - if (hasIssueWithSevetiry(lintAnalyserResult, Severity.error)) { + if (hasIssueWithSeverity(lintAnalyserResult, Severity.error)) { exit(3); } else if ((argResults[FlagNames.fatalWarnings] as bool) && - hasIssueWithSevetiry(lintAnalyserResult, Severity.warning)) { + hasIssueWithSeverity(lintAnalyserResult, Severity.warning)) { exit(2); } @@ -85,9 +85,9 @@ class AnalyzeCommand extends BaseCommand { } if (((argResults[FlagNames.fatalPerformance] as bool) && - hasIssueWithSevetiry(lintAnalyserResult, Severity.performance)) || + hasIssueWithSeverity(lintAnalyserResult, Severity.performance)) || ((argResults[FlagNames.fatalStyle] as bool) && - hasIssueWithSevetiry(lintAnalyserResult, Severity.style))) { + hasIssueWithSeverity(lintAnalyserResult, Severity.style))) { exit(1); } } @@ -140,7 +140,7 @@ class AnalyzeCommand extends BaseCommand { argParser.addOption( metric.id, help: '${metric.documentation.name} threshold$deprecationMessage.', - valueHelp: '${metric.documentation.recomendedThreshold}', + valueHelp: '${metric.documentation.recommendedThreshold}', callback: (i) { if (i != null && int.tryParse(i) == null) { print( diff --git a/lib/src/config_builder/config_builder.dart b/lib/src/config_builder/config_builder.dart index 4ad0638642..1596cb16bc 100644 --- a/lib/src/config_builder/config_builder.dart +++ b/lib/src/config_builder/config_builder.dart @@ -29,9 +29,9 @@ class ConfigBuilder { static LintAnalysisConfig getLintAnalysisConfig( LintConfig config, String excludesRootFolder, { - Iterable>? classMetrics, - Iterable>? fileMetrics, - Iterable>? functionMetrics, + Iterable? classMetrics, + Iterable? fileMetrics, + Iterable? functionMetrics, }) { final patterns = getPatternsById(config); final patternsDependencies = patterns diff --git a/test/resources/maintability_index_metric_example.dart b/test/resources/maintability_index_metric_example.dart index 84aafa99c5..c4d4793e9d 100644 --- a/test/resources/maintability_index_metric_example.dart +++ b/test/resources/maintability_index_metric_example.dart @@ -18,7 +18,7 @@ class MaintainabilityIndexMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final halVol = otherMetricsValues.firstWhere( (value) => value.metricsId == HalsteadVolumeMetric.metricId, diff --git a/test/resources/number_of_parameters_metric_example.dart b/test/resources/number_of_parameters_metric_example.dart index 9e77abd677..8ddbac5237 100644 --- a/test/resources/number_of_parameters_metric_example.dart +++ b/test/resources/number_of_parameters_metric_example.dart @@ -33,7 +33,7 @@ class NumberOfParametersMetric extends FunctionMetric { Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { int? parametersCount; if (node is FunctionDeclaration) { diff --git a/test/src/analyzers/lint_analyzer/reporters/reporters_list/report_example.dart b/test/src/analyzers/lint_analyzer/reporters/reporters_list/report_example.dart index d8206685d3..df302225a7 100644 --- a/test/src/analyzers/lint_analyzer/reporters/reporters_list/report_example.dart +++ b/test/src/analyzers/lint_analyzer/reporters/reporters_list/report_example.dart @@ -31,7 +31,7 @@ final _file1Report = Report( name: 'metric1', shortName: 'MTR1', measuredType: EntityType.fileEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 100, unitType: 'units', @@ -51,7 +51,7 @@ final _class1Report = Report( name: 'metric1', shortName: 'MTR1', measuredType: EntityType.classEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 0, level: MetricValueLevel.none, @@ -71,7 +71,7 @@ final _function1Report = Report( name: 'metric2', shortName: 'MTR2', measuredType: EntityType.methodEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 10, level: MetricValueLevel.alarm, @@ -91,7 +91,7 @@ final _function2Report = Report( name: 'metric3', shortName: 'MTR3', measuredType: EntityType.methodEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 1, level: MetricValueLevel.none, @@ -117,7 +117,7 @@ final _function3Report = Report( name: 'metric4', shortName: 'MTR4', measuredType: EntityType.methodEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 5, unitType: 'units', diff --git a/test/src/analyzers/lint_analyzer/reporters/utility_selector_test.dart b/test/src/analyzers/lint_analyzer/reporters/utility_selector_test.dart index 79cafd52ff..da68091cac 100644 --- a/test/src/analyzers/lint_analyzer/reporters/utility_selector_test.dart +++ b/test/src/analyzers/lint_analyzer/reporters/utility_selector_test.dart @@ -27,7 +27,7 @@ void main() { name: '', shortName: '', measuredType: EntityType.classEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 0, level: MetricValueLevel.none, @@ -41,7 +41,7 @@ void main() { name: '', shortName: '', measuredType: EntityType.classEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 15, level: MetricValueLevel.warning, @@ -55,7 +55,7 @@ void main() { name: '', shortName: '', measuredType: EntityType.classEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 25, level: MetricValueLevel.alarm, diff --git a/test/src/analyzers/lint_analyzer/utils/report_utils_test.dart b/test/src/analyzers/lint_analyzer/utils/report_utils_test.dart index 24a6734639..87480eaec6 100644 --- a/test/src/analyzers/lint_analyzer/utils/report_utils_test.dart +++ b/test/src/analyzers/lint_analyzer/utils/report_utils_test.dart @@ -125,16 +125,16 @@ void main() { }); test( - 'hasIssueWithSevetiry returns true if found issue with required severity', + 'hasIssueWithSeverity returns true if found issue with required severity', () { - expect(hasIssueWithSevetiry(fileRecords, Severity.error), isTrue); - expect(hasIssueWithSevetiry(fileRecords, Severity.warning), isFalse); + expect(hasIssueWithSeverity(fileRecords, Severity.error), isTrue); + expect(hasIssueWithSeverity(fileRecords, Severity.warning), isFalse); expect( - hasIssueWithSevetiry(fileRecords, Severity.performance), + hasIssueWithSeverity(fileRecords, Severity.performance), isFalse, ); - expect(hasIssueWithSevetiry(fileRecords, Severity.style), isTrue); - expect(hasIssueWithSevetiry(fileRecords, Severity.none), isFalse); + expect(hasIssueWithSeverity(fileRecords, Severity.style), isTrue); + expect(hasIssueWithSeverity(fileRecords, Severity.none), isFalse); }, ); diff --git a/test/stubs_builders.dart b/test/stubs_builders.dart index c7c8bec51e..a7afcb8914 100644 --- a/test/stubs_builders.dart +++ b/test/stubs_builders.dart @@ -15,7 +15,7 @@ import 'package:source_span/source_span.dart'; class _DeclarationMock extends Mock implements Declaration {} -MetricValue buildMetricValueStub({ +MetricValue buildMetricValueStub({ required String id, required T value, String? unitType, @@ -28,7 +28,7 @@ MetricValue buildMetricValueStub({ name: id, shortName: id.toUpperCase(), measuredType: type, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: value, unitType: unitType, @@ -38,7 +38,7 @@ MetricValue buildMetricValueStub({ Report buildReportStub({ SourceSpanBase? location, - Iterable> metrics = const [], + Iterable metrics = const [], }) { const defaultMetricValues = [ MetricValue( @@ -47,7 +47,7 @@ Report buildReportStub({ name: 'metric1', shortName: 'MTR1', measuredType: EntityType.classEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 0, level: MetricValueLevel.none, @@ -59,7 +59,7 @@ Report buildReportStub({ name: 'metric2', shortName: 'MTR2', measuredType: EntityType.methodEntity, - recomendedThreshold: 0, + recommendedThreshold: 0, ), value: 1, level: MetricValueLevel.none, @@ -77,7 +77,7 @@ Report buildReportStub({ Report buildFunctionRecordStub({ SourceSpanBase? location, - Iterable> metrics = const [], + Iterable metrics = const [], }) { final defaultMetricValues = [ buildMetricValueStub( diff --git a/website/docs/metrics/maintainability-index.md b/website/docs/metrics/maintainability-index.md index febd5587e5..a50c31c85f 100644 --- a/website/docs/metrics/maintainability-index.md +++ b/website/docs/metrics/maintainability-index.md @@ -33,7 +33,7 @@ MetricComputationResult computeImplementation( Iterable classDeclarations, Iterable functionDeclarations, InternalResolvedUnitResult source, - Iterable> otherMetricsValues, + Iterable otherMetricsValues, ) { final halVol = otherMetricsValues.firstWhere( (value) => value.metricsId == HalsteadVolumeMetric.metricId,