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

Commit

Permalink
chore: activate language strict rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrutskikh committed Dec 11, 2021
1 parent f1ad8e2 commit e6030f0
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* fix: fixed issue with type check in prefer-match-file-name
* doc: add flutter favorite badge
* chore: disable github_checks annotations from codecov
* chore: activate language strict rules

## 4.8.1

Expand Down
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ analyzer:
- test/resources/*
- test/resources/unused_files_analyzer/**
- test/**/examples/**
language:
strict-inference: true
strict-raw-types: true
plugins:
- dart_code_metrics
strong-mode:
Expand Down
5 changes: 3 additions & 2 deletions lib/src/analyzers/lint_analyzer/lint_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:path/path.dart';

import '../../config_builder/config_builder.dart';
import '../../config_builder/models/analysis_options.dart';
import '../../reporters/models/file_report.dart';
import '../../reporters/models/reporter.dart';
import '../../utils/analyzer_utils.dart';
import '../../utils/exclude_utils.dart';
Expand Down Expand Up @@ -33,7 +34,7 @@ class LintAnalyzer {

/// Returns a reporter for the given [name]. Use the reporter
/// to convert analysis reports to console, JSON or other supported format.
Reporter? getReporter({
Reporter<FileReport, Object>? getReporter({
required String name,
required IOSink output,
required String reportFolder,
Expand Down Expand Up @@ -125,7 +126,7 @@ class LintAnalyzer {
return analyzerResult;
}

Iterable<SummaryLintReportRecord> getSummary(
Iterable<SummaryLintReportRecord<Object>> getSummary(
Iterable<LintFileReport> records,
) =>
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MaintainabilityIndexMetric extends FunctionMetric<int> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue> otherMetricsValues,
Iterable<MetricValue<Object>> otherMetricsValues,
) =>
super.supports(
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NumberOfParametersMetric extends FunctionMetric<int> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue> otherMetricsValues,
Iterable<MetricValue<Object>> otherMetricsValues,
) {
if (node is FunctionDeclaration) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class WeightOfClassMetric extends ClassMetric<double> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue> otherMetricsValues,
Iterable<MetricValue<Object>> otherMetricsValues,
) =>
super.supports(
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class FileMetric<T extends num> extends Metric<T> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue> otherMetricsValues,
Iterable<MetricValue<Object>> otherMetricsValues,
) =>
node is CompilationUnit;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/analyzers/lint_analyzer/metrics/models/metric.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Metric<T extends num> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue> otherMetricsValues,
Iterable<MetricValue<Object>> otherMetricsValues,
) =>
true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import '../../../reporters/models/code_climate_reporter.dart';
import '../../../reporters/models/console_reporter.dart';
import '../../../reporters/models/file_report.dart';
import '../../../reporters/models/github_reporter.dart';
import '../../../reporters/models/html_reporter.dart';
import '../../../reporters/models/json_reporter.dart';
Expand All @@ -12,8 +13,8 @@ import 'reporters_list/github/lint_github_reporter.dart';
import 'reporters_list/html/lint_html_reporter.dart';
import 'reporters_list/json/lint_json_reporter.dart';

final _implementedReports =
<String, Reporter Function(IOSink output, String reportFolder)>{
final _implementedReports = <String,
Reporter<FileReport, Object> Function(IOSink output, String reportFolder)>{
ConsoleReporter.id: (output, _) => LintConsoleReporter(output),
ConsoleReporter.verboseId: (output, _) =>
LintConsoleReporter(output, reportAll: true),
Expand All @@ -25,7 +26,7 @@ final _implementedReports =
LintCodeClimateReporter(output, gitlabCompatible: true),
};

Reporter? reporter({
Reporter<FileReport, Object>? reporter({
required String name,
required IOSink output,
required String reportFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import 'models/code_climate_issue_severity.dart';
/// Lint Code Climate reporter.
///
/// Use it to create reports in Code Climate format.
class LintCodeClimateReporter
extends CodeClimateReporter<LintFileReport, SummaryLintReportRecord> {
class LintCodeClimateReporter extends CodeClimateReporter<LintFileReport,
SummaryLintReportRecord<Object>> {
LintCodeClimateReporter(IOSink output, {bool gitlabCompatible = false})
: super(
output,
Expand All @@ -29,7 +29,7 @@ class LintCodeClimateReporter
@override
Future<void> report(
Iterable<LintFileReport> records, {
Iterable<SummaryLintReportRecord> summary = const [],
Iterable<SummaryLintReportRecord<Object>> summary = const [],
}) async {
if (records.isEmpty) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'lint_console_reporter_helper.dart';
///
/// Use it to create reports in console format.
class LintConsoleReporter
extends ConsoleReporter<LintFileReport, SummaryLintReportRecord> {
extends ConsoleReporter<LintFileReport, SummaryLintReportRecord<Object>> {
/// If true will report info about all files even if they're not above warning threshold
final bool reportAll;

Expand All @@ -25,7 +25,7 @@ class LintConsoleReporter
@override
Future<void> report(
Iterable<LintFileReport> records, {
Iterable<SummaryLintReportRecord> summary = const [],
Iterable<SummaryLintReportRecord<Object>> summary = const [],
}) async {
if (records.isEmpty) {
return;
Expand Down Expand Up @@ -74,6 +74,6 @@ class LintConsoleReporter
return [];
}

bool _isNeedToReport(MetricValue metric) =>
bool _isNeedToReport(MetricValue<Object> metric) =>
metric.level > MetricValueLevel.none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const _deprecationMessage =
/// **Note:** this reporter is deprecated and should not be used.
/// Consider using Dart Code Metrics GitHub Action instead.
class LintGitHubReporter
extends GitHubReporter<LintFileReport, SummaryLintReportRecord> {
extends GitHubReporter<LintFileReport, SummaryLintReportRecord<Object>> {
const LintGitHubReporter(IOSink output) : super(output);

@override
Future<void> report(
Iterable<LintFileReport> records, {
Iterable<SummaryLintReportRecord> summary = const [],
Iterable<SummaryLintReportRecord<Object>> summary = const [],
}) async {
if (records.isEmpty) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ const _designIssues = 'Design issues';
///
/// Use it to create reports in HTML format.
class LintHtmlReporter
extends HtmlReporter<LintFileReport, SummaryLintReportRecord> {
extends HtmlReporter<LintFileReport, SummaryLintReportRecord<Object>> {
LintHtmlReporter(String reportFolder) : super(reportFolder);

@override
Future<void> report(
Iterable<LintFileReport> records, {
Iterable<SummaryLintReportRecord> summary = const [],
Iterable<SummaryLintReportRecord<Object>> summary = const [],
}) async {
await super.report(records);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import '../../../models/summary_lint_report_record.dart';
/// Use it to create reports in JSON format.
@immutable
class LintJsonReporter
extends JsonReporter<LintFileReport, SummaryLintReportRecord> {
extends JsonReporter<LintFileReport, SummaryLintReportRecord<Object>> {
const LintJsonReporter(IOSink output) : super(output, 2);

@override
Future<void> report(
Iterable<LintFileReport> records, {
Iterable<SummaryLintReportRecord> summary = const [],
Iterable<SummaryLintReportRecord<Object>> summary = const [],
}) async {
if (records.isEmpty) {
return;
Expand All @@ -35,11 +35,7 @@ class LintJsonReporter
'timestamp': getTimestamp(),
'records': records.map(_lintFileReportToJson).toList(),
if (summary.isNotEmpty)
'summary': summary
.map((record) => _summaryLintReportRecordToJson(
record as SummaryLintReportRecord<Object>,
))
.toList(),
'summary': summary.map(_summaryLintReportRecordToJson).toList(),
});

output.write(encodedReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import 'dart:io';
import '../../../reporters/models/console_reporter.dart';
import '../../../reporters/models/json_reporter.dart';
import '../../../reporters/models/reporter.dart';
import '../models/unused_files_file_report.dart';
import 'reporters_list/console/unused_files_console_reporter.dart';
import 'reporters_list/json/unused_files_json_reporter.dart';

final _implementedReports = <String, Reporter Function(IOSink output)>{
final _implementedReports =
<String, Reporter<UnusedFilesFileReport, void> Function(IOSink output)>{
ConsoleReporter.id: (output) => UnusedFilesConsoleReporter(output),
JsonReporter.id: (output) => UnusedFilesJsonReporter(output),
};

Reporter? reporter({
Reporter<UnusedFilesFileReport, void>? reporter({
required String name,
required IOSink output,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UnusedFilesAnalyzer {

/// Returns a reporter for the given [name]. Use the reporter
/// to convert analysis reports to console, JSON or other supported format.
Reporter? getReporter({
Reporter<UnusedFilesFileReport, void>? getReporter({
required String name,
required IOSink output,
}) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import 'dart:io';
import '../../../reporters/models/console_reporter.dart';
import '../../../reporters/models/json_reporter.dart';
import '../../../reporters/models/reporter.dart';
import '../models/unused_l10n_file_report.dart';
import 'reporters_list/console/unused_l10n_console_reporter.dart';
import 'reporters_list/json/unused_l10n_json_reporter.dart';

// ignore: avoid_private_typedef_functions
typedef _ReportersFactory = Reporter Function(IOSink output);

final _implementedReports = <String, _ReportersFactory>{
final _implementedReports =
<String, Reporter<UnusedL10nFileReport, void> Function(IOSink output)>{
ConsoleReporter.id: (output) => UnusedL10nConsoleReporter(output),
JsonReporter.id: (output) => UnusedL10nJsonReporter(output),
};

Reporter? reporter({
Reporter<UnusedL10nFileReport, void>? reporter({
required String name,
required IOSink output,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class UnusedL10nAnalyzer {

/// Returns a reporter for the given [name]. Use the reporter
/// to convert analysis reports to console, JSON or other supported format.
Reporter? getReporter({
Reporter<UnusedL10nFileReport, void>? getReporter({
required String name,
required IOSink output,
}) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/commands/analyze_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AnalyzeCommand extends BaseCommand {

@override
String get invocation =>
'${runner.executableName} $name [arguments] <directories>';
'${runner?.executableName} $name [arguments] <directories>';

AnalyzeCommand() {
_addFlags();
Expand Down
3 changes: 0 additions & 3 deletions lib/src/cli/commands/base_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ abstract class BaseCommand extends Command<void> {
return super.argResults!;
}

@override
CommandRunner get runner => super.runner as CommandRunner;

@override
Future<void> run() => _verifyThenRunCommand();

Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/commands/check_unused_files_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CheckUnusedFilesCommand extends BaseCommand {

@override
String get invocation =>
'${runner.executableName} $name [arguments] <directories>';
'${runner?.executableName} $name [arguments] <directories>';

CheckUnusedFilesCommand() {
_addFlags();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/commands/check_unused_l10n_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CheckUnusedL10nCommand extends BaseCommand {

@override
String get invocation =>
'${runner.executableName} $name [arguments] <directories>';
'${runner?.executableName} $name [arguments] <directories>';

CheckUnusedL10nCommand() {
_addFlags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ final Iterable<LintFileReport> testReport = [
),
];

const Iterable<SummaryLintReportRecord> testSummary = [
const Iterable<SummaryLintReportRecord<Object>> testSummary = [
SummaryLintReportRecord<Iterable<String>>(
status: SummaryLintReportRecordStatus.none,
title: 'Scanned package folders',
Expand Down

0 comments on commit e6030f0

Please sign in to comment.