{"id":20768182,"url":"https://github.com/softwaremill/scala-pre-commit-hooks","last_synced_at":"2025-04-30T11:23:51.044Z","repository":{"id":53103636,"uuid":"230505893","full_name":"softwaremill/scala-pre-commit-hooks","owner":"softwaremill","description":"Pre-commit/Pre-push hooks for Scala","archived":false,"fork":false,"pushed_at":"2025-03-21T14:18:56.000Z","size":21,"stargazers_count":35,"open_issues_count":8,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T15:46:59.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softwaremill.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-27T19:32:14.000Z","updated_at":"2025-03-21T14:19:01.000Z","dependencies_parsed_at":"2023-01-19T15:30:48.256Z","dependency_job_id":null,"html_url":"https://github.com/softwaremill/scala-pre-commit-hooks","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fscala-pre-commit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fscala-pre-commit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fscala-pre-commit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softwaremill%2Fscala-pre-commit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softwaremill","download_url":"https://codeload.github.com/softwaremill/scala-pre-commit-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251689235,"owners_count":21627870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T11:36:18.102Z","updated_at":"2025-04-30T11:23:51.016Z","avatar_url":"https://github.com/softwaremill.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Pre-commit/Pre-push hooks for Scala\n:repoRoot: https://github.com/softwaremill/scala-pre-commit-hooks\n:repoMaster: {repoRoot}/blob/master\n:defaultScope: test:compile\n:currentVersion: v0.3.0\n\n== What for?\n\nTo make your code go smoother while still maintaining high code quality.\n\n== Why?\n\nScala has a quite rich build ecosystem, and a myriad of tools to help you writ good code. However, the build system(s) are relatively slow, so any helpers executed via those build system run the risk of interrupting the flow of a developer.\n\nMoreover, some of the code quality tools/features (like unused import checks) are actively in opposition to a \"run-often\" coding approach.\n\nMoving relevant checks to the pre-commit/pre-push phases partially alleviates those two issues.\n\n== How?\n\nThis is a set of hooks defined in the excellent https://pre-commit.com/[pre-commit] library.\n\nCurrently, they include the following:\n\n- `sbt-fatal-warnings` - turns on `-Xfatal-warnings`, runs a clean compilation on the given scope.\n- `sbt-unused-imports` - as above, but also adds the \"unused imports\" warning.\n- `sbt-scalafmt` - runs `scalafmtCheckAll`.\n- `sbt-wartremover` - runs the wartremover plugin.\n- `sbt-scalafmt-apply` - runs `scalafmtAll`, as sbt-scalafmt but also applies reformatting to changed files.\n\nTo add one or more of the hooks into your repo:\n\n. Have everyone on your team install https://pre-commit.com/#install[pre-commit].\n. Add a `.pre-commit-config.yaml` file to your repository, with the following syntax:\n+\n[source,yaml, subs=\"attributes\"]\n..pre-commit-config.yaml\n----\nrepos:\n-   repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: {currentVersion}\n    default_phase: push #change to commit if desired\n    hooks: #mix and match any of the following:\n    -   id: sbt-fatal-warnings #arguments optional\n        args: [--scope={defaultScope}]\n    -   id: sbt-unused-imports #includes fatal warnings, arguments optional\n        args: [--scope={defaultScope}]\n    -   id: sbt-scalafmt\n    -   id: sbt-scalafmt-apply\n    -   id: sbt-wartremover #arguments are optional\n        args: [--warts=Warts.unsafe, --scope={defaultScope}]\n----\n+\n. Run `pre-commit install` to apply your hooks to the repo.\n\n[NOTE]\n--\nAll hooks except for `sbt-scalafmt` and `sbt-scalafmt-apply` have the optional `scope` argument, which allows to define what source scopes\nare relevant for the hook's check. The default is `{defaultScope}`.\n--\n\n[IMPORTANT]\n--\nSteps 1-2 are only really required for the person setting up the _pre-commit library_ integration. _pre-commit library_ plugins, once installed, are normal Git hooks and are thus \"visible\" to everyone using the repo.\n--\n\n== How to control hook run time\n\nBy default, the hooks defined here run on *both* pre-commit and pre-push. They do, however, require some time to get running\non large codebases, especially since each hook's execution is essentially a clean build.\n\nTo limit hook runs to e.g. `pre-push`, you need to add a `stages` argument with the relevant value:\n\n[source,yaml, subs=\"attributes\"]\n..pre-commit-config.yaml\n----\nrepos:\n-   repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: {currentVersion}\n    hooks:\n    -   id: sbt-fatal-warnings\n        stages: [push] #or [commit, push] etc.\n----\n\n== I want more hooks/found a problem!\n\nThanks for noticing that! Please create an {repoRoot}/issues[issue].\n\n== I want to add a hook!\n\nExcellent, please create a PR. See {repoMaster}/CONTRIBUTING.adoc[the contribution guide] for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fscala-pre-commit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftwaremill%2Fscala-pre-commit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftwaremill%2Fscala-pre-commit-hooks/lists"}