From 4caad01ba728d0b194a4c8e1cd0a3a569dd6f584 Mon Sep 17 00:00:00 2001 From: vladimir-beloded Date: Thu, 9 Nov 2023 18:57:31 +0200 Subject: [PATCH] Rename custom lints to use snake_case --- example/analysis_options.yaml | 4 +- ...avoid_unnecessary_type_assertions_fix.dart | 2 +- ...void_unnecessary_type_assertions_rule.dart | 4 +- .../avoid_unnecessary_type_casts_fix.dart | 2 +- .../avoid_unnecessary_type_casts_rule.dart | 4 +- .../avoid_unrelated_type_assertions_rule.dart | 4 +- .../avoid_unused_parameters_rule.dart | 4 +- .../double_literal_format_fix.dart | 2 +- .../double_literal_format_rule.dart | 4 +- lib/lints/member_ordering/config_parser.dart | 58 ++++++++--------- .../member_ordering/member_ordering_rule.dart | 4 +- .../models/member_ordering_parameters.dart | 2 +- .../newline_before_return_rule.dart | 4 +- .../no_empty_block/no_empty_block_rule.dart | 4 +- .../no_equal_then_else_rule.dart | 4 +- .../no_magic_number/no_magic_number_rule.dart | 4 +- ...er_conditional_expressions_parameters.dart | 2 +- .../prefer_conditional_expressions_fix.dart | 2 +- .../prefer_conditional_expressions_rule.dart | 4 +- lib/lints/prefer_first/prefer_first_fix.dart | 2 +- lib/lints/prefer_first/prefer_first_rule.dart | 4 +- lib/lints/prefer_last/prefer_last_fix.dart | 2 +- lib/lints/prefer_last/prefer_last_rule.dart | 4 +- .../prefer_match_file_name_rule.dart | 4 +- lib/utils/typecast_utils.dart | 6 +- .../alphabetize_by_type_test.dart | 6 +- .../analysis_options.yaml | 2 +- lint_test/analysis_options.yaml | 64 +++++++++---------- lint_test/avoid_global_state_test.dart | 2 +- lint_test/avoid_late_keyword_test.dart | 2 +- lint_test/avoid_non_null_assertion_test.dart | 4 +- lint_test/avoid_returning_widget_test.dart | 4 +- .../avoid_unnecessary_setstate_test.dart | 2 +- ...void_unnecessary_type_assertions_test.dart | 14 ++-- .../avoid_unnecessary_type_casts_test.dart | 10 +-- .../avoid_unrelated_type_assertions_test.dart | 14 ++-- lint_test/avoid_unused_parameters_test.dart | 28 ++++---- lint_test/cyclomatic_complexity_test.dart | 2 +- lint_test/double_literal_format_test.dart | 16 ++--- lint_test/lines_of_code_test.dart | 2 +- lint_test/member_ordering_test.dart | 62 +++++++++--------- lint_test/newline_before_return_test.dart | 16 ++--- lint_test/no_empty_block_test.dart | 16 ++--- lint_test/no_equal_then_else_test.dart | 10 +-- lint_test/no_magic_number_test.dart | 8 +-- .../analysis_options.yaml | 4 +- ...tional_expressions_ignore_nested_test.dart | 6 +- .../prefer_conditional_expressions_test.dart | 16 ++--- lint_test/prefer_first_test.dart | 12 ++-- lint_test/prefer_last_test.dart | 12 ++-- .../prefer_match_file_name_enum_test.dart | 4 +- ...prefer_match_file_name_extension_test.dart | 4 +- .../prefer_match_file_name_mixin_test.dart | 4 +- lint_test/prefer_match_file_name_test.dart | 2 +- .../prefer_match_file_name_wrong_test.dart | 4 +- 55 files changed, 246 insertions(+), 246 deletions(-) diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index ccddb430..6ba2969f 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -17,5 +17,5 @@ custom_lint: - avoid_global_state - avoid_returning_widgets - avoid_unnecessary_setstate - - double-literal-format - - avoid-unnecessary-type-assertions + - double_literal_format + - avoid_unnecessary_type_assertions diff --git a/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_fix.dart b/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_fix.dart index 501351a8..884003df 100644 --- a/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_fix.dart +++ b/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_fix.dart @@ -1,6 +1,6 @@ part of 'avoid_unnecessary_type_assertions_rule.dart'; -/// A Quick fix for `avoid-unnecessary-type-assertions` rule +/// A Quick fix for `avoid_unnecessary_type_assertions` rule /// Suggests to remove unnecessary assertions class _UnnecessaryTypeAssertionsFix extends DartFix { @override diff --git a/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_rule.dart b/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_rule.dart index 84745b4a..01e29339 100644 --- a/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_rule.dart +++ b/lib/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_rule.dart @@ -17,12 +17,12 @@ const operatorIsName = 'is'; /// The name of 'whereType' method const whereTypeMethodName = 'whereType'; -/// A `avoid-unnecessary-type-assertions` rule which +/// An `avoid_unnecessary_type_assertions` rule which /// warns about unnecessary usage of `is` and `whereType` operators class AvoidUnnecessaryTypeAssertions extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const lintName = 'avoid-unnecessary-type-assertions'; + static const lintName = 'avoid_unnecessary_type_assertions'; static const _unnecessaryIsCode = LintCode( name: lintName, diff --git a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_fix.dart b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_fix.dart index 4c8c578c..47435f50 100644 --- a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_fix.dart +++ b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_fix.dart @@ -1,6 +1,6 @@ part of 'avoid_unnecessary_type_casts_rule.dart'; -/// A Quick fix for `avoid-unnecessary-type-assertions` rule +/// A Quick fix for `avoid_unnecessary_type_casts` rule /// Suggests to remove unnecessary assertions class _UnnecessaryTypeCastsFix extends DartFix { @override diff --git a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart index e6ccbeeb..5845e87e 100644 --- a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart +++ b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart @@ -9,12 +9,12 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; part 'avoid_unnecessary_type_casts_fix.dart'; -/// A `avoid-unnecessary-type-casts` rule which +/// An `avoid_unnecessary_type_casts` rule which /// warns about unnecessary usage of `as` operator class AvoidUnnecessaryTypeCastsRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const lintName = 'avoid-unnecessary-type-casts'; + static const lintName = 'avoid_unnecessary_type_casts'; AvoidUnnecessaryTypeCastsRule._(super.config); diff --git a/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart b/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart index 117cc49f..09d17505 100644 --- a/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart +++ b/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart @@ -4,12 +4,12 @@ import 'package:solid_lints/lints/avoid_unrelated_type_assertions/avoid_unrelate import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `avoid-unrelated-type-assertions` rule which +/// A `avoid_unrelated_type_assertions` rule which /// warns about unnecessary usage of `as` operator class AvoidUnrelatedTypeAssertionsRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const lintName = 'avoid-unrelated-type-assertions'; + static const lintName = 'avoid_unrelated_type_assertions'; AvoidUnrelatedTypeAssertionsRule._(super.config); diff --git a/lib/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart b/lib/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart index 5c608b28..c2338411 100644 --- a/lib/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart +++ b/lib/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart @@ -4,12 +4,12 @@ import 'package:solid_lints/lints/avoid_unused_parameters/avoid_unused_parameter import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `avoid-unused-parameters` rule which +/// A `avoid_unused_parameters` rule which /// warns about unused parameters class AvoidUnusedParametersRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const String lintName = 'avoid-unused-parameters'; + static const String lintName = 'avoid_unused_parameters'; AvoidUnusedParametersRule._(super.config); diff --git a/lib/lints/double_literal_format/double_literal_format_fix.dart b/lib/lints/double_literal_format/double_literal_format_fix.dart index a83de45f..23c3043a 100644 --- a/lib/lints/double_literal_format/double_literal_format_fix.dart +++ b/lib/lints/double_literal_format/double_literal_format_fix.dart @@ -1,6 +1,6 @@ part of 'double_literal_format_rule.dart'; -/// A Quick fix for `double-literal-format` rule +/// A Quick fix for `double_literal_format` rule /// Suggests the correct value for an issue class _DoubleLiteralFormatFix extends DartFix { @override diff --git a/lib/lints/double_literal_format/double_literal_format_rule.dart b/lib/lints/double_literal_format/double_literal_format_rule.dart index 63b021f1..5d1fea06 100644 --- a/lib/lints/double_literal_format/double_literal_format_rule.dart +++ b/lib/lints/double_literal_format/double_literal_format_rule.dart @@ -8,7 +8,7 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; part 'double_literal_format_fix.dart'; part 'double_literal_format_utils.dart'; -/// A `double-literal-format` rule which +/// A `double_literal_format` rule which /// checks that double literals should begin with 0. instead of just ., /// and should not end with a trailing 0. /// BAD: @@ -18,7 +18,7 @@ part 'double_literal_format_utils.dart'; class DoubleLiteralFormatRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const lintName = 'double-literal-format'; + static const lintName = 'double_literal_format'; // Use different messages for different issues /// The [LintCode] of this lint rule that represents diff --git a/lib/lints/member_ordering/config_parser.dart b/lib/lints/member_ordering/config_parser.dart index 9e42421f..e543abab 100644 --- a/lib/lints/member_ordering/config_parser.dart +++ b/lib/lints/member_ordering/config_parser.dart @@ -32,37 +32,37 @@ import 'package:solid_lints/lints/member_ordering/models/member_group/method_mem import 'package:solid_lints/lints/member_ordering/models/member_type.dart'; import 'package:solid_lints/lints/member_ordering/models/modifier.dart'; -/// Helper class to parse member-ordering rule config +/// Helper class to parse member_ordering rule config class MemberOrderingConfigParser { static const _defaultOrderList = [ - 'public-fields', - 'private-fields', - 'public-getters', - 'private-getters', - 'public-setters', - 'private-setters', + 'public_fields', + 'private_fields', + 'public_getters', + 'private_getters', + 'public_setters', + 'private_setters', 'constructors', - 'public-methods', - 'private-methods', + 'public_methods', + 'private_methods', ]; static const _defaultWidgetsOrderList = [ 'constructor', - 'named-constructor', - 'const-fields', - 'static-methods', - 'final-fields', - 'init-state-method', - 'var-fields', - 'init-state-method', - 'private-methods', - 'overridden-public-methods', - 'build-method', + 'named_constructor', + 'const_fields', + 'static_methods', + 'final_fields', + 'init_state_method', + 'var_fields', + 'init_state_method', + 'private_methods', + 'overridden_public_methods', + 'build_method', ]; static final _regExp = RegExp( - '(overridden-|protected-)?(private-|public-)?(static-)?(late-)?' - '(var-|final-|const-)?(nullable-)?(named-)?(factory-)?', + '(overridden_|protected_)?(private_|public_)?(static_)?(late_)?' + '(var_|final_|const_)?(nullable_)?(named_)?(factory_)?', ); /// Parse rule config for regular class order rules @@ -84,15 +84,15 @@ class MemberOrderingConfigParser { } static MemberGroup? _parseGroup(String group) { - final lastGroup = group.endsWith('getters-setters') - ? 'getters-setters' - : group.split('-').lastOrNull; + final lastGroup = group.endsWith('getters_setters') + ? 'getters_setters' + : group.split('_').lastOrNull; final type = MemberType.parse(lastGroup); final result = _regExp.allMatches(group.toLowerCase()); - final isNamedMethod = group.endsWith('-method'); + final isNamedMethod = group.endsWith('_method'); if (isNamedMethod) { - final name = group.split('-method').first.replaceAll('-', ''); + final name = group.split('_method').first.replaceAll('_', ''); return MethodMemberGroup.named( name: name, @@ -105,11 +105,11 @@ class MemberOrderingConfigParser { if (hasGroups && type != null) { final match = result.first; - final annotation = Annotation.parse(match.group(1)?.replaceAll('-', '')); - final modifier = Modifier.parse(match.group(2)?.replaceAll('-', '')); + final annotation = Annotation.parse(match.group(1)?.replaceAll('_', '')); + final modifier = Modifier.parse(match.group(2)?.replaceAll('_', '')); final isStatic = match.group(3) != null; final isLate = match.group(4) != null; - final keyword = FieldKeyword.parse(match.group(5)?.replaceAll('-', '')); + final keyword = FieldKeyword.parse(match.group(5)?.replaceAll('_', '')); final isNullable = match.group(6) != null; final isNamed = match.group(7) != null; final isFactory = match.group(8) != null; diff --git a/lib/lints/member_ordering/member_ordering_rule.dart b/lib/lints/member_ordering/member_ordering_rule.dart index c922d8a5..d341587f 100644 --- a/lib/lints/member_ordering/member_ordering_rule.dart +++ b/lib/lints/member_ordering/member_ordering_rule.dart @@ -5,13 +5,13 @@ import 'package:solid_lints/lints/member_ordering/models/member_ordering_paramet import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `member-ordering` rule which +/// A `member_ordering` rule which /// warns about class members being in wrong order /// Custom order can be provided through config class MemberOrderingRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether we use bad formatted double literals. - static const lintName = 'member-ordering'; + static const lintName = 'member_ordering'; static const _warningMessage = 'should be before'; static const _warningAlphabeticalMessage = 'should be alphabetically before'; diff --git a/lib/lints/member_ordering/models/member_ordering_parameters.dart b/lib/lints/member_ordering/models/member_ordering_parameters.dart index 44b36bb4..60937d1c 100644 --- a/lib/lints/member_ordering/models/member_ordering_parameters.dart +++ b/lib/lints/member_ordering/models/member_ordering_parameters.dart @@ -29,7 +29,7 @@ import 'package:solid_lints/lints/member_ordering/models/member_group/member_gro class MemberOrderingParameters { /// Config keys static const _orderConfig = 'order'; - static const _widgetsOrderConfig = 'widgets-order'; + static const _widgetsOrderConfig = 'widgets_order'; static const _alphabetizeConfig = 'alphabetize'; static const _alphabetizeByTypeConfig = 'alphabetize-by-type'; diff --git a/lib/lints/newline_before_return/newline_before_return_rule.dart b/lib/lints/newline_before_return/newline_before_return_rule.dart index f97ba0ac..9e8a19ab 100644 --- a/lib/lints/newline_before_return/newline_before_return_rule.dart +++ b/lib/lints/newline_before_return/newline_before_return_rule.dart @@ -29,12 +29,12 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; // Inspired by ESLint (https://eslint.org/docs/rules/newline-before-return) -/// A `newline-before-return` rule which +/// A `newline_before_return` rule which /// warns about missing newline before return class NewlineBeforeReturnRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if /// newline is missing before return statement - static const String lintName = 'newline-before-return'; + static const String lintName = 'newline_before_return'; NewlineBeforeReturnRule._(super.config); diff --git a/lib/lints/no_empty_block/no_empty_block_rule.dart b/lib/lints/no_empty_block/no_empty_block_rule.dart index 89153e24..3524a087 100644 --- a/lib/lints/no_empty_block/no_empty_block_rule.dart +++ b/lib/lints/no_empty_block/no_empty_block_rule.dart @@ -6,12 +6,12 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; // Inspired by TSLint (https://palantir.github.io/tslint/rules/no-empty/) -/// A `no-empty-block` rule which forbids having empty blocks. +/// A `no_empty_block` rule which forbids having empty blocks. /// Excluding catch blocks and to-do comments class NoEmptyBlockRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error whether left empty block. - static const String lintName = 'no-empty-block'; + static const String lintName = 'no_empty_block'; NoEmptyBlockRule._(super.config); diff --git a/lib/lints/no_equal_then_else/no_equal_then_else_rule.dart b/lib/lints/no_equal_then_else/no_equal_then_else_rule.dart index 067ed50f..34a7f4c2 100644 --- a/lib/lints/no_equal_then_else/no_equal_then_else_rule.dart +++ b/lib/lints/no_equal_then_else/no_equal_then_else_rule.dart @@ -6,12 +6,12 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; // Inspired by PVS-Studio (https://www.viva64.com/en/w/v6004/) -/// A `no-equal-then-else` rule which warns about +/// A `no_equal_then_else` rule which warns about /// unnecessary if statements and conditional expressions class NoEqualThenElseRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if /// 'if' statements or conditional expression is redundant - static const String lintName = 'no-equal-then-else'; + static const String lintName = 'no_equal_then_else'; NoEqualThenElseRule._(super.config); diff --git a/lib/lints/no_magic_number/no_magic_number_rule.dart b/lib/lints/no_magic_number/no_magic_number_rule.dart index 1fd64405..c9e1e201 100644 --- a/lib/lints/no_magic_number/no_magic_number_rule.dart +++ b/lib/lints/no_magic_number/no_magic_number_rule.dart @@ -29,11 +29,11 @@ import 'package:solid_lints/lints/no_magic_number/no_magic_number_visitor.dart'; import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `no-magic-number` rule which forbids having numbers without variable +/// A `no_magic_number` rule which forbids having numbers without variable class NoMagicNumberRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents /// the error when having magic number. - static const String lintName = 'no-magic-number'; + static const String lintName = 'no_magic_number'; NoMagicNumberRule._(super.config); diff --git a/lib/lints/prefer_conditional_expressions/models/prefer_conditional_expressions_parameters.dart b/lib/lints/prefer_conditional_expressions/models/prefer_conditional_expressions_parameters.dart index 3b4f50c7..54d7768e 100644 --- a/lib/lints/prefer_conditional_expressions/models/prefer_conditional_expressions_parameters.dart +++ b/lib/lints/prefer_conditional_expressions/models/prefer_conditional_expressions_parameters.dart @@ -1,7 +1,7 @@ /// A data model class that represents the "prefer conditional expressions" /// input parameters. class PreferConditionalExpressionsParameters { - static const _ignoreNestedConfig = 'ignore-nested'; + static const _ignoreNestedConfig = 'ignore_nested'; /// Should rule ignore nested if statements final bool ignoreNested; diff --git a/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_fix.dart b/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_fix.dart index 98373bc5..49bbfad0 100644 --- a/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_fix.dart +++ b/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_fix.dart @@ -5,7 +5,7 @@ import 'package:analyzer/source/source_range.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:solid_lints/lints/prefer_conditional_expressions/prefer_conditional_expressions_visitor.dart'; -/// A Quick fix for `avoid-unnecessary-type-assertions` rule +/// A Quick fix for `prefer_conditional_expressions` rule /// Suggests to remove unnecessary assertions class PreferConditionalExpressionsFix extends DartFix { @override diff --git a/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_rule.dart b/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_rule.dart index 3d06698f..eb36a7c4 100644 --- a/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_rule.dart +++ b/lib/lints/prefer_conditional_expressions/prefer_conditional_expressions_rule.dart @@ -8,13 +8,13 @@ import 'package:solid_lints/models/solid_lint_rule.dart'; // Inspired by TSLint (https://palantir.github.io/tslint/rules/prefer-conditional-expression/) -/// A `prefer-conditional-expressions` rule which warns about +/// A `prefer_conditional_expressions` rule which warns about /// simple if statements that can be replaced with conditional expressions class PreferConditionalExpressionsRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if number of /// parameters reaches the maximum value. - static const lintName = 'prefer-conditional-expressions'; + static const lintName = 'prefer_conditional_expressions'; PreferConditionalExpressionsRule._(super.config); diff --git a/lib/lints/prefer_first/prefer_first_fix.dart b/lib/lints/prefer_first/prefer_first_fix.dart index c1557c97..e52ba9ce 100644 --- a/lib/lints/prefer_first/prefer_first_fix.dart +++ b/lib/lints/prefer_first/prefer_first_fix.dart @@ -3,7 +3,7 @@ import 'package:analyzer/error/error.dart'; import 'package:analyzer/source/source_range.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; -/// A Quick fix for `prefer-first` rule +/// A Quick fix for `prefer_first` rule /// Suggests to replace iterable access expressions class PreferFirstFix extends DartFix { static const _replaceComment = "Replace with 'first'."; diff --git a/lib/lints/prefer_first/prefer_first_rule.dart b/lib/lints/prefer_first/prefer_first_rule.dart index c9e33f26..fff405ff 100644 --- a/lib/lints/prefer_first/prefer_first_rule.dart +++ b/lib/lints/prefer_first/prefer_first_rule.dart @@ -5,12 +5,12 @@ import 'package:solid_lints/lints/prefer_first/prefer_first_visitor.dart'; import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `prefer-first` rule which warns about +/// A `prefer_first` rule which warns about /// usage of iterable[0] or iterable.elementAt(0) class PreferFirstRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if number of /// parameters reaches the maximum value. - static const lintName = 'prefer-first'; + static const lintName = 'prefer_first'; PreferFirstRule._(super.config); diff --git a/lib/lints/prefer_last/prefer_last_fix.dart b/lib/lints/prefer_last/prefer_last_fix.dart index 9e276350..88f236e8 100644 --- a/lib/lints/prefer_last/prefer_last_fix.dart +++ b/lib/lints/prefer_last/prefer_last_fix.dart @@ -3,7 +3,7 @@ import 'package:analyzer/error/error.dart'; import 'package:analyzer/source/source_range.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; -/// A Quick fix for `prefer-last` rule +/// A Quick fix for `prefer_last` rule /// Suggests to replace iterable access expressions class PreferLastFix extends DartFix { static const _replaceComment = "Replace with 'last'."; diff --git a/lib/lints/prefer_last/prefer_last_rule.dart b/lib/lints/prefer_last/prefer_last_rule.dart index f965144a..75254cb2 100644 --- a/lib/lints/prefer_last/prefer_last_rule.dart +++ b/lib/lints/prefer_last/prefer_last_rule.dart @@ -5,12 +5,12 @@ import 'package:solid_lints/lints/prefer_last/prefer_last_visitor.dart'; import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; -/// A `prefer-last` rule which warns about +/// A `prefer_last` rule which warns about /// usage of iterable[length-1] or iterable.elementAt(length-1) class PreferLastRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if iterable /// access can be simplified. - static const lintName = 'prefer-last'; + static const lintName = 'prefer_last'; PreferLastRule._(super.config); diff --git a/lib/lints/prefer_match_file_name/prefer_match_file_name_rule.dart b/lib/lints/prefer_match_file_name/prefer_match_file_name_rule.dart index 53a67961..80817b6e 100644 --- a/lib/lints/prefer_match_file_name/prefer_match_file_name_rule.dart +++ b/lib/lints/prefer_match_file_name/prefer_match_file_name_rule.dart @@ -6,12 +6,12 @@ import 'package:solid_lints/models/rule_config.dart'; import 'package:solid_lints/models/solid_lint_rule.dart'; import 'package:solid_lints/utils/node_utils.dart'; -/// A `prefer-match-file-name` rule which warns about +/// A `prefer_match_file_name` rule which warns about /// mismatch between file name and declared element inside class PreferMatchFileNameRule extends SolidLintRule { /// The [LintCode] of this lint rule that represents the error if iterable /// access can be simplified. - static const String lintName = 'prefer-match-file-name'; + static const String lintName = 'prefer_match_file_name'; static final _onlySymbolsRegex = RegExp('[^a-zA-Z0-9]'); PreferMatchFileNameRule._(super.config); diff --git a/lib/utils/typecast_utils.dart b/lib/utils/typecast_utils.dart index d425c8f1..be228d16 100644 --- a/lib/utils/typecast_utils.dart +++ b/lib/utils/typecast_utils.dart @@ -5,9 +5,9 @@ import 'package:collection/collection.dart'; // Useful types for testing expressions' types // TODO: consider to move here common functions for rules -// avoid-unnecessary-type-assertions -// avoid-unnecessary-type-casts (after implementation) -// avoid-unrelated-type-assertions (after implementation) +// avoid_unnecessary_type_assertions +// avoid_unnecessary_type_casts (after implementation) +// avoid_unrelated_type_assertions (after implementation) /// A class for representing arguments for types checking methods class TypeCast { diff --git a/lint_test/alphabetize_by_type_test/alphabetize_by_type_test.dart b/lint_test/alphabetize_by_type_test/alphabetize_by_type_test.dart index 5f8a8643..bd7522a7 100644 --- a/lint_test/alphabetize_by_type_test/alphabetize_by_type_test.dart +++ b/lint_test/alphabetize_by_type_test/alphabetize_by_type_test.dart @@ -1,7 +1,7 @@ // ignore_for_file: unused_field // ignore_for_file: unused_element -/// Check the `member-ordering` rule +/// Check the `member_ordering` rule /// alphabetical-by-type option enabled class CorrectAlphabeticalByTypeClass { @@ -12,7 +12,7 @@ class CorrectAlphabeticalByTypeClass { class WrongAlphabeticalByTypeClass { final int a = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering final double e = 1; } @@ -20,6 +20,6 @@ class PartiallyWrongAlphabeticalByTypeClass { final int a = 1; final String str = 's'; - // expect_lint: member-ordering + // expect_lint: member_ordering final double e = 1; } diff --git a/lint_test/alphabetize_by_type_test/analysis_options.yaml b/lint_test/alphabetize_by_type_test/analysis_options.yaml index b77c8f7a..c4d39159 100644 --- a/lint_test/alphabetize_by_type_test/analysis_options.yaml +++ b/lint_test/alphabetize_by_type_test/analysis_options.yaml @@ -4,5 +4,5 @@ analyzer: custom_lint: rules: - - member-ordering: + - member_ordering: alphabetize-by-type: true diff --git a/lint_test/analysis_options.yaml b/lint_test/analysis_options.yaml index 1082956e..d7f934e4 100644 --- a/lint_test/analysis_options.yaml +++ b/lint_test/analysis_options.yaml @@ -15,41 +15,41 @@ custom_lint: - avoid_global_state - avoid_returning_widgets - avoid_unnecessary_setstate - - double-literal-format - - avoid-unnecessary-type-assertions - - avoid-unnecessary-type-casts - - avoid-unrelated-type-assertions - - avoid-unused-parameters - - newline-before-return - - no-empty-block - - no-equal-then-else - - member-ordering: + - double_literal_format + - avoid_unnecessary_type_assertions + - avoid_unnecessary_type_casts + - avoid_unrelated_type_assertions + - avoid_unused_parameters + - newline_before_return + - no_empty_block + - no_equal_then_else + - member_ordering: alphabetize: true order: - - public-fields - - private-fields + - public_fields + - private_fields - constructors - getters - setters - - public-methods - - private-methods - - close-method - widgets-order: - - const-fields - - static-fields - - static-methods - - public-fields - - private-fields - - public-methods - - private-methods + - public_methods + - private_methods + - close_method + widgets_order: + - const_fields + - static_fields + - static_methods + - public_fields + - private_fields + - public_methods + - private_methods - constructors - - build-method - - init-state-method - - did-change-dependencies-method - - did-update-widget-method - - dispose-method - - no-magic-number - - prefer-conditional-expressions - - prefer-first - - prefer-last - - prefer-match-file-name + - build_method + - init_state_method + - did_change_dependencies_method + - did_update_widget_method + - dispose_method + - no_magic_number + - prefer_conditional_expressions + - prefer_first + - prefer_last + - prefer_match_file_name diff --git a/lint_test/avoid_global_state_test.dart b/lint_test/avoid_global_state_test.dart index b64e47cd..e790523e 100644 --- a/lint_test/avoid_global_state_test.dart +++ b/lint_test/avoid_global_state_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis, prefer-match-file-name +// ignore_for_file: type_annotate_public_apis, prefer_match_file_name /// Check global mutable variable fail /// `avoid_global_state` diff --git a/lint_test/avoid_late_keyword_test.dart b/lint_test/avoid_late_keyword_test.dart index ad9d67bf..105f1607 100644 --- a/lint_test/avoid_late_keyword_test.dart +++ b/lint_test/avoid_late_keyword_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations, unused_local_variable, prefer-match-file-name +// ignore_for_file: prefer_const_declarations, unused_local_variable, prefer_match_file_name // ignore_for_file: avoid_global_state /// Check "late" keyword fail diff --git a/lint_test/avoid_non_null_assertion_test.dart b/lint_test/avoid_non_null_assertion_test.dart index a07296bc..2a33a7df 100644 --- a/lint_test/avoid_non_null_assertion_test.dart +++ b/lint_test/avoid_non_null_assertion_test.dart @@ -1,5 +1,5 @@ -// ignore_for_file: avoid_global_state, prefer-match-file-name -// ignore_for_file: member-ordering +// ignore_for_file: avoid_global_state, prefer_match_file_name +// ignore_for_file: member_ordering /// Check "bang" operator fail /// diff --git a/lint_test/avoid_returning_widget_test.dart b/lint_test/avoid_returning_widget_test.dart index d4b53d9c..ed366e1a 100644 --- a/lint_test/avoid_returning_widget_test.dart +++ b/lint_test/avoid_returning_widget_test.dart @@ -1,5 +1,5 @@ -// ignore_for_file: unused_element, prefer-match-file-name -// ignore_for_file: member-ordering +// ignore_for_file: unused_element, prefer_match_file_name +// ignore_for_file: member_ordering /// Check returning a widget fail /// `avoid_returning_widgets` diff --git a/lint_test/avoid_unnecessary_setstate_test.dart b/lint_test/avoid_unnecessary_setstate_test.dart index f343257e..51b5e2be 100644 --- a/lint_test/avoid_unnecessary_setstate_test.dart +++ b/lint_test/avoid_unnecessary_setstate_test.dart @@ -21,7 +21,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -// ignore_for_file: member-ordering, prefer-match-file-name +// ignore_for_file: member_ordering, prefer_match_file_name import 'package:flutter/material.dart'; diff --git a/lint_test/avoid_unnecessary_type_assertions_test.dart b/lint_test/avoid_unnecessary_type_assertions_test.dart index bdcff8f1..c95e47f6 100644 --- a/lint_test/avoid_unnecessary_type_assertions_test.dart +++ b/lint_test/avoid_unnecessary_type_assertions_test.dart @@ -3,31 +3,31 @@ // ignore_for_file: unnecessary_type_check // ignore_for_file: unused_local_variable -/// Check the `avoid-unnecessary-type-assertions` rule +/// Check the `avoid_unnecessary_type_assertions` rule void fun() { final testList = [1.0, 2.0, 3.0]; - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions final result = testList is List; - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions final negativeResult = testList is! List; // to check quick-fix => testList.length - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions testList.whereType().length; final dynamicList = [1.0, 2.0]; dynamicList.whereType(); - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions [1.0, 2.0].whereType(); final double d = 2.0; - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions final casted = d is double; - // expect_lint: avoid-unnecessary-type-assertions + // expect_lint: avoid_unnecessary_type_assertions final negativeCasted = d is! double; final double? nullableD = 2.0; diff --git a/lint_test/avoid_unnecessary_type_casts_test.dart b/lint_test/avoid_unnecessary_type_casts_test.dart index 302353c1..dffa6903 100644 --- a/lint_test/avoid_unnecessary_type_casts_test.dart +++ b/lint_test/avoid_unnecessary_type_casts_test.dart @@ -3,13 +3,13 @@ // ignore_for_file: unnecessary_cast // ignore_for_file: unused_local_variable -/// Check the `avoid-unnecessary-type-casts` rule +/// Check the `avoid_unnecessary_type_casts` rule void fun() { final testList = [1.0, 2.0, 3.0]; // to check quick-fix => testList - // expect_lint: avoid-unnecessary-type-casts + // expect_lint: avoid_unnecessary_type_casts final result = testList as List; final double? nullableD = 2.0; @@ -18,18 +18,18 @@ void fun() { final testMap = {'A': 'B'}; - // expect_lint: avoid-unnecessary-type-casts + // expect_lint: avoid_unnecessary_type_casts final castedMapValue = testMap['A'] as String?; // casting `Type? is Type` is allowed final castedNotNullMapValue = testMap['A'] as String; final testString = 'String'; - // expect_lint: avoid-unnecessary-type-casts + // expect_lint: avoid_unnecessary_type_casts _testFun(testString as String); } void _testFun(String a) { - // expect_lint: avoid-unnecessary-type-casts + // expect_lint: avoid_unnecessary_type_casts final result = (a as String).length; } diff --git a/lint_test/avoid_unrelated_type_assertions_test.dart b/lint_test/avoid_unrelated_type_assertions_test.dart index 861dc8e3..eee0a09a 100644 --- a/lint_test/avoid_unrelated_type_assertions_test.dart +++ b/lint_test/avoid_unrelated_type_assertions_test.dart @@ -1,8 +1,8 @@ -// ignore_for_file: prefer_const_declarations, prefer-match-file-name +// ignore_for_file: prefer_const_declarations, prefer_match_file_name // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unused_local_variable -/// Check the `avoid-unrelated-type-assertions` rule +/// Check the `avoid_unrelated_type_assertions` rule class Foo {} class Bar {} @@ -16,18 +16,18 @@ void fun() { final Foo foo = Foo(); final childFoo = ChildFoo(); - // expect_lint: avoid-unrelated-type-assertions + // expect_lint: avoid_unrelated_type_assertions final result = testString is int; - // expect_lint: avoid-unrelated-type-assertions + // expect_lint: avoid_unrelated_type_assertions final result2 = testList is List; - // expect_lint: avoid-unrelated-type-assertions + // expect_lint: avoid_unrelated_type_assertions final result3 = foo is Bar; - // expect_lint: avoid-unrelated-type-assertions + // expect_lint: avoid_unrelated_type_assertions final result4 = childFoo is Bar; - // expect_lint: avoid-unrelated-type-assertions + // expect_lint: avoid_unrelated_type_assertions final result5 = testMap['A'] is double; } diff --git a/lint_test/avoid_unused_parameters_test.dart b/lint_test/avoid_unused_parameters_test.dart index 1a022fc9..e54d6499 100644 --- a/lint_test/avoid_unused_parameters_test.dart +++ b/lint_test/avoid_unused_parameters_test.dart @@ -1,25 +1,25 @@ -// ignore_for_file: prefer_const_declarations, prefer-match-file-name +// ignore_for_file: prefer_const_declarations, prefer_match_file_name // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unused_local_variable // ignore_for_file: unused_element -// ignore_for_file: newline-before-return -// ignore_for_file: no-empty-block -// ignore_for_file: member-ordering +// ignore_for_file: newline_before_return +// ignore_for_file: no_empty_block +// ignore_for_file: member_ordering import 'package:flutter/material.dart'; -/// Check the `avoid-unused-parameters` rule +/// Check the `avoid_unused_parameters` rule -// expect_lint: avoid-unused-parameters +// expect_lint: avoid_unused_parameters void fun(String s) { return; } class TestClass { - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters static void staticMethod(int a) {} - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters void method(String s) { return; } @@ -34,7 +34,7 @@ class TestClass2 { } class SomeOtherClass { - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters void method(String s) { return; } @@ -56,11 +56,11 @@ class SomeOtherAnotherClass { return; } - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters void anonymousCallback(Function(int a) cb) {} } -// expect_lint: avoid-unused-parameters +// expect_lint: avoid_unused_parameters void closure(int a) { void internal(int a) { print(a); @@ -82,12 +82,12 @@ class Foo { Foo.coolName({required this.a, required this.b}); - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters Foo.another({required int c}) : a = 1, b = 0; - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters factory Foo.aOnly(int a) { return Foo._(1, null); } @@ -100,7 +100,7 @@ class Bar extends Foo { class TestWidget extends StatelessWidget { const TestWidget({ super.key, - // expect_lint: avoid-unused-parameters + // expect_lint: avoid_unused_parameters int a = 1, }); diff --git a/lint_test/cyclomatic_complexity_test.dart b/lint_test/cyclomatic_complexity_test.dart index aad42041..52cf2bbf 100644 --- a/lint_test/cyclomatic_complexity_test.dart +++ b/lint_test/cyclomatic_complexity_test.dart @@ -1,5 +1,5 @@ // ignore_for_file: literal_only_boolean_expressions -// ignore_for_file: no-empty-block +// ignore_for_file: no_empty_block /// Check complexity fail /// diff --git a/lint_test/double_literal_format_test.dart b/lint_test/double_literal_format_test.dart index 35602507..195b01e8 100644 --- a/lint_test/double_literal_format_test.dart +++ b/lint_test/double_literal_format_test.dart @@ -2,37 +2,37 @@ // ignore_for_file: type_annotate_public_apis // ignore_for_file: unused_local_variable -/// Check the `double-literal-format` rule +/// Check the `double_literal_format` rule -// expect_lint: double-literal-format +// expect_lint: double_literal_format var badA = 05.23; var goodA = 5.23; var stringA = '05.23'; var intA = 0; -// expect_lint: double-literal-format +// expect_lint: double_literal_format double badB = -01.2; double goodB = -1.2; -// expect_lint: double-literal-format +// expect_lint: double_literal_format double badC = -001.2; -// expect_lint: double-literal-format +// expect_lint: double_literal_format double badExpr = 5.23 + 05.23; double goodExpr = 5.23 + 5.23; class DoubleLiteralFormatTest { - // expect_lint: double-literal-format + // expect_lint: double_literal_format var badA = .16e+5; var goodA = 0.16e+5; void someMethod() { - // expect_lint: double-literal-format + // expect_lint: double_literal_format const badA = -0.250; const goodA = -0.25; - // expect_lint: double-literal-format + // expect_lint: double_literal_format const badB = 0.160e+5; } } diff --git a/lint_test/lines_of_code_test.dart b/lint_test/lines_of_code_test.dart index b8d14eb9..200cbee9 100644 --- a/lint_test/lines_of_code_test.dart +++ b/lint_test/lines_of_code_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: no-magic-number +// ignore_for_file: no_magic_number import 'package:test/test.dart'; diff --git a/lint_test/member_ordering_test.dart b/lint_test/member_ordering_test.dart index f7060e93..f82b01be 100644 --- a/lint_test/member_ordering_test.dart +++ b/lint_test/member_ordering_test.dart @@ -1,28 +1,28 @@ -// ignore_for_file: unused_field, prefer-match-file-name +// ignore_for_file: unused_field, prefer_match_file_name // ignore_for_file: unused_element -// ignore_for_file: no-empty-block +// ignore_for_file: no_empty_block import 'package:flutter/widgets.dart'; -/// Check the `member-ordering` rule +/// Check the `member_ordering` rule class AlphabeticalClass { final b = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering final a = 1; final c = 1; void bStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void aStuff() {} void cStuff() {} void visitStatement() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void visitStanford() {} } @@ -48,27 +48,27 @@ class CorrectOrder { class WrongOrder { void close() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void _privateDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void publicDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void set privateFieldSetter(int value) { _privateField = value; } - // expect_lint: member-ordering + // expect_lint: member_ordering int get privateFieldGetter => _privateField; - // expect_lint: member-ordering + // expect_lint: member_ordering WrongOrder(); - // expect_lint: member-ordering + // expect_lint: member_ordering int _privateField = 2; - // expect_lint: member-ordering + // expect_lint: member_ordering final publicField = 1; } @@ -77,7 +77,7 @@ class PartiallyWrongOrder { PartiallyWrongOrder(); - // expect_lint: member-ordering + // expect_lint: member_ordering int _privateField = 2; int get privateFieldGetter => _privateField; @@ -88,7 +88,7 @@ class PartiallyWrongOrder { void _privateDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void publicDoStuff() {} void close() {} @@ -136,7 +136,7 @@ class _CorrectWidgetState extends State { class WrongWidget extends StatefulWidget { const WrongWidget({super.key}); - // expect_lint: member-ordering + // expect_lint: member_ordering @override State createState() => _WrongWidgetState(); } @@ -145,45 +145,45 @@ class _WrongWidgetState extends State { @override void dispose() => super.dispose(); - // expect_lint: member-ordering + // expect_lint: member_ordering @override void didUpdateWidget(covariant WrongWidget oldWidget) => super.didUpdateWidget(oldWidget); - // expect_lint: member-ordering + // expect_lint: member_ordering @override void didChangeDependencies() => super.didChangeDependencies(); - // expect_lint: member-ordering + // expect_lint: member_ordering @override void initState() => super.initState(); - // expect_lint: member-ordering + // expect_lint: member_ordering @override Widget build(BuildContext context) => throw UnimplementedError(); - // expect_lint: member-ordering + // expect_lint: member_ordering _WrongWidgetState(); - // expect_lint: member-ordering + // expect_lint: member_ordering void _privateDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering void publicDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering final _privateField = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering final publicField = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering static void staticDoStuff() {} - // expect_lint: member-ordering + // expect_lint: member_ordering static final staticField = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering static const constField = 1; } @@ -197,14 +197,14 @@ class PartiallyCorrectWidget extends StatefulWidget { class _PartiallyCorrectWidgetState extends State { static final staticField = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering static const constField = 1; static void staticDoStuff() {} final _privateField = 1; - // expect_lint: member-ordering + // expect_lint: member_ordering final publicField = 1; void publicDoStuff() {} @@ -219,7 +219,7 @@ class _PartiallyCorrectWidgetState extends State { @override void didChangeDependencies() => super.didChangeDependencies(); - // expect_lint: member-ordering + // expect_lint: member_ordering @override void initState() => super.initState(); diff --git a/lint_test/newline_before_return_test.dart b/lint_test/newline_before_return_test.dart index f25fcaed..282057ad 100644 --- a/lint_test/newline_before_return_test.dart +++ b/lint_test/newline_before_return_test.dart @@ -1,18 +1,18 @@ -// ignore_for_file: unused_local_variable, prefer-match-file-name -// ignore_for_file: member-ordering -// ignore_for_file: avoid-unused-parameters +// ignore_for_file: unused_local_variable, prefer_match_file_name +// ignore_for_file: member_ordering +// ignore_for_file: avoid_unused_parameters -/// Check the `newline-before-return` rule +/// Check the `newline_before_return` rule class Foo { int method() { final a = 0; - // expect_lint: newline-before-return + // expect_lint: newline_before_return return 1; } void anotherMethod() { final a = 1; - // expect_lint: newline-before-return + // expect_lint: newline_before_return return; } @@ -29,9 +29,9 @@ void fun() { }); foo.bar(() { final a = 1; - // expect_lint: newline-before-return + // expect_lint: newline_before_return return; }); - // expect_lint: newline-before-return + // expect_lint: newline_before_return return; } diff --git a/lint_test/no_empty_block_test.dart b/lint_test/no_empty_block_test.dart index 8e96769f..036e406f 100644 --- a/lint_test/no_empty_block_test.dart +++ b/lint_test/no_empty_block_test.dart @@ -1,17 +1,17 @@ -// ignore_for_file: prefer_const_declarations, prefer-match-file-name +// ignore_for_file: prefer_const_declarations, prefer_match_file_name // ignore_for_file: unused_local_variable // ignore_for_file: cyclomatic_complexity -// ignore_for_file: avoid-unused-parameters +// ignore_for_file: avoid_unused_parameters -/// Check the `no-empty-block` rule +/// Check the `no_empty_block` rule -// expect_lint: no-empty-block +// expect_lint: no_empty_block void fun() {} void anotherFun() { if (true) { if (true) { - // expect_lint: no-empty-block + // expect_lint: no_empty_block if (true) {} } } @@ -23,7 +23,7 @@ void toDoStuff() { } void catchStuff() { - // expect_lint: no-empty-block + // expect_lint: no_empty_block try {} catch (e) {} try { @@ -37,12 +37,12 @@ void nestedFun(void Function() fun) { } void doStuff() { - // expect_lint: no-empty-block + // expect_lint: no_empty_block nestedFun(() {}); } class A { - // expect_lint: no-empty-block + // expect_lint: no_empty_block void method() {} void toDoMethod() { diff --git a/lint_test/no_equal_then_else_test.dart b/lint_test/no_equal_then_else_test.dart index df35eeb4..c9caa40c 100644 --- a/lint_test/no_equal_then_else_test.dart +++ b/lint_test/no_equal_then_else_test.dart @@ -1,16 +1,16 @@ // ignore_for_file: unused_local_variable // ignore_for_file: cyclomatic_complexity -// ignore_for_file: no-magic-number -// ignore_for_file: prefer-conditional-expressions +// ignore_for_file: no_magic_number +// ignore_for_file: prefer_conditional_expressions -/// Check the `no-equal-then-else` rule +/// Check the `no_equal_then_else` rule void fun() { final _valueA = 1; final _valueB = 2; int _result = 0; - // expect_lint: no-equal-then-else + // expect_lint: no_equal_then_else if (_valueA == 1) { _result = _valueA; } else { @@ -23,7 +23,7 @@ void fun() { _result = _valueB; } - // expect_lint: no-equal-then-else + // expect_lint: no_equal_then_else _result = _valueA == 2 ? _valueA : _valueA; _result = _valueA == 2 ? _valueA : _valueB; diff --git a/lint_test/no_magic_number_test.dart b/lint_test/no_magic_number_test.dart index 4633019a..b215ec4b 100644 --- a/lint_test/no_magic_number_test.dart +++ b/lint_test/no_magic_number_test.dart @@ -1,18 +1,18 @@ -// ignore_for_file: unused_local_variable, prefer-match-file-name +// ignore_for_file: unused_local_variable, prefer_match_file_name -/// Check the `no-magic-number` rule +/// Check the `no_magic_number` rule const pi = 3.14; const radiusToDiameterCoefficient = 2; -// expect_lint: no-magic-number +// expect_lint: no_magic_number double circumference(double radius) => 2 * 3.14 * radius; double correctCircumference(double radius) => radiusToDiameterCoefficient * pi * radius; bool canDrive(int age, {bool isUSA = false}) { -// expect_lint: no-magic-number +// expect_lint: no_magic_number return isUSA ? age >= 16 : age > 18; } diff --git a/lint_test/prefer_conditional_expressions_ignore_nested_test/analysis_options.yaml b/lint_test/prefer_conditional_expressions_ignore_nested_test/analysis_options.yaml index 957617b9..750be4b4 100644 --- a/lint_test/prefer_conditional_expressions_ignore_nested_test/analysis_options.yaml +++ b/lint_test/prefer_conditional_expressions_ignore_nested_test/analysis_options.yaml @@ -4,5 +4,5 @@ analyzer: custom_lint: rules: - - prefer-conditional-expressions: - ignore-nested: true + - prefer_conditional_expressions: + ignore_nested: true diff --git a/lint_test/prefer_conditional_expressions_ignore_nested_test/prefer_conditional_expressions_ignore_nested_test.dart b/lint_test/prefer_conditional_expressions_ignore_nested_test/prefer_conditional_expressions_ignore_nested_test.dart index fddfa18a..954e77fa 100644 --- a/lint_test/prefer_conditional_expressions_ignore_nested_test/prefer_conditional_expressions_ignore_nested_test.dart +++ b/lint_test/prefer_conditional_expressions_ignore_nested_test/prefer_conditional_expressions_ignore_nested_test.dart @@ -1,12 +1,12 @@ // ignore_for_file: unused_local_variable // ignore_for_file: cyclomatic_complexity -// ignore_for_file: no-equal-then-else +// ignore_for_file: no_equal_then_else -/// Check the `prefer-conditional-expressions` rule ignore-nested option +/// Check the `prefer_conditional_expressions` rule ignore_nested option void fun() { int _result = 0; - // Allowed because ignore-nested flag is enabled + // Allowed because ignore_nested flag is enabled if (1 > 0) { _result = 1 > 2 ? 2 : 1; } else { diff --git a/lint_test/prefer_conditional_expressions_test.dart b/lint_test/prefer_conditional_expressions_test.dart index 8196ddc5..ee60f237 100644 --- a/lint_test/prefer_conditional_expressions_test.dart +++ b/lint_test/prefer_conditional_expressions_test.dart @@ -1,27 +1,27 @@ // ignore_for_file: unused_local_variable // ignore_for_file: cyclomatic_complexity -// ignore_for_file: no-equal-then-else +// ignore_for_file: no_equal_then_else // ignore_for_file: dead_code -// ignore_for_file: no-magic-number +// ignore_for_file: no_magic_number -/// Check the `prefer-conditional-expressions` rule +/// Check the `prefer_conditional_expressions` rule void fun() { int _result = 0; - // expect_lint: prefer-conditional-expressions + // expect_lint: prefer_conditional_expressions if (true) { _result = 1; } else { _result = 2; } - // expect_lint: prefer-conditional-expressions + // expect_lint: prefer_conditional_expressions if (1 > 0) _result = 1; else _result = 2; - // expect_lint: prefer-conditional-expressions + // expect_lint: prefer_conditional_expressions if (1 > 0) { _result = 1 > 2 ? 2 : 1; } else { @@ -30,7 +30,7 @@ void fun() { } int someFun() { - // expect_lint: prefer-conditional-expressions + // expect_lint: prefer_conditional_expressions if (1 == 1) { return 0; } else { @@ -39,7 +39,7 @@ int someFun() { } int anotherFun() { - // expect_lint: prefer-conditional-expressions + // expect_lint: prefer_conditional_expressions if (1 > 0) return 1; else diff --git a/lint_test/prefer_first_test.dart b/lint_test/prefer_first_test.dart index 49d6bf54..2527d828 100644 --- a/lint_test/prefer_first_test.dart +++ b/lint_test/prefer_first_test.dart @@ -1,21 +1,21 @@ -/// Check the `prefer-first` rule +/// Check the `prefer_first` rule void fun() { const zero = 0; final list = [0, 1, 2, 3]; final set = {0, 1, 2, 3}; final map = {0: 0, 1: 1, 2: 2, 3: 3}; - // expect_lint: prefer-first + // expect_lint: prefer_first list[0]; list[zero]; - // expect_lint: prefer-first + // expect_lint: prefer_first list.elementAt(0); list.elementAt(zero); - // expect_lint: prefer-first + // expect_lint: prefer_first set.elementAt(0); - // expect_lint: prefer-first + // expect_lint: prefer_first map.keys.elementAt(0); - // expect_lint: prefer-first + // expect_lint: prefer_first map.values.elementAt(0); } diff --git a/lint_test/prefer_last_test.dart b/lint_test/prefer_last_test.dart index 0007641d..4b87476f 100644 --- a/lint_test/prefer_last_test.dart +++ b/lint_test/prefer_last_test.dart @@ -1,25 +1,25 @@ -/// Check the `prefer-first` rule +/// Check the `prefer_first` rule void fun() { final list = [0, 1, 2, 3]; final length = list.length - 1; final set = {0, 1, 2, 3}; final map = {0: 0, 1: 1, 2: 2, 3: 3}; - // expect_lint: prefer-last + // expect_lint: prefer_last list[list.length - 1]; list[length - 1]; - // expect_lint: prefer-last + // expect_lint: prefer_last list.elementAt(list.length - 1); list.elementAt(length - 1); - // expect_lint: prefer-last + // expect_lint: prefer_last set.elementAt(set.length - 1); - // expect_lint: prefer-last + // expect_lint: prefer_last map.keys.elementAt(map.keys.length - 1); - // expect_lint: prefer-last + // expect_lint: prefer_last map.values.elementAt(map.values.length - 1); } diff --git a/lint_test/prefer_match_file_name_enum_test.dart b/lint_test/prefer_match_file_name_enum_test.dart index 2c89f120..91da9904 100644 --- a/lint_test/prefer_match_file_name_enum_test.dart +++ b/lint_test/prefer_match_file_name_enum_test.dart @@ -1,5 +1,5 @@ // ignore_for_file: unused_element, unused_field -/// Check the `prefer-match-file-name` rule -// expect_lint: prefer-match-file-name +/// Check the `prefer_match_file_name` rule +// expect_lint: prefer_match_file_name enum WrongMixin { a, b } diff --git a/lint_test/prefer_match_file_name_extension_test.dart b/lint_test/prefer_match_file_name_extension_test.dart index 123be14a..dd5ea1fc 100644 --- a/lint_test/prefer_match_file_name_extension_test.dart +++ b/lint_test/prefer_match_file_name_extension_test.dart @@ -1,5 +1,5 @@ // ignore_for_file: unused_element, unused_field -/// Check the `prefer-match-file-name` rule -// expect_lint: prefer-match-file-name +/// Check the `prefer_match_file_name` rule +// expect_lint: prefer_match_file_name extension WrongExtension on List {} diff --git a/lint_test/prefer_match_file_name_mixin_test.dart b/lint_test/prefer_match_file_name_mixin_test.dart index d9091495..5b8d2331 100644 --- a/lint_test/prefer_match_file_name_mixin_test.dart +++ b/lint_test/prefer_match_file_name_mixin_test.dart @@ -1,5 +1,5 @@ // ignore_for_file: unused_element, unused_field -/// Check the `prefer-match-file-name` rule -// expect_lint: prefer-match-file-name +/// Check the `prefer_match_file_name` rule +// expect_lint: prefer_match_file_name mixin WrongMixin {} diff --git a/lint_test/prefer_match_file_name_test.dart b/lint_test/prefer_match_file_name_test.dart index 6d607ffd..68466050 100644 --- a/lint_test/prefer_match_file_name_test.dart +++ b/lint_test/prefer_match_file_name_test.dart @@ -1,6 +1,6 @@ // ignore_for_file: unused_element, unused_field -/// Check the `prefer-match-file-name` rule +/// Check the `prefer_match_file_name` rule class _AnotherPrivateClass {} class PreferMatchFileNameTest {} diff --git a/lint_test/prefer_match_file_name_wrong_test.dart b/lint_test/prefer_match_file_name_wrong_test.dart index 150b5d8d..b0588354 100644 --- a/lint_test/prefer_match_file_name_wrong_test.dart +++ b/lint_test/prefer_match_file_name_wrong_test.dart @@ -1,9 +1,9 @@ // ignore_for_file: unused_element, unused_field -/// Check the `prefer-match-file-name` rule +/// Check the `prefer_match_file_name` rule class _AnotherPrivateClass {} -// expect_lint: prefer-match-file-name +// expect_lint: prefer_match_file_name class WrongClass {} /// Only first public element declaration is checked