Skip to content

Commit

Permalink
Bump the minimum custom_lint_builder version to 0.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
charlescyt committed Aug 15, 2024
1 parent 5beb6e6 commit a0be794
Show file tree
Hide file tree
Showing 50 changed files with 172 additions and 153 deletions.
5 changes: 4 additions & 1 deletion packages/pyramid_lint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Changed

- Bump the minimum `custom_lint_builder` version to 0.6.5.
- Bump the minimum `analyzer` version to 0.6.6.
- `avoid_public_members_in_states` now ignores public fields and methods with `@visibleForTesting` annotations.

### Fixed
Expand Down Expand Up @@ -34,7 +36,7 @@
- **BREAKING**: `avoid_widget_state_public_members` has been renamed to `avoid_public_members_in_states`.
- **BREAKING**: `proper_edge_insets_constructor` has been renamed to `proper_edge_insets_constructors`.
- **BREAKING**: `prefer_dedicated_media_query_method` has been renamed to `prefer_dedicated_media_query_functions`.
- Pump the minimum `custom_lint_builder` version to 0.6.2.
- Bump the minimum `custom_lint_builder` version to 0.6.2.
- Fix false positive for `avoid_nested_if` when the if statement is a else if statement. ([#44](https://github.com/charlescyt/pyramid_lint/pull/44))

### Removed
Expand Down Expand Up @@ -207,6 +209,7 @@
[parlough]: https://github.com/parlough
[imsamgarg]: https://github.com/imsamgarg

[Unreleased]: https://github.com/charlescyt/pyramid_lint/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/charlescyt/pyramid_lint/compare/v1.5.0...v2.0.0
[1.5.0]: https://github.com/charlescyt/pyramid_lint/compare/v1.4.0...v1.5.0
[1.4.0]: https://github.com/charlescyt/pyramid_lint/compare/v1.3.0...v1.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AlwaysPutDocCommentsBeforeAnnotations extends PyramidLintRule {
final annotationOffset = annotations.first.offset;
if (commentOffset < annotationOffset) return;

reporter.reportErrorForNode(code, comment);
reporter.atNode(comment, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AlwaysSpecifyParameterNames extends PyramidLintRule {
) {
context.registry.addSimpleFormalParameter((node) {
if (node.name == null) {
reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class AvoidAbbreviationsInDocComments

final index = commentText.indexOf(abbreviation);

reporter.reportErrorForOffset(
code,
comment.offset + index,
abbreviation.length,
reporter.atOffset(
offset: comment.offset + index,
length: abbreviation.length,
errorCode: code,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AvoidDynamic extends PyramidLintRule {
if (node.type is! DynamicType) return;
if (_isUsedInMap(node)) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AvoidEmptyBlocks extends PyramidLintRule {
final comment = node.endToken.precedingComments;
if (comment != null && _hasTodoComment(comment)) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ class AvoidInvertedBooleanExpressions extends PyramidLintRule {
'${operandExpression.rightOperand.toSource()}'
' ? ${parent.elseExpression.toSource()} : ${parent.thenExpression.toSource()}';

reporter.reportErrorForNode(
code,
reporter.atNode(
parent,
[correctExpression],
code,
arguments: [correctExpression],
);
} else {
correctExpression =
'${operandExpression.leftOperand.toSource()} ${invertedOperator.lexeme} '
'${operandExpression.rightOperand.toSource()}';

reporter.reportErrorForNode(
code,
reporter.atNode(
node,
[correctExpression],
code,
arguments: [correctExpression],
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AvoidMutableGlobalVariables extends PyramidLintRule {
final isConstOrFinal = variables.every((v) => v.isConst || v.isFinal);
if (isConstOrFinal) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AvoidNestedIf extends PyramidLintRule<AvoidNestedIfOptions> {

if (ifStatements.length < options.params.maxNestingLevel) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AvoidPositionalFieldsInRecords extends PyramidLintRule {
final propertyName = node.propertyName.name;
if (!propertyName.startsWith(r'$')) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AvoidRedundantPatternFieldNames extends PyramidLintRule {
final patternName = pattern.name.lexeme;
if (fieldName != patternName) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AvoidUnusedParameters

if (isParameterReferenced) continue;

reporter.reportErrorForNode(code, parameter);
reporter.atNode(parameter, code);
}
});

Expand Down Expand Up @@ -134,7 +134,7 @@ class AvoidUnusedParameters

if (isParameterReferenced) continue;

reporter.reportErrorForNode(code, parameter);
reporter.atNode(parameter, code);
}
});
}
Expand Down
24 changes: 12 additions & 12 deletions packages/pyramid_lint/lib/src/lints/dart/boolean_prefixes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class BooleanPrefixes extends PyramidLintRule<BooleanPrefixesOptions> {
final name = parent.name.lexeme;
if (isNameValid(name)) return;

reporter.reportErrorForToken(
code,
reporter.atToken(
parent.name,
[
code,
arguments: [
'Boolean variable',
'variable',
],
Expand All @@ -109,19 +109,19 @@ class BooleanPrefixes extends PyramidLintRule<BooleanPrefixesOptions> {
final parameter = node.parameters;
switch (parameter) {
case null:
reporter.reportErrorForToken(
code,
reporter.atToken(
node.name,
[
code,
arguments: [
'Getter that returns a boolean',
'getter',
],
);
case _:
reporter.reportErrorForToken(
code,
reporter.atToken(
node.name,
[
code,
arguments: [
'Method that returns a boolean',
'method',
],
Expand All @@ -136,10 +136,10 @@ class BooleanPrefixes extends PyramidLintRule<BooleanPrefixesOptions> {
final name = node.name.lexeme;
if (isNameValid(name)) return;

reporter.reportErrorForToken(
code,
reporter.atToken(
node.name,
[
code,
arguments: [
'Function that returns a boolean',
'function',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,27 @@ class ClassMembersOrdering extends PyramidLintRule {
final next = i < members.length - 1 ? members[i + 1] : null;

if (previous != null && comparator(current.type, previous.type) < 0) {
reporter.reportErrorForNode(code, current, [
current.type.label,
'before',
previous.type.label,
]);
reporter.atNode(
current,
code,
arguments: [
current.type.label,
'before',
previous.type.label,
],
);
}

if (next != null && comparator(current.type, next.type) > 0) {
reporter.reportErrorForNode(code, current, [
current.type.label,
'after',
next.type.label,
]);
reporter.atNode(
current,
code,
arguments: [
current.type.label,
'after',
next.type.label,
],
);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class MaxLinesForFile extends PyramidLintRule<MaxLinesForFileOptions> {
final lineCount = node.lineInfo.lineCount;
if (lineCount <= options.params.maxLines) return;

reporter.reportErrorForNode(
code,
reporter.atNode(
node,
[options.params.maxLines],
code,
arguments: [options.params.maxLines],
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class MaxLinesForFunction extends PyramidLintRule<MaxLinesForFunctionOptions> {
final lineCount = getLineCountForNode(body, lineInfo);
if (lineCount <= options.params.maxLines) return;

reporter.reportErrorForNode(
code,
reporter.atNode(
node,
['function', options.params.maxLines],
code,
arguments: ['function', options.params.maxLines],
);
});

Expand All @@ -79,10 +79,10 @@ class MaxLinesForFunction extends PyramidLintRule<MaxLinesForFunctionOptions> {
final lineCount = getLineCountForNode(body, lineInfo);
if (lineCount <= options.params.maxLines) return;

reporter.reportErrorForNode(
code,
reporter.atNode(
node,
['method', options.params.maxLines],
code,
arguments: ['method', options.params.maxLines],
);
});
}
Expand Down
12 changes: 10 additions & 2 deletions packages/pyramid_lint/lib/src/lints/dart/max_switch_cases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ class MaxSwitchCases extends PyramidLintRule<MaxSwitchCasesOptions> {
node.members.where((e) => e is SwitchCase || e is SwitchPatternCase);
if (cases.length <= options.params.maxCases) return;

reporter.reportErrorForNode(code, node, [options.params.maxCases]);
reporter.atNode(
node,
code,
arguments: [options.params.maxCases],
);
});

context.registry.addSwitchExpression((node) {
final cases = node.cases;
if (cases.length <= options.params.maxCases) return;

reporter.reportErrorForNode(code, node, [options.params.maxCases]);
reporter.atNode(
node,
code,
arguments: [options.params.maxCases],
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NoDuplicateImports extends PyramidLintRule {
for (final importDirective in importDirectives) {
final url = importDirective.uri.stringValue;
if (duplicateUrls.contains(url)) {
reporter.reportErrorForNode(code, importDirective.uri);
reporter.atNode(importDirective.uri, code);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NoSelfComparisons extends PyramidLintRule {
final right = expression.rightOperand.unParenthesized;
if (left.toSource() != right.toSource()) return;

reporter.reportErrorForNode(code, expression);
reporter.atNode(expression, code);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PreferAsyncAwait extends PyramidLintRule {
final methodName = node.methodName.name;
if (methodName != 'then') return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PreferConstConstructorDeclarations extends PyramidLintRule {
if (!allExpressionResolveToConstant) return;
}

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PreferImmediateReturn extends PyramidLintRule {
return;
}

reporter.reportErrorForNode(code, lastStatement);
reporter.atNode(lastStatement, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PreferIterableAny extends PyramidLintRule {

if (!iterableChecker.isAssignableFromType(targetType)) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PreferIterableEvery extends PyramidLintRule {

if (!iterableChecker.isAssignableFromType(targetType)) return;

reporter.reportErrorForNode(code, node);
reporter.atNode(node, code);
});
}

Expand Down
Loading

0 comments on commit a0be794

Please sign in to comment.