• Stars
    star
    1,182
  • Rank 38,218 (Top 0.8 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python application for tracking, reporting on timing and complexity in Python code

wily

A command-line application for tracking, reporting on complexity of Python tests and applications.

Wily codecov Documentation Status PyPI version Conda Version black

wily [a]:
quick to think of things, having a very good understanding of situations and possibilities, 
and often willing to use tricks to achieve an aim.

Wily uses git to go through each revision (commit) in a branch and run complexity and code-analysis metrics over the code. You can use this to limit your code or report on trends for complexity, length etc.

Installation

Wily can be installed via pip from Python 3.6 and above:

 $ pip install wily

Alternatively, Wily packages are available on conda-forge:

 $ conda install -c conda-forge wily

Usage

See the Documentation Site for full usage guides.

Wily can be used via a command line interface, wily.

 $ wily --help

help-screen

Demo

Here is a demo of wily analysing a Python project, giving a summary of changes to complexity in the last 10 commits and then showing changes against a specific git revision:

demo

Using Wily in a CI/CD pipeline

Wily can be used in a CI/CD workflow to compare the complexity of the current files against a particular revision.

By default, wily will compare against the previous revision (for a git-pre-commit hook) but you can also give a Git ref, for example HEAD^1 is the commit before the HEAD reference.

 $ wily build src/
 $ wily diff src/ -r HEAD^1

Or, to compare against

 $ wily build src/
 $ wily diff src/ -r master

pre-commit plugin

You can install wily as a pre-commit plugin by adding the following to .pre-commit-config.yaml

repos:
-   repo: local
    hooks:
    -   id: wily
        name: wily
        entry: wily diff
        verbose: true
        language: python
        additional_dependencies: [wily]

Command line usage

wily build

The first step to using wily is to build a wily cache with the statistics of your project.

Usage: __main__.py build [OPTIONS] [TARGETS]...

  Build the wily cache

Options:
  -n, --max-revisions INTEGER  The maximum number of historical commits to
                               archive
  -o, --operators TEXT         List of operators, separated by commas
  --help                       Show this message and exit.

By default, wily will assume your project folder is a git directory. Wily will not build a cache if the working copy is dirty (has changed files not committed).

 $ wily build src/

Limit the number of revisions (defaults to 50).

wily-build

wily report

Show a specific metric for a given file, requires that .wily/ exists

wily report will print the metric and the delta between each revision.

wily-report

wily rank

Show the ranking for all files in a directory or a single file based on the metric provided, requires that .wily/ exists

wily rank will print a table of files and their metric values.

wily-rank

wily graph

Similar to wily report but instead of printing in the console, wily will print a graph in a browser.

wily-graph

wily index

Show information about the build directory. Requires that .wily/ exists.

wily index will print the configuration to the screen and list all revisions that have been analysed and the operators used.

wily-graph

wily list-metrics

List the metrics available in the Wily operators. Each one of the metrics can be used in wily graph and wily report

 $ wily list-metrics
mccabe operator:
No metrics available
raw operator:
╒═════════════════╀══════════════════════╀═══════════════╀══════════════════════════╕
β”‚                 β”‚ Name                 β”‚ Description   β”‚ Type                     β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•ͺ══════════════════════β•ͺ═══════════════β•ͺ══════════════════════════║
β”‚ loc             β”‚ Lines of Code        β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ lloc            β”‚ L Lines of Code      β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ sloc            β”‚ S Lines of Code      β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ comments        β”‚ Multi-line comments  β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ multi           β”‚ Multi lines          β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ blank           β”‚ blank lines          β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ single_comments β”‚ Single comment lines β”‚ <class 'int'> β”‚ MetricType.Informational β”‚
β•˜β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›
cyclomatic operator:
No metrics available
maintainability operator:
╒══════╀═════════════════════════╀═════════════════╀══════════════════════════╕
β”‚      β”‚ Name                    β”‚ Description     β”‚ Type                     β”‚
β•žβ•β•β•β•β•β•β•ͺ═════════════════════════β•ͺ═════════════════β•ͺ══════════════════════════║
β”‚ rank β”‚ Maintainability Ranking β”‚ <class 'str'>   β”‚ MetricType.Informational β”‚
β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ mi   β”‚ Maintainability Index   β”‚ <class 'float'> β”‚ MetricType.AimLow        β”‚
β•˜β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›

Configuration

You can put a wily.cfg file in your project directory and wily will override the runtime settings. Here are the available options:

[wily]
# list of operators, choose from cyclomatic, maintainability, mccabe and raw
operators = cyclomatic,raw
# archiver to use, defaults to git
archiver = git
# path to analyse, defaults to .
path = /path/to/target
# max revisions to archive, defaults to 50
max_revisions = 20

You can also override the path to the configuration with the --config flag on the command-line.

IPython/Jupyter Notebooks

Wily will detect and scan all Python code in .ipynb files automatically.

You can disable this behaviour if you require by setting ipynb_support = false in the configuration. You can also disable the behaviour of reporting on individual cells by setting ipynb_cells = false.

Credits

Contributors

  • @wcooley (Wil Cooley)
  • @DahlitzFlorian (Florian Dahlitz)
  • @alegonz
  • @DanielChabrowski
  • @jwattier
  • @skarzi

"cute animal doing dabbing" Designed by Freepik

More Repositories

1

vscode-pets

Adds playful pets πŸ¦€πŸ±πŸΆ in your VS Code window
TypeScript
1,553
star
2

mocker

A Docker-type runtime, written in 100% Python
Python
794
star
3

perflint

Python Linter for performance anti patterns
Python
582
star
4

pycharm-security

Finds security holes in your Python projects from PyCharm and GitHub
Kotlin
312
star
5

cpython-book-samples

Sample scripts and examples for my CPython Internals book
Python
180
star
6

anti-patterns

Python
137
star
7

instaviz

Instant visualization of Python AST and Code Objects
JavaScript
107
star
8

rich-bench

A little benchmarking tool for Python
Python
100
star
9

retox

For running a local continuous testing environment with tox
Python
76
star
10

ants-azure-demos

Collection of PoCs and Azure Demos
Python
49
star
11

python-assembly-poc

Python
46
star
12

requests-staticmock

A test utility for mocking out requests host from a fixtures directory
Python
42
star
13

django-xss-fuzzer

An XSS fuzzer for Django
Python
38
star
14

workday

A Python client for workday.com
Python
37
star
15

azure-pipelines-python-examples

Example configurations for Azure Build Pipelines for Python
Python
36
star
16

hathi

A dictionary attack tool for PostgreSQL and MSSQL
Python
33
star
17

pep-explorer

An easy to use online explorer for Python Enhancement Proposals
HTML
33
star
18

notations

Estimating Big-O notations for a given function in Python
Python
24
star
19

django-on-azure

Resources for my Django on Azure workshop at PyCon US 2021
CSS
19
star
20

ServiceNowHackathon2016

Sydney Hackathon with ServiceNow March 2016- Slack and ServiceNow
JavaScript
19
star
21

tonybaloney.github.io

HTML
19
star
22

wntf

An anti-recommendation algorithm for twitter
Python
17
star
23

pyucwa

Python client for the Skype for Business (Lync) UCWA 2.0 API
Python
17
star
24

django-on-azure-demo

Tutorial for running Django on Azure
Python
16
star
25

dependabot-bot

Python
15
star
26

sciencelogic

A ScienceLogic EM7 API client for Python
Python
15
star
27

hubot-spark

A hubot integration for Cisco Spark
CoffeeScript
14
star
28

readysalted

An Internet of Things toolkit for SaltStack
C++
14
star
29

dissy

A TUI disassembler
Python
14
star
30

pyinline

Python
13
star
31

St2Client

A StackStorm API client for C#.NET including a PowerShell module
C#
13
star
32

python-railroads

A script to generate railroad diagrams for Python grammar
Python
13
star
33

tonybaloney

12
star
34

netimages

tool for sniffing images over HTTP traffic and showing them on the console. Designed for remote shells.
Python
12
star
35

bad-security-practices

Python
11
star
36

performance_testing

Results from a performance test for Python runtimes
HTML
9
star
37

try-pyjion

JavaScript
8
star
38

confluence-to-powerpoint

Python
8
star
39

generic_demos

Python
7
star
40

python-3.11-demos

Python
6
star
41

libcloud.extra

Some extra packs and examples for libcloud integration with StackStorm
Python
6
star
42

python-task-provider

TypeScript
5
star
43

pluralsight

Python
5
star
44

wily-pycharm

Code Complexity Plugin for PyCharm and IntelliJ-based IDEs
Kotlin
4
star
45

markdownlint-rule-titlecase

Custom title case rule for markdownlint headers
JavaScript
4
star
46

multicloud

Python
4
star
47

pyrower

A Python Rowing Machine
Python
3
star
48

django-cosmos

A Cosmos DB driver for Django
Python
3
star
49

vs-test-detail

An NUnit extension for Azure DevOps
TypeScript
3
star
50

Cloud-auto-scaling

Provides auto-scaling capabilities to a group of Virtual Servers via SNMP, currently works with Abiquo
PHP
3
star
51

python-for-csharp-java-devs

2
star
52

pywinexe

Python bindings for winexe
Python
2
star
53

rightscale-agent-libcloud

Python
2
star
54

pathgather

Python client for Pathgather API
Python
2
star
55

pyjion-home

The website for www.trypyjion.com
CSS
2
star
56

tox-nuitka

A tox plugin for executing via nuitka
Python
2
star
57

cpython-clion-demo

Demo of debugging CPython from CLion
C
2
star
58

simple-flask-azd

A tiny template for Azure Developer CLI with Flask running in App Service
Bicep
1
star
59

PHPVarnish

PHP Class for Varnish Management CLI
PHP
1
star
60

email-toolbox

Python
1
star
61

panic_room

Python
1
star
62

hubot-servicenow

JavaScript
1
star
63

pysaba

Python
1
star
64

cisco-spark-async-bot

A Python Asynchronous Bot for Cisco Spark API
Python
1
star
65

ants-vscode-session

Jupyter Notebook
1
star
66

Abiquo-Backup

Backup Virtual Machines in an Abiquo Cloud
PHP
1
star
67

cognitive-kitchen-sink

SCSS
1
star
68

No-More-Spreadsheets

A web based service catalogue and pricing tool for products and services.
ASP
1
star
69

pycharm-webinar

Demo project for PyCharm webinar
Python
1
star
70

pyupgradesim

CSS
1
star