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
cocoaand 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 pullbefore running this code. - This will get branch information for all branches.
- This will only run the analysis (
pyflakeson python files) for the code in the current branch. So if you run this while your current branch ismainit will run onmain.
Options
Results are truncated by default. To print all results, use the verbose option:
cocoa /path/to/repo --verbose
Cocoa evaluates the main branch by default. To evaluate a different branch, use the branch argument:
cocoa /path/to/repo --branch branch-name
If files modified/created only after a certain date are to be evaluated then use the date option:
cocoa /path/to/repo --date YYYY-MM-DD
Note: Please add date string in YYYY-MM-DD format.
All options can be combined like so:
cocoa /path/to/repo --lint --verbose --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
There is a Github action located here that runs cocoa on pushes to the main branch. The action has an associated badge that can be displayed at the top of your repo to show passing or failing status. The badge code can be copied from the raw text of this readme.
To override the --date or --branch options run in the action, create an environment named "cocoa_standards" in your repository, then create environment variables called BRANCH_NAME and REVIEW_AFTER_DATE.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsi_cocoa-0.0.0.tar.gz.
File metadata
- Download URL: dsi_cocoa-0.0.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f164ac89d4b4c7b13bc0208ca7f8c5fd89485609fb6cff9f1b81e2e069d2715
|
|
| MD5 |
cd230d5926798d82bb62e57e60bebecd
|
|
| BLAKE2b-256 |
ddaeece9d25df5d35b28850d2bf5e26faf71e534756e1426609e39f0c7963242
|
File details
Details for the file dsi_cocoa-0.0.0-py3-none-any.whl.
File metadata
- Download URL: dsi_cocoa-0.0.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bb73b4032e17d4008fbca5854fdcedee3927dc8050b0bcec7f49519ef1d60b5
|
|
| MD5 |
58ecda06ab1353a97103bb00cf6b99ad
|
|
| BLAKE2b-256 |
91e167df9b131211cd12ac13098b6363cfcc6e3315732547ccbba148a526c5ec
|