Skip to content

Commit

Permalink
Fixed docs linter issues (#179)
Browse files Browse the repository at this point in the history
* Fixed analyzer issue, fixed linter

* Fixed LintCode issue

* Fixed LintCode issue

* Fixed pubspec

* Try to update analyzer version

* Try to override analyzer dependency

* Add import as instead of hide

* Fixed tests fpr custom linter to work correctly

* Fixed issue with LintCode in docs

* Fix description for rules
  • Loading branch information
solid-glebvorobey authored Sep 19, 2024
1 parent fcc0621 commit 4fc1a05
Show file tree
Hide file tree
Showing 29 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
///
///
class AvoidDebugPrintInReleaseRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error when debugPrint is called
static const lintName = 'avoid_debug_print_in_release';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/error.dart' as error;
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/source/source_range.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
Expand Down Expand Up @@ -35,7 +35,7 @@ part 'fixes/avoid_final_with_getter_fix.dart';
/// ```
///
class AvoidFinalWithGetterRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use final private fields with getters.
static const lintName = 'avoid_final_with_getter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class _FinalWithGetterFix extends DartFix {
CustomLintResolver resolver,
ChangeReporter reporter,
CustomLintContext context,
AnalysisError analysisError,
List<AnalysisError> others,
error.AnalysisError analysisError,
List<error.AnalysisError> others,
) {
context.registry.addMethodDeclaration((node) {
if (analysisError.sourceRange.intersects(node.sourceRange)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class AvoidGlobalStateRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use global state.
static const lintName = 'avoid_global_state';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import 'package:solid_lints/src/utils/types_utils.dart';
/// }
/// ```
class AvoidLateKeywordRule extends SolidLintRule<AvoidLateKeywordParameters> {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use `late` keyword.
static const lintName = 'avoid_late_keyword';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// map['key']!;
/// ```
class AvoidNonNullAssertionRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bang operator.
static const lintName = 'avoid_non_null_assertion';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import 'package:solid_lints/src/utils/types_utils.dart';
/// ```
class AvoidReturningWidgetsRule
extends SolidLintRule<AvoidReturningWidgetsParameters> {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we return a widget.
static const lintName = 'avoid_returning_widgets';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const whereTypeMethodName = 'whereType';
/// final castedD = nullableD is double;
/// ```
class AvoidUnnecessaryTypeAssertions extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const lintName = 'avoid_unnecessary_type_assertions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/error/error.dart' as error;
import 'package:analyzer/error/listener.dart' as error_listener;
import 'package:analyzer/source/source_range.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:solid_lints/src/lints/avoid_unnecessary_type_casts/visitors/avoid_unnecessary_type_casts_visitor.dart';
Expand All @@ -12,7 +12,7 @@ part 'fixes/avoid_unnecessary_type_casts_fix.dart';
/// 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
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const lintName = 'avoid_unnecessary_type_casts';

Expand All @@ -33,7 +33,7 @@ class AvoidUnnecessaryTypeCastsRule extends SolidLintRule {
@override
void run(
CustomLintResolver resolver,
ErrorReporter reporter,
error_listener.ErrorReporter reporter,
CustomLintContext context,
) {
context.registry.addAsExpression((node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class _UnnecessaryTypeCastsFix extends DartFix {
CustomLintResolver resolver,
ChangeReporter reporter,
CustomLintContext context,
AnalysisError analysisError,
List<AnalysisError> others,
error.AnalysisError analysisError,
List<error.AnalysisError> others,
) {
context.registry.addAsExpression((node) {
if (analysisError.sourceRange.intersects(node.sourceRange)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// 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
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const lintName = 'avoid_unrelated_type_assertions';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
///
/// ```
class AvoidUnusedParametersRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const String lintName = 'avoid_unused_parameters';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/avoid_using_api/avoid_using_api_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import 'package:solid_lints/src/utils/path_utils.dart';
///
/// Contributed by getBoolean (https://github.com/getBoolean).
class AvoidUsingApiRule extends SolidLintRule<AvoidUsingApiParameters> {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const String lintName = 'avoid_using_api';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// ```
class CyclomaticComplexityRule
extends SolidLintRule<CyclomaticComplexityParameters> {
/// The [LintCode] of this lint rule that represents the error if complexity
/// This lint rule represents the error if complexity
/// reaches maximum value.
static const lintName = 'cyclomatic_complexity';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ part 'double_literal_format_utils.dart';
/// var a = 5.23, b = 0.16e+5, c = -0.25, d = -0.4e-5;
/// ```
class DoubleLiteralFormatRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const lintName = 'double_literal_format';

// Use different messages for different issues
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use double literals with a redundant leading 0.
static const _leadingZeroCode = LintCode(
name: lintName,
problemMessage: "Double literals shouldn't have redundant leading `0`.",
correctionMessage: "Remove redundant leading `0`.",
);

/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use double literals with a leading decimal point.
static const _leadingDecimalCode = LintCode(
name: lintName,
Expand All @@ -49,7 +49,7 @@ class DoubleLiteralFormatRule extends SolidLintRule {
correctionMessage: "Add missing leading `0`.",
);

/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use double literals with a trailing 0.
static const _trailingZeroCode = LintCode(
name: lintName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// ```
class FunctionLinesOfCodeRule
extends SolidLintRule<FunctionLinesOfCodeParameters> {
/// The [LintCode] of this lint rule that represents the error if number of
/// This lint rule represents the error if number of
/// parameters reaches the maximum value.
static const lintName = 'function_lines_of_code';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/member_ordering/member_ordering_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class MemberOrderingRule extends SolidLintRule<MemberOrderingParameters> {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether we use bad formatted double literals.
static const lintName = 'member_ordering';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class NewlineBeforeReturnRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if
/// This lint rule represents the error if
/// newline is missing before return statement
static const String lintName = 'newline_before_return';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/no_empty_block/no_empty_block_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class NoEmptyBlockRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether left empty block.
static const String lintName = 'no_empty_block';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// selectedValue = condition ? valueA : valueB;
/// ```
class NoEqualThenElseRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if
/// This lint rule represents the error if
/// 'if' statements or conditional expression is redundant
static const String lintName = 'no_equal_then_else';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/no_magic_number/no_magic_number_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class NoMagicNumberRule extends SolidLintRule<NoMagicNumberParameters> {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error when having magic number.
static const String lintName = 'no_magic_number';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// ```
class NumberOfParametersRule
extends SolidLintRule<NumberOfParametersParameters> {
/// The [LintCode] of this lint rule that represents the error if number of
/// This lint rule represents the error if number of
/// parameters reaches the maximum value.
static const lintName = 'number_of_parameters';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// ```
class PreferConditionalExpressionsRule
extends SolidLintRule<PreferConditionalExpressionsParameters> {
/// The [LintCode] of this lint rule that represents the error if number of
/// This lint rule represents the error if number of
/// parameters reaches the maximum value.
static const lintName = 'prefer_conditional_expressions';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class PreferEarlyReturnRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if
/// This lint rule represents the error if
/// 'if' statements should be reversed
static const String lintName = 'prefer_early_return';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/prefer_first/prefer_first_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// a.first; // OK
/// ```
class PreferFirstRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if number of
/// This lint rule represents the error if number of
/// parameters reaches the maximum value.
static const lintName = 'prefer_first';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/lints/prefer_last/prefer_last_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// a.last; // OK
/// ```
class PreferLastRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if iterable
/// This lint rule represents the error if iterable
/// access can be simplified.
static const lintName = 'prefer_last';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import 'package:solid_lints/src/utils/node_utils.dart';
/// ```
///
class PreferMatchFileNameRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents the error if iterable
/// This lint rule represents the error if iterable
/// access can be simplified.
static const String lintName = 'prefer_match_file_name';
static final _onlySymbolsRegex = RegExp('[^a-zA-Z0-9]');
Expand Down
6 changes: 3 additions & 3 deletions lib/src/lints/proper_super_calls/proper_super_calls_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart';
/// }
/// ```
class ProperSuperCallsRule extends SolidLintRule {
/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether the initState and dispose methods
/// are called in the incorrect order
static const lintName = 'proper_super_calls';
static const _initState = 'initState';
static const _dispose = 'dispose';
static const _override = 'override';

/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether super.initState() should be called first
static const _superInitStateCode = LintCode(
name: lintName,
problemMessage: "super.initState() should be first",
);

/// The [LintCode] of this lint rule that represents
/// This lint rule represents
/// the error whether super.dispose() should be called last
static const _superDisposeCode = LintCode(
name: lintName,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/rule_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RuleConfig<T extends Object?> {
parameters = paramsParser?.call(configs.rules[name]?.json ?? {}) as T,
_problemMessageFactory = problemMessage;

/// The [LintCode] of this lint rule that represents the error.
/// This lint rule represents the error.
final String name;

/// A flag which indicates whether this rule was enabled by the user.
Expand Down

0 comments on commit 4fc1a05

Please sign in to comment.