Skip to content

Commit

Permalink
Merge pull request #127 from supermetrics-public/feature/code-fmt-mak…
Browse files Browse the repository at this point in the history
…e-targets

Add scripts and docs for code quality tooling
  • Loading branch information
crocodele committed Jul 12, 2021
2 parents 3e82099 + 1a201ed commit 988915b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Makefile.frag
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
format_files=jsonpath.c \
php_jsonpath.h \
src/jsonpath/*.{c,h} \

findphp:
@echo $(PHP_EXECUTABLE)

format-check:
@clang-format --dry-run -Werror $(format_files)

format-code:
@clang-format -i $(format_files)

lint-code:
@cppcheck --enable=all --error-exitcode=1 --std=c89 --suppress=missingInclude $(format_files)

setup-pre-commit:
@ln -s ../../pre-commit .git/hooks

26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,32 @@ $ make lcov

You can then find a coverage report in the `lcov_html/` directory.

## Code Quality Tooling

Please run the code formatter and linter (and fix any issues reported by the linter) before filing a pull request.

You may check the code format and linter automatically before committing by setting up a pre-commit hook:

```bash
make setup-pre-commit
```

### Formatting

Code formatting requires [clang-format](https://clang.llvm.org/docs/index.html).

```bash
make format-code
```

### Linting

Linting requires [cppcheck](http://cppcheck.sourceforge.net/).

```bash
make lint-code
```

## Contributors

JsonPath-PHP is created by [Mike Kaminski](https://github.com/mkaminski1988) and maintained by
Expand Down
3 changes: 3 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

make format-check lint-code

0 comments on commit 988915b

Please sign in to comment.