ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.87k stars 907 forks source link

Perform basic conventional checks in Git pre-commit hook #7765

Open s373nZ opened 1 month ago

s373nZ commented 1 month ago

Following from this conversation on Discord, @cdecker writes:

Sure, there are plenty of pre-commit plugins for that type of lint. A quick search surfaced https://github.com/compilerla/conventional-pre-commit for example. I also wonder if we should remove some of our custom tooling in favor of better maintained conventional tools (shellcheck run, JSON schema format check, JSON schema validation, check that files were regenerated when needed, etc. currently there are loads of make targets that just check something in ci, when really we want to enforce them for new code. The upside would be that we check during commit, but the same rules can just be double checked in ci from the same config.

This issue represents the beginning of an initiative to improve standardization and offload some of the CI checks into the developer workflow, starting with the following brainstorm:

cdecker commented 5 days ago

I added a first draft formatting the python files here: https://github.com/ElementsProject/lightning/pull/7884

It took me a bit of time to figure out how to avoid an all-or-nothing formatting change, and luckily I found --from-ref and --to-ref which we can use to limit to just the PRs changed files. So we incrementally fix things up as we edit files.

More lints and checks welcome ^^