PureContractClassLint class final
A lint rule requiring pure contract classes to be declared as abstract interface class.
Abstract classes that have no instance field declarations and no method bodies serve purely
as interface contracts. In Dart 3+, adding the interface modifier ensures callers implement
the contract rather than extending it, preventing accidental inheritance bugs.
Example
BAD:
abstract class AuthGateway {
Future<void> signIn();
}
GOOD:
abstract interface class AuthGateway {
Future<void> signIn();
}
Constructors
- PureContractClassLint()
- Creates a new PureContractClassLint instance.
Properties
- canUseParsedResult → bool
-
Indicates whether this analysis rule can work with just the parsed
information or if it requires a resolved unit.
no setterinherited
- description → String
-
Short description suitable for display in console output and IDEs.
finalinherited
- diagnosticCode → LintCode
-
The code to report for a violation.
no setter
-
diagnosticCodes
→ List<
DiagnosticCode> -
The diagnostic codes associated with this analysis rule.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
incompatibleRules
→ List<
String> -
A list of incompatible rule names.
no setterinherited
- name → String
-
The rule name.
finalinherited
- pubspecVisitor → PubspecVisitor?
-
A visitor that visits a
Pubspecto perform analysis.no setterinherited - reporter ← DiagnosticReporter
-
Sets the
DiagnosticReporterfor theCompilationUnitcurrently being visited.no getterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → RuleState
-
The state of this analysis rule.
finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerNodeProcessors(
RuleVisitorRegistry registry, RuleContext context) → void -
Registers node processors in the given
registry. -
reportAtNode(
AstNode? node, {List< Object> arguments = const [], List<DiagnosticMessage> ? contextMessages}) → Diagnostic? -
Reports a diagnostic at
nodewith messageargumentsandcontextMessages.inherited -
reportAtOffset(
int offset, int length, {List< Object> arguments = const [], List<DiagnosticMessage> ? contextMessages}) → Diagnostic -
Reports a diagnostic at
offset, withlength, with messageargumentsandcontextMessages.inherited -
reportAtPubNode(
PubspecNode node, {List< Object> arguments = const [], List<DiagnosticMessage> contextMessages = const []}) → Diagnostic -
Reports a diagnostic at Pubspec
node, with messageargumentsandcontextMessages.inherited -
reportAtSourceRange(
SourceRange sourceRange, {List< Object> arguments = const [], List<DiagnosticMessage> ? contextMessages}) → Diagnostic -
Reports a diagnostic at
sourceRange, with messageargumentsandcontextMessages.inherited -
reportAtToken(
Token token, {List< Object> arguments = const [], List<DiagnosticMessage> ? contextMessages}) → Diagnostic? -
Reports a diagnostic at
token, with messageargumentsandcontextMessages.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- code → const LintCode
- The lint diagnostic code for PureContractClassLint.