Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/birkenfeld/gitcodesmell
Git hook checking for "smelly" changes in files (debugging leftovers, merge markers etc.) before committing
https://github.com/birkenfeld/gitcodesmell
Last synced: 3 days ago
JSON representation
Git hook checking for "smelly" changes in files (debugging leftovers, merge markers etc.) before committing
- Host: GitHub
- URL: https://github.com/birkenfeld/gitcodesmell
- Owner: birkenfeld
- License: gpl-2.0
- Created: 2015-01-22T07:50:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-12T16:17:59.000Z (over 4 years ago)
- Last Synced: 2024-10-10T16:09:43.074Z (24 days ago)
- Language: Python
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - gitcodesmell - Git hook checking for "smelly" changes in files (debugging leftovers, merge markers etc.) before committing (Python)
README
Git codesmell hook
==================This hook should be used as/during ``pre-commit``. It checks added lines
for common "smelly" changes. If it finds any, it will show them and prompt
whether to continue committing.Smelly patterns that are currently recognized are:
* vim "quit" commands that leak into the file because of wrong mode
* merge conflict markers (``<<<<<<<`` and ``>>>>>>>``)
* Windows newlines (only on non-Windows platforms)Language-specific (Python):
* ``pdb.set_trace()``
* ``1/0``
* ``print`` statements
(This is going to produce false positives, but print statements
are also the debugging tool #1 for Python)
* bare ``raise`` statements
* ``traceback.print_*`` callsLanguage-specific (JavaScript):
* ``debugger;`` statements inside of Javascript files
You can add more of them by editing gitcodesmell.py's ``SMELLY_STUFF``
dictionary.Example output::
git-[master] gbr@georg ~/devel/gitcodesmell> git commit
Smelly change (set_trace):diff --git a/gitcodesmell.py b/gitcodesmell.py
index b40559d..8629850 100755
--- a/gitcodesmell.py
@@ -64,6 +64,7 @@ def write_colored(diff):
def main():
smelly_count = 0
chunklines = os.popen('git diff --staged').readlines()
+ import pdb; pdb.set_trace()
indexline = 0
hunkstart = 0
Found 1 smelly change. Continue (y/N)?This hook is copyright 2015 by Georg Brandl, and can be
distributed under the GNU GPL version 2 or later.