Clinic Opinionated Codebase Oversight and Analysis
Project description
Clinic Opinionated Codebase Oversight and Analysis
This repository was developed in order to generate automated reports on how well codebases adhere to the coding standards of the University of Chicago's DSI Clinic course.
The goals of this codebase is to provide a quick and easy way to review code and to alert contributors where their code may be failing.
Installation
pip install dsi-cocoa
To install the package locally, run the following command from the root of the repository:
python3 -m pip install .
cocoa
This package contains a module evaluate_repo
which runs code testing libraries against a repository. There are multiple ways that we want to be able to run this repo:
- We want to be able to clone
cocoa
and then use it as part of their process. - We want administrators to be able to give it a list of repos to generate reports on all repos.
- (Eventually) We want it to be able to run as a github action on the repo itself.
- (Eventually) We want to be able to have adminstrative repo that can run it on other repos.
How to run
Via command line:
cocoa /path/to/repo
As a python script:
python3 src/cocoa/evaluate_repo.py /path/to/repo
As a Python module:
from cocoa.evaluate_repo import evaluate_repo
evaluate_repo('/path/to/repo', False)
A few important notes:
- Make sure to
git pull
before running this code. - This will get branch information for all branches.
- This will only run the analysis (
pyflakes
on python files) for the code in the current branch. So if you run this while your current branch ismain
it will run onmain
.
Options
If you want to turn on linting, add the argument "--lint":
cocoa /path/to/repo --lint
Results are truncated by default. To print all results, use the verbose option:
cocoa /path/to/repo --verbose
To report remote branch information, use the --branchinfo
option.
To run cocoa on files changed after a certain date, use the --date
option with a date formatted as below.
cocoa /path/to/repo --date YYYY-MM-DD
Checks
The code run multiple checks on each repo. For each check run there are three possibilities:
- WARNING: Most likely this needs to be fixed.
- INFO: Log information for additional context.
- ERROR: A critical issue that needs to be addressed.
For each of the checks below we have denoted what the check generates.
- Branch Hygiene:
- [WARNING] Branch names
- [INFO] Commit information for live branches.
- File Hygiene:
- [ERROR] Unnecessary and cache file (such as .DS_Store or pycache files)
- Notebook Files (*.ipynb):
- [ERROR] Cells per notebook < 10, lines per cell < 15 and 0 functions defined
- [ERROR] Linting: PyLint, Black, Flake and iSort
- Python Files
- [ERROR] All Code in Functions
- [ERROR] All functions have docstrings
- [ERROR] Code uses off-limit libraries (subprocess)
- [ERROR] Linting: PyLint, Black, Flake and iSort
Github actions
For each of the ERRORS and WARNINGS above there is an associated github action that can be run to create a badge which we put in a table at the top of each clinic repo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dsi_cocoa-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37f3aa6cc3b9a5ae904c0c2e1f18cc2c5e315d9c306627dd87e495c4bae95fa |
|
MD5 | af98f1f767bd962fe2e725e1a47c846f |
|
BLAKE2b-256 | c7366cd59955a152a7659a4dc7039929316d739ccf6041629e2f62146f5f299f |