All Projects β†’ gtramontina β†’ walter.cr

gtramontina / walter.cr

Licence: MIT license
Keep your crystal clean!

Programming Languages

crystal
512 projects
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to walter.cr

triki
Mysql, PostgreSQL and SQL dump obfuscator aka anonimizer
Stars: ✭ 28 (+100%)
Mutual labels:  crystal-lang, crystal-shard
Husky.Net
Git hooks made easy with Husky.Net internal task runner! 🐢 It brings the dev-dependency concept to the .NET world!
Stars: ✭ 394 (+2714.29%)
Mutual labels:  lint, lint-staged
Sql Lint
An SQL linter
Stars: ✭ 243 (+1635.71%)
Mutual labels:  lint
lisk-template
πŸ“„ Template repository for Lisk projects
Stars: ✭ 39 (+178.57%)
Mutual labels:  lint
duplex
Duplicate code finder for Elixir
Stars: ✭ 20 (+42.86%)
Mutual labels:  lint
TypeScript-in-Nodejs-Starter
A starter kit for Node.js project written with TypeScript.
Stars: ✭ 39 (+178.57%)
Mutual labels:  lint-staged
elm-lint
elm-lint lints Elm source code, to add additional guarantees to your project.
Stars: ✭ 27 (+92.86%)
Mutual labels:  lint
Lin
Lin is an Android Lint tool made simple
Stars: ✭ 235 (+1578.57%)
Mutual labels:  lint
tallboy
Declarative API for drawing unicode/ascii character tables in crystal lang
Stars: ✭ 49 (+250%)
Mutual labels:  crystal-lang
pathvalidate
A Python library to sanitize/validate a string such as filenames/file-paths/etc.
Stars: ✭ 139 (+892.86%)
Mutual labels:  lint
crystime
Advanced time, calendar, schedule, and remind library for Crystal
Stars: ✭ 23 (+64.29%)
Mutual labels:  crystal-lang
vscode-lint
A VSCode configuration tool integrating Stylelint and Eslint
Stars: ✭ 60 (+328.57%)
Mutual labels:  lint
rpmlint
Tool for checking common errors in rpm packages
Stars: ✭ 112 (+700%)
Mutual labels:  lint
lint-checks
A set of opinionated and useful lint checks
Stars: ✭ 61 (+335.71%)
Mutual labels:  lint
Lint Rules
A set of very opinionated lint rules.
Stars: ✭ 252 (+1700%)
Mutual labels:  lint
brotli.cr
Crystal bindings to the Google brotli compression library
Stars: ✭ 20 (+42.86%)
Mutual labels:  crystal-lang
Secretlint
Pluggable linting tool to prevent committing credential.
Stars: ✭ 239 (+1607.14%)
Mutual labels:  lint
gitlab-lint
An open source gitlab linting utility
Stars: ✭ 19 (+35.71%)
Mutual labels:  lint
nano-staged
Tiny tool to run commands for modified, staged, and committed files in a GIT repository.
Stars: ✭ 347 (+2378.57%)
Mutual labels:  lint
yamburger
YAML syntax got you down? That's a YAMBURGER!
Stars: ✭ 32 (+128.57%)
Mutual labels:  lint


WALTER
KEEPING YOUR CRYSTAL CLEAN

Master build status

What

walter is a command line tool that aims to keep your crystal clean, simplifying the routine checks on staged files that are ready to be committed and help you maintain a healthy and clean codebase.

Why

From a consistency perspective, there are plenty of tools that support us on our never-ending pursue of code-cleanliness. Linters, static code analyzers, code formatters… Great! However, more often than not, our git history ends up cluttered with angry commits fixing violations detected by those tools.

One way to avoid these commits from getting into our history is to run your linters and code formatters before committing your changes. But running these tools against the entire project every time you're committing something can be slow and lead to unexpected or irrelevant results.

This tool allows you to specify a series of commands to run on staged files that match a given pattern.

Installing

Add the following entry to your shard.yml on the development_dependencies section and run shards install.

walter.cr:
  github: gtramontina/walter.cr
  version: <current-version>

shard.yml

Next, create a .walter.yml at the root of your project with the following content:

expression: \.cr$
command:
  - crystal tool format
  - git add

.walter.yml

Executing bin/walter now would run crystal tool format and git add on your staged files that match the \.cr$ regular expression. For example, if you have file1.txt, file2.cr and file3.cr, water will run, in this order:

  1. crystal tool format file2.cr
  2. git add file2.cr
  3. crystal tool format file3.cr
  4. git add file3.cr

Notice that file1.txt was not referenced, as it doesn't match the \.cr$ regular expression.

Running the commands on each individual staged file was deliberate. The idea is that it would foster a small/atomic commit mindset.

More Examples

Here's a few more configuration examples for you to draw inspiration from:

expression: \.cr$
command: bin/ameba
expression: \.png$
command:
  - pngcrush -ow
  - git add
  • All examples at once:
- expression:
    - \.cr$
  command:
    - bin/ameba
    - crystal tool format
    - git add

- expression:
    - \.png$
  command:
    - pngcrush -ow
    - git add

Tips

  • Although you can manually run bin/walter before every commit, this quickly becomes boring and quite often forgotten. You can leverage the precommit git hook. Take a look at ghooks.cr. It makes versioning your git hooks easier! Here's an example of a ghooks pre-commit hook (.githooks/pre-commit) configured to run bin/walter:
#!/usr/bin/env sh
bin/walter

.githooks/pre-commit

Help

Walter - Keeping your Crystal clean!

Usage:
  walter
  walter (-c <config> | -C <config-file>)
  walter (-h | --help | -v | --version)

Options:
  -h --help                         Show this screen.
  -v --version                      Show version.
  -c --config=<config>              Rules configuration in YAML.
  -C --config-file=<config-file>    Rules configuration file in YAML [default: .walter.yml]

$ bin/walter --help

Design Decisions

  • Every interaction with the operating system is abstracted;
  • Methods have only one output (no exceptions or nils). If needed, use the Result class;
  • Favor composition over inheritance: augment behavior by decorating existing implementations;

Contributing

Contributions of any kind are very welcome!

Developing

At the root of the project, you'll find a Makefile. This is meant to be the entry point for any build step during development. Running make help will yield you a list of existing phony targets:

make build
make clean
make format
make help
make install (default)
make lint
make test

$ make help

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].