kafka icon indicating copy to clipboard operation
kafka copied to clipboard

MINOR; Use underscore for variable initialization in BrokerServer

Open mdedetrich opened this issue 2 years ago • 2 comments

In Scala its standard practice to use _ whenever you are initializing variables. In regards to implementation, for object references _ initialization maps to null so there is no chance in behaviour.

Committer Checklist (excluded from commit message)

  • [ ] Verify design and implementation
  • [ ] Verify test coverage and CI build status
  • [ ] Verify documentation (including upgrade notes)

mdedetrich avatar Aug 02 '22 08:08 mdedetrich

Thank you for the review. Looks good. One question though (which does not have to be addressed part of this PR), do we have a linter for scala that can enforce such best practices?

divijvaidya avatar Aug 02 '22 11:08 divijvaidya

Yes there is, its called scalafix, would just have to integrate it into gradle. There is also scalafmt which works on the context free grammar linting fixes, I noticed there is a configuration for this already in Kafka but for some reason Gradle build doesn't use it (or at least it doesn't fail if there is a formatting error).

mdedetrich avatar Aug 02 '22 11:08 mdedetrich