diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 1ba2855..a88d0cc 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -20,6 +20,7 @@ custom_lint: - double_literal_format - avoid_unnecessary_type_assertions - avoid_debug_print_in_release + - consider_making_a_member_private - avoid_using_api: severity: info entries: diff --git a/lib/analysis_options.yaml b/lib/analysis_options.yaml index 9eeaace..536cb0f 100644 --- a/lib/analysis_options.yaml +++ b/lib/analysis_options.yaml @@ -52,6 +52,7 @@ custom_lint: - avoid_unused_parameters - avoid_debug_print_in_release - avoid_final_with_getter + - consider_making_a_member_private - cyclomatic_complexity: max_complexity: 10 diff --git a/lib/solid_lints.dart b/lib/solid_lints.dart index 0ddfd58..fe7142b 100644 --- a/lib/solid_lints.dart +++ b/lib/solid_lints.dart @@ -13,6 +13,7 @@ import 'package:solid_lints/src/lints/avoid_unnecessary_type_casts/avoid_unneces import 'package:solid_lints/src/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart'; import 'package:solid_lints/src/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart'; import 'package:solid_lints/src/lints/avoid_using_api/avoid_using_api_rule.dart'; +import 'package:solid_lints/src/lints/consider_making_a_member_private/consider_making_a_member_private_rule.dart'; import 'package:solid_lints/src/lints/cyclomatic_complexity/cyclomatic_complexity_rule.dart'; import 'package:solid_lints/src/lints/double_literal_format/double_literal_format_rule.dart'; import 'package:solid_lints/src/lints/function_lines_of_code/function_lines_of_code_rule.dart'; @@ -65,6 +66,7 @@ class _SolidLints extends PluginBase { AvoidDebugPrintInReleaseRule.createRule(configs), PreferEarlyReturnRule.createRule(configs), AvoidFinalWithGetterRule.createRule(configs), + ConsiderMakingAMemberPrivateRule.createRule(configs), ]; // Return only enabled rules diff --git a/lib/src/lints/consider_making_a_member_private/consider_making_a_member_private_rule.dart b/lib/src/lints/consider_making_a_member_private/consider_making_a_member_private_rule.dart new file mode 100644 index 0000000..323d418 --- /dev/null +++ b/lib/src/lints/consider_making_a_member_private/consider_making_a_member_private_rule.dart @@ -0,0 +1,86 @@ +import 'package:analyzer/error/listener.dart'; +import 'package:custom_lint_builder/custom_lint_builder.dart'; +import 'package:solid_lints/src/lints/consider_making_a_member_private/visitor/consider_making_a_member_private_visitor.dart'; +import 'package:solid_lints/src/models/rule_config.dart'; +import 'package:solid_lints/src/models/solid_lint_rule.dart'; + +/// Warns about public method, field if its not used outside. +/// +/// ### Example: +/// #### BAD: +/// class X { +/// only used internally +/// void x() { +/// ... +/// } +///} +/// #### Good: +/// class X { +/// only used internally +/// void _x() { +/// ... +/// } +///} +/// #### Good: +/// class X { +/// +/// void x() { +/// ... +/// } +///} +/// +/// class Y { +/// +/// final x = X(); +/// +/// void y(){ +/// x.x(); +/// } +/// } +class ConsiderMakingAMemberPrivateRule extends SolidLintRule { + /// This lint rule represents + /// the error whether we use public method, field if its not used outside. + static const String lintName = 'consider_making_a_member_private'; + + ConsiderMakingAMemberPrivateRule._(super.config); + + /// Creates a new instance of [ConsiderMakingAMemberPrivateRule] + /// based on the lint configuration. + factory ConsiderMakingAMemberPrivateRule.createRule( + CustomLintConfigs configs, + ) { + final rule = RuleConfig( + configs: configs, + name: lintName, + problemMessage: (_) => 'Consider making a member privat', + ); + + return ConsiderMakingAMemberPrivateRule._(rule); + } + + @override + void run( + CustomLintResolver resolver, + ErrorReporter reporter, + CustomLintContext context, + ) { + context.registry.addCompilationUnit((node) { + final visitor = ConsiderMakingAMemberPrivateVisitor(node); + node.visitChildren(visitor); + + final unusedMembers = visitor.unusedPublicMembers; + final unusedGlobalVariables = visitor.unusedGlobalVariables; + final unusedGlobalFunctions = visitor.unusedGlobalFunctions; + + for (final member in unusedMembers) { + reporter.atNode(member, code); + } + for (final variable in unusedGlobalVariables) { + reporter.atNode(variable, code); + } + for (final function in unusedGlobalFunctions) { + reporter.atNode(function, code); + } + }); + } +} diff --git a/lib/src/lints/consider_making_a_member_private/visitor/consider_making_a_member_private_visitor.dart b/lib/src/lints/consider_making_a_member_private/visitor/consider_making_a_member_private_visitor.dart new file mode 100644 index 0000000..509eba0 --- /dev/null +++ b/lib/src/lints/consider_making_a_member_private/visitor/consider_making_a_member_private_visitor.dart @@ -0,0 +1,178 @@ +// MIT License +// +// Copyright (c) 2020-2021 Dart Code Checker team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import 'package:analyzer/dart/ast/ast.dart'; +import 'package:analyzer/dart/ast/visitor.dart'; + +/// AST Visitor for identifying unused public members, global functions, +/// and variables. +class ConsiderMakingAMemberPrivateVisitor extends RecursiveAstVisitor { + final CompilationUnit _node; + + final _unusedPublicMembers = {}; + final _unusedGlobalFunctions = {}; + final _unusedGlobalVariables = {}; + + /// Returns unused public members of classes. + Iterable get unusedPublicMembers => _unusedPublicMembers; + + /// Returns unused global functions. + Iterable get unusedGlobalFunctions => + _unusedGlobalFunctions; + + /// Returns unused global variables. + Iterable get unusedGlobalVariables => + _unusedGlobalVariables; + + /// Constructor for [ConsiderMakingAMemberPrivateVisitor] + ConsiderMakingAMemberPrivateVisitor(this._node); + + @override + void visitClassDeclaration(ClassDeclaration node) { + // Check for unused public members in a class. + final classMembers = node.members.where((member) { + if (member is MethodDeclaration || member is FieldDeclaration) { + final name = _getMemberName(member); + return name != null && !_isPrivate(name); + } + if (member is ConstructorDeclaration) { + final name = _getMemberName(member); + if (name == null) return true; + + return !_isPrivate(name); + } + return false; + }).toList(); + + for (final member in classMembers) { + final memberName = _getMemberName(member); + if (!_isUsedOutsideClass(memberName, node)) { + _unusedPublicMembers.add(member); + } + } + + super.visitClassDeclaration(node); + } + + @override + void visitFunctionDeclaration(FunctionDeclaration node) { + final name = node.declaredElement?.name; + if (!_isPrivate(name) && !_isUsedEntity(name)) { + _unusedGlobalFunctions.add(node); + } + super.visitFunctionDeclaration(node); + } + + @override + void visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { + for (final variable in node.variables.variables) { + final name = variable.declaredElement?.name; + if (!_isPrivate(name) && !_isUsedEntity(name)) { + _unusedGlobalVariables.add(variable); + } + } + super.visitTopLevelVariableDeclaration(node); + } + + bool _isPrivate(String? name) => name?.startsWith('_') ?? false; + + String? _getMemberName(ClassMember member) { + if (member is MethodDeclaration) return member.declaredElement?.name; + if (member is FieldDeclaration) { + final fields = member.fields.variables; + return fields.isNotEmpty ? fields.first.declaredElement?.name : null; + } + if (member is ConstructorDeclaration) { + return member.declaredElement?.name; + } + return null; + } + + bool _isUsedOutsideClass(String? memberName, ClassDeclaration classNode) { + bool isUsedOutside = false; + + _node.visitChildren( + _GlobalEntityUsageVisitor( + entityName: memberName!, + onUsageFound: () { + isUsedOutside = true; + }, + ), + ); + + if (memberName.isEmpty) return true; + + return isUsedOutside; + } + + bool _isUsedEntity(String? entityName) { + bool isUsed = false; + + if (entityName == null) return false; + + _node.visitChildren( + _GlobalEntityUsageVisitor( + entityName: entityName, + onUsageFound: () { + isUsed = true; + }, + ), + ); + + return isUsed; + } +} + +class _GlobalEntityUsageVisitor extends RecursiveAstVisitor { + final String entityName; + final Function() onUsageFound; + + _GlobalEntityUsageVisitor({ + required this.entityName, + required this.onUsageFound, + }); + + @override + void visitSimpleIdentifier(SimpleIdentifier identifier) { + if (identifier.name == entityName) { + onUsageFound(); + } + super.visitSimpleIdentifier(identifier); + } + + @override + void visitInstanceCreationExpression(InstanceCreationExpression node) { + if (node.constructorName.name?.name == entityName) { + onUsageFound(); + } + super.visitInstanceCreationExpression(node); + } + + @override + void visitMethodInvocation(MethodInvocation node) { + if (node.target != null && node.target.toString() == entityName) { + onUsageFound(); + } + super.visitMethodInvocation(node); + } +} 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 498188f..02d0e74 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,4 +1,4 @@ -// ignore_for_file: unused_field +// ignore_for_file: unused_field, consider_making_a_member_private // ignore_for_file: unused_element // ignore_for_file: prefer_match_file_name diff --git a/lint_test/analysis_options.yaml b/lint_test/analysis_options.yaml index 3d8da19..a103462 100644 --- a/lint_test/analysis_options.yaml +++ b/lint_test/analysis_options.yaml @@ -58,3 +58,4 @@ custom_lint: - prefer_match_file_name - proper_super_calls - avoid_final_with_getter + - consider_making_a_member_private diff --git a/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_prefix_test.dart b/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_prefix_test.dart index 01b162a..3a1d7d0 100644 --- a/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_prefix_test.dart +++ b/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_prefix_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable +// ignore_for_file: unused_local_variable, consider_making_a_member_private import 'package:flutter/foundation.dart' as f; diff --git a/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_test.dart b/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_test.dart index 9d6fa72..b3a9f05 100644 --- a/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_test.dart +++ b/lint_test/avoid_debug_print_in_release_test/avoid_debug_print_in_release_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable +// ignore_for_file: unused_local_variable, consider_making_a_member_private import 'package:flutter/foundation.dart'; diff --git a/lint_test/avoid_final_with_getter_test.dart b/lint_test/avoid_final_with_getter_test.dart index 4f0fa32..53fa0c2 100644 --- a/lint_test/avoid_final_with_getter_test.dart +++ b/lint_test/avoid_final_with_getter_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis, prefer_match_file_name, unused_local_variable +// ignore_for_file: type_annotate_public_apis, prefer_match_file_name, unused_local_variable, consider_making_a_member_private /// Check final private field with getter fail /// `avoid_final_with_getter` diff --git a/lint_test/avoid_global_state_test.dart b/lint_test/avoid_global_state_test.dart index 37028d4..df8da7e 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, unused_local_variable +// ignore_for_file: type_annotate_public_apis, prefer_match_file_name, unused_local_variable, consider_making_a_member_private /// Check global mutable variable fail /// `avoid_global_state` diff --git a/lint_test/avoid_late_keyword/allow_initialized/avoid_late_keyword_allow_initialized_test.dart b/lint_test/avoid_late_keyword/allow_initialized/avoid_late_keyword_allow_initialized_test.dart index 8136b96..300533c 100644 --- a/lint_test/avoid_late_keyword/allow_initialized/avoid_late_keyword_allow_initialized_test.dart +++ b/lint_test/avoid_late_keyword/allow_initialized/avoid_late_keyword_allow_initialized_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, consider_making_a_member_private // ignore_for_file: avoid_global_state abstract class Animation {} diff --git a/lint_test/avoid_late_keyword/no_generics/avoid_late_keyword_no_generics_test.dart b/lint_test/avoid_late_keyword/no_generics/avoid_late_keyword_no_generics_test.dart index 12fea48..8459f19 100644 --- a/lint_test/avoid_late_keyword/no_generics/avoid_late_keyword_no_generics_test.dart +++ b/lint_test/avoid_late_keyword/no_generics/avoid_late_keyword_no_generics_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, consider_making_a_member_private // ignore_for_file: avoid_global_state class Subscription {} diff --git a/lint_test/avoid_late_keyword/with_generics/avoid_late_keyword_with_generics_test.dart b/lint_test/avoid_late_keyword/with_generics/avoid_late_keyword_with_generics_test.dart index 576ade7..4fa3e84 100644 --- a/lint_test/avoid_late_keyword/with_generics/avoid_late_keyword_with_generics_test.dart +++ b/lint_test/avoid_late_keyword/with_generics/avoid_late_keyword_with_generics_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, consider_making_a_member_private // ignore_for_file: avoid_global_state class ColorTween {} diff --git a/lint_test/avoid_non_null_assertion_test.dart b/lint_test/avoid_non_null_assertion_test.dart index 2a33a7d..2251779 100644 --- a/lint_test/avoid_non_null_assertion_test.dart +++ b/lint_test/avoid_non_null_assertion_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: avoid_global_state, prefer_match_file_name +// ignore_for_file: avoid_global_state, prefer_match_file_name, consider_making_a_member_private // ignore_for_file: member_ordering /// Check "bang" operator fail diff --git a/lint_test/avoid_returning_widget_test/avoid_returning_widget_test.dart b/lint_test/avoid_returning_widget_test/avoid_returning_widget_test.dart index a1f3677..b8d0ae6 100644 --- a/lint_test/avoid_returning_widget_test/avoid_returning_widget_test.dart +++ b/lint_test/avoid_returning_widget_test/avoid_returning_widget_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_element, prefer_match_file_name +// ignore_for_file: unused_element, prefer_match_file_name, consider_making_a_member_private // ignore_for_file: member_ordering /// Check returning a widget fail diff --git a/lint_test/avoid_unnecessary_setstate_test.dart b/lint_test/avoid_unnecessary_setstate_test.dart index b308515..e864e71 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, consider_making_a_member_private 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 b3f2f3c..566592d 100644 --- a/lint_test/avoid_unnecessary_type_assertions_test.dart +++ b/lint_test/avoid_unnecessary_type_assertions_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations, prefer_match_file_name, cyclomatic_complexity, unused_element +// ignore_for_file: prefer_const_declarations, prefer_match_file_name, cyclomatic_complexity, unused_element, consider_making_a_member_private // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unnecessary_type_check // ignore_for_file: unused_local_variable diff --git a/lint_test/avoid_unnecessary_type_casts_test.dart b/lint_test/avoid_unnecessary_type_casts_test.dart index dffa690..97a2b51 100644 --- a/lint_test/avoid_unnecessary_type_casts_test.dart +++ b/lint_test/avoid_unnecessary_type_casts_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations +// ignore_for_file: prefer_const_declarations, consider_making_a_member_private // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unnecessary_cast // ignore_for_file: unused_local_variable diff --git a/lint_test/avoid_unrelated_type_assertions_test.dart b/lint_test/avoid_unrelated_type_assertions_test.dart index 209a561..5a0b063 100644 --- a/lint_test/avoid_unrelated_type_assertions_test.dart +++ b/lint_test/avoid_unrelated_type_assertions_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations, prefer_match_file_name, unused_element +// ignore_for_file: prefer_const_declarations, prefer_match_file_name, unused_element, consider_making_a_member_private // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unused_local_variable diff --git a/lint_test/avoid_unused_parameters_test.dart b/lint_test/avoid_unused_parameters_test.dart index b75e120..94aad81 100644 --- a/lint_test/avoid_unused_parameters_test.dart +++ b/lint_test/avoid_unused_parameters_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations, prefer_match_file_name, avoid_global_state +// ignore_for_file: prefer_const_declarations, prefer_match_file_name, avoid_global_state, consider_making_a_member_private // ignore_for_file: unnecessary_nullable_for_final_variable_declarations // ignore_for_file: unused_local_variable // ignore_for_file: unused_element diff --git a/lint_test/avoid_using_api/external_source/lib/banned_library.dart b/lint_test/avoid_using_api/external_source/lib/banned_library.dart index abad480..1978c36 100644 --- a/lint_test/avoid_using_api/external_source/lib/banned_library.dart +++ b/lint_test/avoid_using_api/external_source/lib/banned_library.dart @@ -1,2 +1,3 @@ +//ignore_for_file:consider_making_a_member_private // expect_lint: avoid_global_state int banned = 5; diff --git a/lint_test/avoid_using_api/external_source/lib/external_source.dart b/lint_test/avoid_using_api/external_source/lib/external_source.dart index 4b2d78d..ee64409 100644 --- a/lint_test/avoid_using_api/external_source/lib/external_source.dart +++ b/lint_test/avoid_using_api/external_source/lib/external_source.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_match_file_name +// ignore_for_file: prefer_match_file_name, consider_making_a_member_private // ignore_for_file: no_empty_block class BannedCodeUsage { diff --git a/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_inner.dart b/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_inner.dart new file mode 100644 index 0000000..c49b2b0 --- /dev/null +++ b/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_inner.dart @@ -0,0 +1,54 @@ +// ignore_for_file: no_empty_block, prefer_match_file_name, unused_element, member_ordering, avoid_global_state, avoid_unused_parameters +/// Check the `consider_making_a_member_private` rule +/// + +// expect_lint:consider_making_a_member_private +const int unusedGlobalVariables = 0; + +//no lint +const int usedGlobalVariables = 0; + +// expect_lint:consider_making_a_member_private +void unusedGLobalFunction() {} + +//no lint +void usedGLobalFunction() {} + +class X { + // expect_lint:consider_making_a_member_private + void unusedX() {} + + // expect_lint:consider_making_a_member_private + final int unusedFinalX = 0; + // expect_lint:consider_making_a_member_private + static final int unusedStaticX = 0; + + // expect_lint:consider_making_a_member_private + int unusedMutableX = 0; + + // expect_lint:consider_making_a_member_private + int get unusedGetX => 0; + + // expect_lint:consider_making_a_member_private + set unusedSetX(int y) {} + + // no lint + void usedMethodX() {} + + // expect_lint:consider_making_a_member_private + static void unusedStaticMethodX() {} + + // no lint + X(); + + // expect_lint:consider_making_a_member_private + X.withValue({ + required this.unusedMutableX, + }); + + // expect_lint:consider_making_a_member_private + factory X.factory() => X(); + + // no lint + factory X.usedFactory() => X(); +} diff --git a/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_outer.dart b/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_outer.dart new file mode 100644 index 0000000..f82fb47 --- /dev/null +++ b/lint_test/consider_making_a_member_private_test/consider_making_a_member_private_test_outer.dart @@ -0,0 +1,16 @@ +// ignore_for_file: no_empty_block, prefer_match_file_name, unused_element, member_ordering, avoid_global_state, avoid_unused_parameters +import 'consider_making_a_member_private_test_inner.dart'; + +/// Check the `consider_making_a_member_private` rule +/// + +class Y { + // no lint + void _y() { + final x = X(); + X.usedFactory(); + x.usedMethodX(); + usedGLobalFunction(); + usedGlobalVariables; + } +} diff --git a/lint_test/cyclomatic_complexity_test.dart b/lint_test/cyclomatic_complexity_test.dart index 0fafcda..716fcce 100644 --- a/lint_test/cyclomatic_complexity_test.dart +++ b/lint_test/cyclomatic_complexity_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: literal_only_boolean_expressions, prefer_early_return +// ignore_for_file: literal_only_boolean_expressions, prefer_early_return, consider_making_a_member_private // ignore_for_file: no_empty_block, prefer_match_file_name /// Check complexity fail diff --git a/lint_test/double_literal_format_test.dart b/lint_test/double_literal_format_test.dart index 195b01e..bf694c2 100644 --- a/lint_test/double_literal_format_test.dart +++ b/lint_test/double_literal_format_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: avoid_global_state +// ignore_for_file: avoid_global_state, consider_making_a_member_private // ignore_for_file: type_annotate_public_apis // ignore_for_file: unused_local_variable diff --git a/lint_test/function_lines_of_code_test/function_lines_of_code_test.dart b/lint_test/function_lines_of_code_test/function_lines_of_code_test.dart index e35d5d6..9172e21 100644 --- a/lint_test/function_lines_of_code_test/function_lines_of_code_test.dart +++ b/lint_test/function_lines_of_code_test/function_lines_of_code_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_match_file_name +// ignore_for_file: prefer_match_file_name, consider_making_a_member_private class ClassWithLongMethods { // expect_lint: function_lines_of_code diff --git a/lint_test/member_ordering_test.dart b/lint_test/member_ordering_test.dart index 3faf21f..e93eb9d 100644 --- a/lint_test/member_ordering_test.dart +++ b/lint_test/member_ordering_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_field, prefer_match_file_name, proper_super_calls +// ignore_for_file: unused_field, prefer_match_file_name, proper_super_calls, consider_making_a_member_private // ignore_for_file: unused_element // ignore_for_file: no_empty_block diff --git a/lint_test/newline_before_return_test.dart b/lint_test/newline_before_return_test.dart index 282057a..33b77d3 100644 --- a/lint_test/newline_before_return_test.dart +++ b/lint_test/newline_before_return_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable, prefer_match_file_name +// ignore_for_file: unused_local_variable, prefer_match_file_name, consider_making_a_member_private // ignore_for_file: member_ordering // ignore_for_file: avoid_unused_parameters diff --git a/lint_test/no_empty_block_test.dart b/lint_test/no_empty_block_test.dart index 385d30c..3ebb54c 100644 --- a/lint_test/no_empty_block_test.dart +++ b/lint_test/no_empty_block_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_const_declarations, prefer_match_file_name, prefer_early_return +// ignore_for_file: prefer_const_declarations, prefer_match_file_name, prefer_early_return, consider_making_a_member_private // ignore_for_file: unused_local_variable // ignore_for_file: cyclomatic_complexity // ignore_for_file: avoid_unused_parameters diff --git a/lint_test/no_equal_then_else_test.dart b/lint_test/no_equal_then_else_test.dart index c9caa40..8870fbd 100644 --- a/lint_test/no_equal_then_else_test.dart +++ b/lint_test/no_equal_then_else_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable +// ignore_for_file: unused_local_variable, consider_making_a_member_private // ignore_for_file: cyclomatic_complexity // ignore_for_file: no_magic_number // ignore_for_file: prefer_conditional_expressions diff --git a/lint_test/no_magic_number_allowed_in_widget_params_test/no_magic_number_allowed_in_widget_params_test.dart b/lint_test/no_magic_number_allowed_in_widget_params_test/no_magic_number_allowed_in_widget_params_test.dart index 7d603d2..142cbe8 100644 --- a/lint_test/no_magic_number_allowed_in_widget_params_test/no_magic_number_allowed_in_widget_params_test.dart +++ b/lint_test/no_magic_number_allowed_in_widget_params_test/no_magic_number_allowed_in_widget_params_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: avoid_returning_widgets +// ignore_for_file: avoid_returning_widgets, consider_making_a_member_private // ignore_for_file: prefer_match_file_name // Allowed for numbers in a Widget subtype parameters. diff --git a/lint_test/no_magic_number_test.dart b/lint_test/no_magic_number_test.dart index 4bdc69e..07809d8 100644 --- a/lint_test/no_magic_number_test.dart +++ b/lint_test/no_magic_number_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable, avoid_returning_widgets +// ignore_for_file: unused_local_variable, avoid_returning_widgets, consider_making_a_member_private // ignore_for_file: prefer_match_file_name // ignore_for_file: avoid_unused_parameters // ignore_for_file: no_empty_block diff --git a/lint_test/number_of_parameters_test.dart b/lint_test/number_of_parameters_test.dart index 12fa6e2..fa2fa33 100644 --- a/lint_test/number_of_parameters_test.dart +++ b/lint_test/number_of_parameters_test.dart @@ -1,3 +1,4 @@ +// ignore_for_file: consider_making_a_member_private /// Check number of parameters fail /// /// `number_of_parameters: max_parameters` 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 150b9e4..cad1956 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,4 +1,4 @@ -// ignore_for_file: unused_local_variable +// ignore_for_file: unused_local_variable,consider_making_a_member_private // ignore_for_file: cyclomatic_complexity // ignore_for_file: no_equal_then_else diff --git a/lint_test/prefer_conditional_expressions_test.dart b/lint_test/prefer_conditional_expressions_test.dart index ee60f23..73c528d 100644 --- a/lint_test/prefer_conditional_expressions_test.dart +++ b/lint_test/prefer_conditional_expressions_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_local_variable +// ignore_for_file: unused_local_variable, consider_making_a_member_private // ignore_for_file: cyclomatic_complexity // ignore_for_file: no_equal_then_else // ignore_for_file: dead_code diff --git a/lint_test/prefer_early_return_test.dart b/lint_test/prefer_early_return_test.dart index d910818..4446901 100644 --- a/lint_test/prefer_early_return_test.dart +++ b/lint_test/prefer_early_return_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: dead_code, cyclomatic_complexity, no_equal_then_else, prefer_match_file_name +// ignore_for_file: dead_code, cyclomatic_complexity, no_equal_then_else, prefer_match_file_name, consider_making_a_member_private // ignore: no_empty_block void _doSomething() {} diff --git a/lint_test/prefer_first_test.dart b/lint_test/prefer_first_test.dart index 2527d82..8801d6f 100644 --- a/lint_test/prefer_first_test.dart +++ b/lint_test/prefer_first_test.dart @@ -1,3 +1,4 @@ +// ignore_for_file: consider_making_a_member_private /// Check the `prefer_first` rule void fun() { const zero = 0; diff --git a/lint_test/prefer_last_test.dart b/lint_test/prefer_last_test.dart index 4b87476..d9e6596 100644 --- a/lint_test/prefer_last_test.dart +++ b/lint_test/prefer_last_test.dart @@ -1,3 +1,4 @@ +// ignore_for_file: consider_making_a_member_private /// Check the `prefer_first` rule void fun() { final list = [0, 1, 2, 3]; diff --git a/lint_test/proper_super_calls_test.dart b/lint_test/proper_super_calls_test.dart index fc6e477..515bd31 100644 --- a/lint_test/proper_super_calls_test.dart +++ b/lint_test/proper_super_calls_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer_match_file_name, no_empty_block +// ignore_for_file: prefer_match_file_name, no_empty_block, consider_making_a_member_private class Widget {}