-
Hello, I would like to ban certain library functions (which are deemed unsafe or non-performant by our tech lead) from the codebase. Is this possible to do with detekt? Basically, a user provided list of functions (full qualified names) which would produce a warning if used. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You have forbidden import and forbidden method (or function, I'm not sure) rules for those use cases. |
Beta Was this translation helpful? Give feedback.
-
As mentioned by @BraisGabin you can use ForbiddenMethodCall:
active: true
methods: ['kotlin.io.println', 'kotlin.io.print', 'your.library.function'] |
Beta Was this translation helpful? Give feedback.
-
Amazing, thank you! Just one additional question, does it work for fields? For example, |
Beta Was this translation helpful? Give feedback.
-
🤔 Not directly I think. You could use |
Beta Was this translation helpful? Give feedback.
As mentioned by @BraisGabin you can use
ForbiddenMethodCall
: