Giter Club home page Giter Club logo

foul-mouth-slap's Introduction

foul-mouth-slap

FOSSA Status

Script to check the diff content of files in output of git status for foul words, variants of those words and repeated chars.
Will not work on Windhose.

What in the seven hells is this and why would I need it?

Personally, I don't like to mess around with git history, so I try to keep the project history as readable and clean as I can.
Now, I'm also someone who likes to use the same non-sensical words to test stuff or during quick implementations:
make it work, make it right, make it fast.
The problem is I don't always catch everything before committing stuff when I make it right.

This is me accepting I have bad habits, and working around them.
So what if I write let dink = '';?
The hook will catch this and make me aware of it, giving me the option to either stop the commit or to go ahead and push it into the repository's history.
Now I can at least be aware when commiting sinful (oh so sinful) things into the repo's history.

Install

  1. Install requirements.txt
pip install -r requirements.txt
  1. Copy config.toml.default to config.toml and assets/violations.toml.default to assets/violations.toml.
  2. Create pre-commit hook somewhere you can easily access
mkdir -p ~/.git-templates/hooks
vim ~/.git-templates/hooks/pre-commit
  1. Call the script from inside the hook
#!/bin/sh

# Add other pre-commit hooks 
python /PATH/TO/slapper.py
  1. Make hook executable
chmod u+x ~/.git-templates/hooks/pre-commit
  1. Set global rule in git to call this on commit in every repository Reminder: You could also set this per repository
git config --global core.hooksPath ~/.git-templates/hooks/

Adding custom rules

The rules for all will be used as baseline.
Different (basic regex) patterns/words can be added to specific file extension identifiers, to overwrite the eventual result.
foul sections will be appended, while acceptable sections will omit existing checks.

Example: Given the following structure:

[all]
  [all.foul]
    words = [
      "dink",
      "poop",
    ]
[css]
  [css.foul]
    words = ["test"]
  [css.acceptable]
    words = ["poop"]

The resulting foul_words will be dink, test.
The same applies to patterns.

Testing

Tests are located in slapper/tests and require the py.test module.

Optional: Create a virtual environment to test.

python -m virtualenv .venv
source .venv/bin/activate

Install pytest

pip install pytest

Navigate to the slapper directory and run the tests.

python -m pytest -v

Smile as you watch the tests pass.

License

FOSSA Status

foul-mouth-slap's People

Contributors

bramver avatar fossabot avatar mattydebie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.