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

resolves #6 #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
pass_filenames: false
always_run: true
minimum_pre_commit_version: '0.19.0'
- id: sbt-scalafix
name: scalafix linting check
stages: [commit,push]
language: python_venv
entry: scalafix
pass_filenames: false
always_run: true
minimum_pre_commit_version: '0.3.1'
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To add one or more of the hooks into your repo:
..pre-commit-config.yaml
----
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/softwaremill/scala-pre-commit-hooks
rev: {currentVersion}
default_phase: push #change to commit if desired
hooks: #mix and match any of the following:
Expand Down Expand Up @@ -73,7 +73,7 @@ To limit hook runs to e.g. `pre-push`, you need to add a `stages` argument with
..pre-commit-config.yaml
----
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/softwaremill/scala-pre-commit-hooks
rev: {currentVersion}
hooks:
- id: sbt-fatal-warnings
Expand Down
16 changes: 16 additions & 0 deletions pre_commit_hooks/scalafix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pre_commit_hooks.runner import run_sbt_command
from colorama import init as colorama_init, Fore

TASK_SCALAFIX = 'scalafixAll --check'
MISSING_PLUGIN_CHECK_STRING = 'Not a valid key: scalafixAll'
MISSING_PLUGIN_ERROR_MSG = f'{Fore.RED}ERROR: scalafix SBT plugin not present! See {Fore.BLUE}https://scalacenter.github.io/scalafix/docs/users/installation.html{Fore.RED} for installation instructions.'


def main(argv=None):
colorama_init()

return run_sbt_command(f'; clean ; {TASK_SCALAFIX}', MISSING_PLUGIN_CHECK_STRING, MISSING_PLUGIN_ERROR_MSG)


if __name__ == '__main__':
exit(main())