Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Lint: blacklisted_method #6073

Closed
ilknarf opened this issue Sep 21, 2020 · 6 comments · Fixed by #6081
Closed

New Lint: blacklisted_method #6073

ilknarf opened this issue Sep 21, 2020 · 6 comments · Fixed by #6081
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy

Comments

@ilknarf
Copy link
Contributor

ilknarf commented Sep 21, 2020

What it does

Blacklist Method Disallowed Method (see #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

@flip1995
Copy link
Member

Should only the usage be blacklisted or also the definition?

@flip1995 flip1995 added the good-first-issue These issues are a good way to get started with Clippy label Sep 22, 2020
@ilknarf
Copy link
Contributor Author

ilknarf commented Sep 22, 2020

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

@ghost
Copy link

ghost commented Sep 22, 2020

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.

@ilknarf
Copy link
Contributor Author

ilknarf commented Sep 22, 2020

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

@ghost
Copy link

ghost commented Sep 22, 2020

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

@ilknarf
Copy link
Contributor Author

ilknarf commented Sep 22, 2020

Many thanks! I will go with that, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants