Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Linter Script to CMake #34

Closed
4 of 5 tasks
YellowChemistryPublishing opened this issue Apr 9, 2024 · 0 comments · Fixed by #44
Closed
4 of 5 tasks

Migrate Linter Script to CMake #34

YellowChemistryPublishing opened this issue Apr 9, 2024 · 0 comments · Fixed by #44
Assignees
Labels
enhancement New feature or request fix Something isn't working (lite)

Comments

@YellowChemistryPublishing
Copy link
Contributor

YellowChemistryPublishing commented Apr 9, 2024

To make the script cross platform and less fragile to file structure, migrate the linter to CMake.

Linting Stages

  1. Check for/insert the license header (must be able to deal with any line endings)
  2. Run clang-format
  3. Run clang-tidy

Targets

Linting of each file should be a target (as linting files is extremely slow) with a target for linting each system, common code and linting everything. To generate all the targets for a project a simple function like add_linter_targets should be created. Note that the name of the targets which lint individual files can be arbitrary.

  • format, apply stages 1 and 2
  • check_fast, run stage 1 and 2 only
  • check, run all stages

Hooks

A pre-commit hook should be created which:

  • Prints a warning that the checking may take a long time to execute (and that the --no-verify flag can be used to bypass the checks)
  • Runs check_all

The hook should return a non-zero exit code if the linting fails (this is so that the commit will be aborted). Although I would prefer a two line shell script, if you want to make it cross platform you may be forced to use Python instead.

To allow the hook to be put into our repo it should be located in the utils/git-hooks directory. A line to the README should instruct users to run git config --local core.hooksPath utils/git-hooks/ to enable our hooks.

Checkpoints

  • All targets exist (but currently no-ops), created with add_linter_targets function
  • Stage 2 (clang-format, run and apply)
  • Stage 3 (clang-tidy, run)
  • Stage 1(license header check, run and apply)
  • Git hooks
@YellowChemistryPublishing YellowChemistryPublishing added enhancement New feature or request help wanted Extra attention is needed fix Something isn't working (lite) labels Apr 9, 2024
@EvanLF6768 EvanLF6768 changed the title Fix ./utils/linter.sh script. Migrate Linter Script to CMake May 5, 2024
@EvanLF6768 EvanLF6768 removed the help wanted Extra attention is needed label May 5, 2024
@YellowChemistryPublishing YellowChemistryPublishing linked a pull request Jun 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix Something isn't working (lite)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants