Rust-clippy: New Lint: blacklisted_method

Created on 22 Sep 2020  路  6Comments  路  Source: rust-lang/rust-clippy

What it does

Blacklist Method Disallowed Method (see https://github.com/rust-lang/rust-clippy/pull/5896)
What does this lint do?
Disallows certain methods, as defined in clippy.toml

Categories (optional)

  • Kind: Nursery

Checks for method calls of specified methods
For example:

  • SomeStruct::bad_method
  • SomeTrait::bad_method

Drawbacks

This might take some significant overhead to implement (regex or some manual string parsing), and the main purpose would probably be to patch in temporary lints, so it might not be super useful.

Example

# clippy.toml

disallowed-methods = ["Foo::bar", "Baz::bar"]
...
let f = Foo::default();
f.bar();
...

results in a lint

L-lint good-first-issue

Most helpful comment

The other PR used the term 'disallowed' so maybe go with disallowed_method. I probably not the right person to answer this.

All 6 comments

Should only the usage be blacklisted or also the definition?

We were mostly looking at usage. I can pick it up too.

Apparently we don't use the term "blacklist" anymore - #5896 . Maybe choose something else if you don't want someone to come along and rename it.

Ok I vibe with that. Would banned_method be appropriate nomenclature for the future?

The other PR used the term 'disallowed' so maybe go with disallowed_method. I probably not the right person to answer this.

Many thanks! I will go with that, then.

Was this page helpful?
0 / 5 - 0 ratings