Skip to content

Commit

Permalink
Squashed 'devtools/pip-tools/' content from commit 7e67fe675
Browse files Browse the repository at this point in the history
git-subtree-dir: devtools/pip-tools
git-subtree-split: 7e67fe675add105613e8665092db9dd09398c722
  • Loading branch information
arogge committed Apr 23, 2021
0 parents commit e471b69
Show file tree
Hide file tree
Showing 34 changed files with 1,930 additions and 0 deletions.
1 change: 1 addition & 0 deletions .check-sources-ignore
@@ -0,0 +1 @@
check_sources.egg-info/*
22 changes: 22 additions & 0 deletions Pipfile
@@ -0,0 +1,22 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
black = "*"
gitpython = "*"
cmake-format = "*"
check-sources = {editable = true, path = "."}
clang-format = "*"
importlib-resources = "*"
python-magic = "*"
enlighten = "*"

[requires]
python_version = "3"

[pipenv]
allow_prereleases = true
273 changes: 273 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions README.md
@@ -0,0 +1,49 @@
# Bareos Source Sanity Checker

This repository contains a pluggable python-based source sanity checker targeted to check all of the Bareos sources.

The program selects files in your source directory to look at based on their git status (i.e. committed, changed, untracked). For each file all the plugins will be run and will check if the file is ok and - if possible and enabled - show what needs to be changed or apply the changes automatically.

## Installation
The program was developed and tested with python 3.6, so this is the minimum required version (we cannot describe this in the Pipfile).
First of all, you need the virtualenv for the project. To install all required dependencies, just all `pipenv sync` in the top directory.
After that can run included software with symlinks pointing to the supplied `pipenv-wrapper.sh`. If you add a symlink `check-sources` from one of your binary dirs (e.g. ~/.local/bin) to that script you'll have it available in your path.
When updating, you may need to rerun `pipenv sync` up update dependencies.

### Upgrading `check-sources` or your python installation
When you upgrade the software or your python install, you should clear out the virtualenv using `pipenv --rm` and the recreate it using `pipenv sync`.

## Usage
See `check-sources --help` for current online-documentation.
By default check-sources runs all installed plugins on all changed files in the git repository it is invoked from. To also check untracked files, you can use the `--untracked` or `-u` option.
To select more files, you can run it with `--since=<commit-ref>` to check everything changed since that commit, `--since-merge` to check all files changed since the last merge commit or `--all` to just check all files (this may take a very long time)

By default all plugins will check and report if changes are required. For modifier plugins, you can also add `--modify` or `--diff` as a parameter. These will write-back the changes and/or show a diff of what needs to be changed.

While the default is to load all plugins, you can select specific plugins by using the `--plugin` option.

## Currently implemented checks/modifiers
* clang-format
* cmake-format
* python black
* trailing spaces
* trailing newlines
* dos line-endings
* missing copyright notices
* copyright notices with wrong end-year
* merge conflicts
* executables have a shebang
* python executables have a sane shebang
* check C/C++ header guards
* check/fix comments wasting space

## Extending
All plugins reside in the `plugins` package and will be autoloaded on startup. To add a new plugin, you can simply drop a new module-file in the `plugins` directory. Every plugin is registered as a checker or a modifier for one or more glob patterns. The registered function will be called with the filename and the file contents as parameters. While a checker returns `True`/`False`, a modifier needs to return the file's content as it should look like.

## TODO
* add more plugins that help improve the code and find problems
* ShellCheck
* phplint
* cmake-lint (in addition to cmake-format)
* check for C constructs we consider bad practice (e.g. "NULL")
* use "long switches" when calling binaries from shell scripts
1 change: 1 addition & 0 deletions add-copyright-header
1 change: 1 addition & 0 deletions bareos-check-sources
1 change: 1 addition & 0 deletions black
10 changes: 10 additions & 0 deletions check_sources.egg-info/PKG-INFO
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: check-sources
Version: 0.0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
7 changes: 7 additions & 0 deletions check_sources.egg-info/SOURCES.txt
@@ -0,0 +1,7 @@
README.md
setup.py
check_sources.egg-info/PKG-INFO
check_sources.egg-info/SOURCES.txt
check_sources.egg-info/dependency_links.txt
check_sources.egg-info/entry_points.txt
check_sources.egg-info/top_level.txt
1 change: 1 addition & 0 deletions check_sources.egg-info/dependency_links.txt
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions check_sources.egg-info/entry_points.txt
@@ -0,0 +1,5 @@
[console_scripts]
add-copyright-header = check_sources.add_copyright_header:main
bareos-check-sources = check_sources.__main__:main
check-sources = check_sources.__main__:main

1 change: 1 addition & 0 deletions check_sources.egg-info/top_level.txt
@@ -0,0 +1 @@

0 comments on commit e471b69

Please sign in to comment.