We use SonarQube to analyse a number of Java, Kotlin, Python and C++ projects. Recently we have found that a particular Kotlin library offers much better performance (100x) over two others that perform a similar job. Within our codebase, we would like to encourage the use of library A in preference to library B or C.
Is there an existing rule or plugin to check for library imports in a project and offer a given set of alternatives?
I expect we would need to add a case-by-case rule for each instance so that we can easily say;
“Library B should be replaced with Library A if possible”,
“Library C should be replaced with Library A if possible” and so on.
I mention our use of several languages as I expect this problem is universal, so using SonarQube as a single central tools for quality would be easier than setting up separate tools per language. In the current case we are talking about Third-Party library use but I expect this could be extended to in-house authored libraries too.