Aiven-Open / klaw

Klaw, the latest OS tool by Aiven, helps enterprises cope with Apache Kafka(r) topics, schema registry and connectors governance by introducing roles/authorizations to users of various teams of an org.
https://www.klaw-project.io/
Apache License 2.0
150 stars 60 forks source link

Add Static Code Analyzers and Style Checkers for the Java parts #264

Open jlprat opened 1 year ago

jlprat commented 1 year ago

What is currently missing?

There are different ways to write Java (curly braces on same line vs newline, naming conventions), we should programatically decide on the way the project should be written. Additionally, there are several known bug prone code patterns that we can automatically check and prevent before committing, making our code more secure and in turn reviews are easier to perform.

How could this be improved?

Last time I worked on Java only codebases there was a triad of plugins to use:

First, decide on which tools to use (I propose the 3 mentioned above) and configure them with the proper defaults

Is this a feature you would work on yourself?

snuyanzin commented 1 year ago

Spotless (I understand is a better alternative to Checkstyle)

it is already enabled here https://github.com/aiven/klaw/blob/f6564513a9fad919485dd16bf6c3f91126634f9c/pom.xml#L190-L211

jlprat commented 1 year ago

Ah yes, Spotless is enabled right. We might want to check if we want to do add extra stylistic rule

sekaiser commented 1 year ago

PMD is a nice tool although you can waste a lot of time until you settle on a configuration that not only works for you but is also not too pedantic in some situations.

In some of my projects I have had good experience with moving this kind of configuration into its own dependency. Then projects that want to use this configuration only need to customize the maven plugin a bit. I believe this is a reasonable approach when trying to achieve some standardization among similar projects. Maybe this is something you want to consider as well, given that you probably have a couple of projects in the organization.

Maybe this sample provides some value, though I would replace Checkstyle with Spotless these days (which you use already): https://github.com/sekaiser/build-tools-sample