Skip to content

Commit

Permalink
Add Pre-commit Hooks and Documentation to Development Environment (#219)
Browse files Browse the repository at this point in the history
undefined
  • Loading branch information
KesharwaniArpita authored Oct 22, 2024
1 parent d2fd822 commit 9d7987c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,41 @@ git remote add upstream https://github.com/scribe-org/Scribe-Android.git
> [!NOTE]
> Feel free to contact the team in the [Android room on Matrix](https://matrix.to/#/#ScribeAndroid:matrix.org) if you're having problems getting your environment setup!
## Pre-commit Hooks [``](#contents)

Scribe-Android uses pre-commit hooks to maintain a clean and consistent codebase. These hooks help automatically check for issues such as formatting, trailing whitespace, and linting errors. Here's how to set up pre-commit for Scribe-Android:

1. Install `pre-commit` by running:

```bash
pip install pre-commit
```

2. After cloning the repository, install the hooks by running the following command in the project root:

```bash
pre-commit install
pre-commit run --all-files # to check
```

3. When you make a commit, the hooks will automatically run to check for any code quality issues. If any issues are found, they will either be fixed automatically or will need to be resolved manually.

## Testing [`⇧`](#contents)

Scribe-Android includes a testing suite that should be ran before all pull requests and subsequent commits. Please run the following in the project root:

```bash
# Run ktlint and detekt:
./gradlew lintKotlin detekt
./gradlew test
```

If you see that there are linting errors above, then please run the following command to hopefully fix them automatically:

```bash
ktlint --format
```

<a id="testing"></a>

## Testing [`⇧`](#contents)
Expand Down
21 changes: 21 additions & 0 deletions pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: local
hooks:
- id: ktlint
name: ktlint
entry: ./gradlew lintKotlin
language: system
types: [kotlin]

- id: detekt
name: detekt
entry: ./gradlew detekt
language: system
types: [kotlin]

0 comments on commit 9d7987c

Please sign in to comment.