Skip to main content

ban-name

added in: 4.12.0
style
⚙️

Configure some names that you want to ban.

Example: When you add some extra functionalities to built-in Flutter functions (such as logging for showDialog), you may want to ban the original Flutter function and use your own version.

caution

When trying to ban some methods in your package, it also triggers on imported from an external package code.

Example

❌ Bad:

// suppose the configuration is the one shown below

showDialog('some_arguments', 'another_argument'); // LINT
material.showDialog('some_arguments', 'another_argument'); // LINT

var strangeName = 42; // LINT

void strangeName() {} // LINT

// LINT
class AnotherStrangeName {
late var strangeName; // LINT
}

✅ Good:

myShowDialog();

⚙️ Config example

dart_code_metrics:
...
rules:
...
- ban-name:
entries:
- ident: showDialog
description: Please use myShowDialog in this package
- ident: strangeName
description: The name is too strange
- ident: AnotherStrangeName
description: Oops