Wflow.jl icon indicating copy to clipboard operation
Wflow.jl copied to clipboard

Enforce style guide for Julia code

Open CFBaptista opened this issue 1 year ago • 6 comments

Currently, there is no style guide for wflow's Julia code. For improved code quality a consistent style across the team is needed. The most popular style guides in the Julia community are:

  1. YAS
  2. Blue
  3. SciML

One of these should be picked, configured and enforced.

Tasks

  • [x] Add configuration file for JuliaFormatter to the git repository
  • [x] Add configuration for "format on save" to the git repository
  • [x] Format entire repository

CFBaptista avatar Jul 05 '24 09:07 CFBaptista

Probably good to check what style the Ribasim team is using and if we can also adopt that style, so this is consistent across the Product line.

verseve avatar Jul 05 '24 11:07 verseve

For JuliaFormatter we use the default style, with a few non-default options: https://github.com/Deltares/Ribasim/blob/main/.JuliaFormatter.toml

I should try SciML style JuliaFormatter again, I changed some parts I didn't like about it ;)

Though as a general style guide we go with https://docs.sciml.ai/SciMLStyle/stable/ since most our dependencies also do that, and I think it's the most actively maintained style guide.

visr avatar Jul 05 '24 12:07 visr

Okay, agreed. I am copying Ribasim's .JuliaFormatter.toml

CFBaptista avatar Jul 05 '24 12:07 CFBaptista

Wflow's and Ribasim's style guides are now in sync.

CFBaptista avatar Jul 05 '24 12:07 CFBaptista

@visr while skimming through Ribasim's repository I did not see a GitHub Action that blocks a PR if code is not properly styled. Have I missed something or do you enforce consistent styling in a different way?

CFBaptista avatar Jul 05 '24 13:07 CFBaptista

That's right. Since everyone is using the same VSCode dev environment with format on save, it's not really an issue. Perhaps later on we could use it as a pre-commit hook. For that I'd like JuliaFormatter to start a bit faster though.

visr avatar Jul 05 '24 15:07 visr