Skip to content

Commit

Permalink
Add commands to apply and check codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Aug 1, 2023
1 parent ce684fa commit dd22b2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
uses: coursier/cache-action@v6

- name: Code style check and binary-compatibility check
# Run locally with: sbt 'verifyCodeFmt; mimaReportBinaryIssues'
run: sbt "verifyCodeFmt; mimaReportBinaryIssues"
# Run locally with: sbt 'javafmtCheckAll; mimaReportBinaryIssues'
run: sbt "javafmtCheckAll; mimaReportBinaryIssues"

check-code-compilation:
name: Check Code Compilation
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ Example:
* Details 2
* Details 3

## Applying code style to the project

The project uses [scalafmt](https://scalameta.org/scalafmt/) to ensure code quality which is automatically checked on
every PR. If you would like to check for any potential code style problems locally you can run `sbt checkCodeStyle`
and if you want to apply the code style then you can run `sbt applyCodeStyle`.

### Ignoring formatting commits in git blame

Throughout the history of the codebase various formatting commits have been applied as the scalafmt style has evolved over time, if desired
Expand Down
8 changes: 2 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ commands := commands.value.filterNot { command =>
ThisBuild / reproducibleBuildsCheckResolver :=
"Apache Pekko Staging".at("https://repository.apache.org/content/groups/staging/")

TaskKey[Unit]("verifyCodeFmt") := {
javafmtCheckAll.all(ScopeFilter(inAnyProject)).result.value.toEither.left.foreach { _ =>
throw new MessageOnlyException(
"Unformatted Java code found. Please run 'javafmtAll' and commit the reformatted code")
}
}
addCommandAlias("verifyCodeStyle", "scalafmtCheckAll; scalafmtSbtCheck; headerCheckAll; javafmtCheckAll")
addCommandAlias("applyCodeStyle", "headerCreateAll; scalafmtAll; scalafmtSbt; javafmtAll")

addCommandAlias("verifyDocs", ";+doc ;unidoc ;docs/paradoxBrowse")

Expand Down

0 comments on commit dd22b2e

Please sign in to comment.