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

chore: restrict analyzer version to >=2.4.0 <3.2.0. #645

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

* feat: support excludes for a separate anti-pattern.
* chore: restrict `analyzer` version to `>=2.4.0 <3.2.0`.

## 4.9.1

* fix: `avoid-global-state` to support static fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class _Visitor extends RecursiveAstVisitor<void> {
if (!node.isFinal && !node.isConst) {
_declarations.add(node);
}
} else {
if ((node.declaredElement?.isStatic ?? false) &&
!node.isFinal &&
!node.isConst) {
_declarations.add(node);
}
} else if ((node.declaredElement?.isStatic ?? false) &&
!node.isFinal &&
!node.isConst) {
_declarations.add(node);
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
sdk: ">=2.14.0 <3.0.0"

dependencies:
analyzer: ">=2.4.0 <3.1.0"
analyzer: ">=2.4.0 <3.2.0"
analyzer_plugin: ">=0.8.0 <0.10.0"
ansicolor: ^2.0.1
args: ^2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,27 @@ void main() {

RuleTestHelper.verifyIssues(
issues: issues,
startLines: [1, 2, 10, 11],
startColumns: [5, 5, 15, 18],
startLines: [1, 2, 10, 11, 21, 22, 32, 33],
startColumns: [5, 5, 15, 18, 15, 18, 15, 18],
locationTexts: [
'answer = 42',
'evenNumbers = [1, 2, 3].where((element) => element.isEven)',
'a',
'c',
'a',
'c',
'a',
'c',
],
messages: [
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
'Avoid using global variable without const or final keywords.',
],
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,25 @@ class Foo {
dynamic c2;
const d = 1;
static const noted = '';
static final finalField = 1;
void function() {}
}

class Mixin {
static int? a; // LINT
static dynamic c; // LINT
final int? b;
dynamic c2;
const d = 1;
static const noted = '';
static final finalField = 1;
void function() {}
}

extension Extension on String {
static int? a; // LINT
static dynamic c; // LINT
static const noted = '';
static final finalField = 1;
void function() {}
}