biston 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- biston-0.2.0/.github/dependabot.yml +26 -0
- biston-0.2.0/.github/workflows/audit.yml +29 -0
- biston-0.2.0/.github/workflows/cargo-deny.yml +35 -0
- biston-0.2.0/.github/workflows/codeql.yml +42 -0
- biston-0.2.0/.github/workflows/release.yml +114 -0
- biston-0.2.0/.github/workflows/review.yml +64 -0
- biston-0.2.0/.gitignore +71 -0
- biston-0.2.0/CLAUDE.md +80 -0
- biston-0.2.0/Cargo.lock +1089 -0
- biston-0.2.0/Cargo.toml +77 -0
- biston-0.2.0/Makefile +60 -0
- biston-0.2.0/PKG-INFO +69 -0
- biston-0.2.0/README.md +39 -0
- biston-0.2.0/clippy.toml +5 -0
- biston-0.2.0/deny.toml +28 -0
- biston-0.2.0/plans/constitution.md +47 -0
- biston-0.2.0/plans/phase-1-deviations.md +116 -0
- biston-0.2.0/plans/phase-1-structural.md +199 -0
- biston-0.2.0/plans/phase-1.5-hardening.md +107 -0
- biston-0.2.0/plans/phase-2-antiunify.md +145 -0
- biston-0.2.0/plans/phase-2.5-near-miss-rework.md +193 -0
- biston-0.2.0/plans/phase-3-embeddings.md +124 -0
- biston-0.2.0/prek.toml +35 -0
- biston-0.2.0/pyproject.toml +46 -0
- biston-0.2.0/release.toml +18 -0
- biston-0.2.0/rust-toolchain.toml +3 -0
- biston-0.2.0/rustfmt.toml +3 -0
- biston-0.2.0/src/antiunify.rs +744 -0
- biston-0.2.0/src/config.rs +279 -0
- biston-0.2.0/src/discovery.rs +150 -0
- biston-0.2.0/src/extract.rs +203 -0
- biston-0.2.0/src/hash.rs +303 -0
- biston-0.2.0/src/lib.rs +160 -0
- biston-0.2.0/src/main.rs +89 -0
- biston-0.2.0/src/normalize.rs +527 -0
- biston-0.2.0/src/parse.rs +80 -0
- biston-0.2.0/src/report.rs +581 -0
- biston-0.2.0/src/similarity.rs +450 -0
- biston-0.2.0/tests/cli.rs +77 -0
- biston-0.2.0/tests/fixtures/near_miss.py +78 -0
- biston-0.2.0/tests/fixtures/no_clones.py +39 -0
- biston-0.2.0/tests/fixtures/short_functions.py +13 -0
- biston-0.2.0/tests/fixtures/simple_clones.py +30 -0
- biston-0.2.0/tests/fixtures/suggest_clones.py +38 -0
- biston-0.2.0/tests/scan.rs +113 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Rust (Cargo) dependencies
|
|
4
|
+
- package-ecosystem: "cargo"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
day: "monday"
|
|
9
|
+
open-pull-requests-limit: 10
|
|
10
|
+
labels:
|
|
11
|
+
- "dependencies"
|
|
12
|
+
- "rust"
|
|
13
|
+
groups:
|
|
14
|
+
minor-and-patch:
|
|
15
|
+
update-types:
|
|
16
|
+
- "minor"
|
|
17
|
+
- "patch"
|
|
18
|
+
|
|
19
|
+
# GitHub Actions
|
|
20
|
+
- package-ecosystem: "github-actions"
|
|
21
|
+
directory: "/"
|
|
22
|
+
schedule:
|
|
23
|
+
interval: "weekly"
|
|
24
|
+
labels:
|
|
25
|
+
- "dependencies"
|
|
26
|
+
- "ci"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: "Cargo Audit"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
paths:
|
|
6
|
+
- "Cargo.toml"
|
|
7
|
+
- "Cargo.lock"
|
|
8
|
+
pull_request:
|
|
9
|
+
paths:
|
|
10
|
+
- "Cargo.toml"
|
|
11
|
+
- "Cargo.lock"
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: "0 0 * * *" # Daily at midnight UTC
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
issues: write
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
audit:
|
|
22
|
+
name: Security Audit
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout repository
|
|
26
|
+
uses: actions/checkout@v6
|
|
27
|
+
|
|
28
|
+
- name: Run cargo-audit
|
|
29
|
+
uses: actions-rust-lang/audit@v1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: "Cargo Deny"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
paths:
|
|
7
|
+
- "Cargo.lock"
|
|
8
|
+
- "Cargo.toml"
|
|
9
|
+
- "deny.toml"
|
|
10
|
+
pull_request:
|
|
11
|
+
paths:
|
|
12
|
+
- "Cargo.lock"
|
|
13
|
+
- "Cargo.toml"
|
|
14
|
+
- "deny.toml"
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
deny:
|
|
21
|
+
name: ${{ matrix.check }}
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
check: [bans, licenses, sources]
|
|
27
|
+
steps:
|
|
28
|
+
- name: Checkout repository
|
|
29
|
+
uses: actions/checkout@v6
|
|
30
|
+
|
|
31
|
+
- name: Run cargo-deny (${{ matrix.check }})
|
|
32
|
+
uses: EmbarkStudios/cargo-deny-action@v2
|
|
33
|
+
with:
|
|
34
|
+
command: check ${{ matrix.check }}
|
|
35
|
+
arguments: --all-features
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
paths:
|
|
7
|
+
- "src/**"
|
|
8
|
+
- "Cargo.toml"
|
|
9
|
+
- "Cargo.lock"
|
|
10
|
+
pull_request:
|
|
11
|
+
branches: ["main"]
|
|
12
|
+
paths:
|
|
13
|
+
- "src/**"
|
|
14
|
+
- "Cargo.toml"
|
|
15
|
+
- "Cargo.lock"
|
|
16
|
+
schedule:
|
|
17
|
+
- cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
security-events: write
|
|
21
|
+
packages: read
|
|
22
|
+
actions: read
|
|
23
|
+
contents: read
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
analyze:
|
|
27
|
+
name: Analyze Rust
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- name: Checkout repository
|
|
31
|
+
uses: actions/checkout@v6
|
|
32
|
+
|
|
33
|
+
- name: Initialize CodeQL
|
|
34
|
+
uses: github/codeql-action/init@v4
|
|
35
|
+
with:
|
|
36
|
+
languages: rust
|
|
37
|
+
build-mode: none
|
|
38
|
+
|
|
39
|
+
- name: Perform CodeQL Analysis
|
|
40
|
+
uses: github/codeql-action/analyze@v4
|
|
41
|
+
with:
|
|
42
|
+
category: "/language:rust"
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-wheels:
|
|
14
|
+
name: Build wheels on ${{ matrix.os }}
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
os: [ubuntu-latest, macos-14, windows-latest]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v6
|
|
22
|
+
|
|
23
|
+
- name: Build wheels
|
|
24
|
+
uses: PyO3/maturin-action@v1
|
|
25
|
+
with:
|
|
26
|
+
args: --release --strip
|
|
27
|
+
manylinux: 2_28
|
|
28
|
+
|
|
29
|
+
- name: Upload wheels
|
|
30
|
+
uses: actions/upload-artifact@v7
|
|
31
|
+
with:
|
|
32
|
+
name: wheels-${{ matrix.os }}
|
|
33
|
+
path: target/wheels/*.whl
|
|
34
|
+
|
|
35
|
+
build-sdist:
|
|
36
|
+
name: Build source distribution
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
|
+
|
|
41
|
+
- name: Set up Rust
|
|
42
|
+
uses: dtolnay/rust-toolchain@stable
|
|
43
|
+
|
|
44
|
+
- name: Set up Python
|
|
45
|
+
uses: actions/setup-python@v6
|
|
46
|
+
with:
|
|
47
|
+
python-version: '3.11'
|
|
48
|
+
|
|
49
|
+
- name: Install maturin
|
|
50
|
+
run: pip install maturin
|
|
51
|
+
|
|
52
|
+
- name: Build sdist
|
|
53
|
+
run: maturin sdist
|
|
54
|
+
|
|
55
|
+
- name: Upload sdist
|
|
56
|
+
uses: actions/upload-artifact@v7
|
|
57
|
+
with:
|
|
58
|
+
name: sdist
|
|
59
|
+
path: target/wheels/*.tar.gz
|
|
60
|
+
|
|
61
|
+
create-release:
|
|
62
|
+
name: Create GitHub Release
|
|
63
|
+
needs: [build-wheels, build-sdist]
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v6
|
|
68
|
+
|
|
69
|
+
- name: Download all artifacts
|
|
70
|
+
uses: actions/download-artifact@v8
|
|
71
|
+
with:
|
|
72
|
+
path: dist
|
|
73
|
+
|
|
74
|
+
- name: Flatten artifacts
|
|
75
|
+
run: |
|
|
76
|
+
mkdir -p wheels
|
|
77
|
+
find dist -name '*.whl' -exec cp {} wheels/ \;
|
|
78
|
+
find dist -name '*.tar.gz' -exec cp {} wheels/ \;
|
|
79
|
+
|
|
80
|
+
- name: Create Release
|
|
81
|
+
uses: softprops/action-gh-release@v2
|
|
82
|
+
with:
|
|
83
|
+
files: wheels/*
|
|
84
|
+
generate_release_notes: true
|
|
85
|
+
draft: false
|
|
86
|
+
prerelease: false
|
|
87
|
+
|
|
88
|
+
publish-to-pypi:
|
|
89
|
+
name: Publish to PyPI
|
|
90
|
+
needs: [build-wheels, build-sdist, create-release]
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
|
|
93
|
+
environment:
|
|
94
|
+
name: pypi
|
|
95
|
+
url: https://pypi.org/p/biston
|
|
96
|
+
permissions:
|
|
97
|
+
id-token: write
|
|
98
|
+
steps:
|
|
99
|
+
- name: Download all artifacts
|
|
100
|
+
uses: actions/download-artifact@v8
|
|
101
|
+
with:
|
|
102
|
+
path: dist
|
|
103
|
+
|
|
104
|
+
- name: Flatten artifacts
|
|
105
|
+
run: |
|
|
106
|
+
mkdir -p wheels
|
|
107
|
+
find dist -name '*.whl' -exec cp {} wheels/ \;
|
|
108
|
+
find dist -name '*.tar.gz' -exec cp {} wheels/ \;
|
|
109
|
+
|
|
110
|
+
- name: Publish to PyPI
|
|
111
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
112
|
+
with:
|
|
113
|
+
packages-dir: wheels/
|
|
114
|
+
skip-existing: true
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Code Review
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- "src/**"
|
|
8
|
+
- "tests/**"
|
|
9
|
+
- "Cargo.toml"
|
|
10
|
+
- "Cargo.lock"
|
|
11
|
+
- "rust-toolchain.toml"
|
|
12
|
+
- "clippy.toml"
|
|
13
|
+
- "rustfmt.toml"
|
|
14
|
+
pull_request:
|
|
15
|
+
paths:
|
|
16
|
+
- "src/**"
|
|
17
|
+
- "tests/**"
|
|
18
|
+
- "Cargo.toml"
|
|
19
|
+
- "Cargo.lock"
|
|
20
|
+
- "rust-toolchain.toml"
|
|
21
|
+
- "clippy.toml"
|
|
22
|
+
- "rustfmt.toml"
|
|
23
|
+
|
|
24
|
+
concurrency:
|
|
25
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
26
|
+
cancel-in-progress: true
|
|
27
|
+
|
|
28
|
+
env:
|
|
29
|
+
CARGO_TERM_COLOR: always
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
fmt:
|
|
33
|
+
name: Formatting
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v6
|
|
37
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
38
|
+
with:
|
|
39
|
+
components: rustfmt
|
|
40
|
+
- run: cargo fmt --all --check
|
|
41
|
+
|
|
42
|
+
clippy:
|
|
43
|
+
name: Clippy
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v6
|
|
47
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
48
|
+
with:
|
|
49
|
+
components: clippy
|
|
50
|
+
- uses: Swatinem/rust-cache@v2
|
|
51
|
+
- run: cargo clippy --all-targets --all-features -- -D warnings
|
|
52
|
+
|
|
53
|
+
test:
|
|
54
|
+
name: Tests
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v6
|
|
58
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
59
|
+
- uses: Swatinem/rust-cache@v2
|
|
60
|
+
- name: Set up Python
|
|
61
|
+
uses: actions/setup-python@v6
|
|
62
|
+
with:
|
|
63
|
+
python-version: "3.11"
|
|
64
|
+
- run: cargo test --all-features
|
biston-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Rust
|
|
2
|
+
/target/
|
|
3
|
+
**/*.rs.bk
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
*.so
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# Virtual environments
|
|
31
|
+
.env
|
|
32
|
+
.venv
|
|
33
|
+
env/
|
|
34
|
+
venv/
|
|
35
|
+
ENV/
|
|
36
|
+
env.bak/
|
|
37
|
+
venv.bak/
|
|
38
|
+
|
|
39
|
+
# IDE
|
|
40
|
+
.vscode/
|
|
41
|
+
.idea/
|
|
42
|
+
*.swp
|
|
43
|
+
*.swo
|
|
44
|
+
*~
|
|
45
|
+
|
|
46
|
+
# OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
.DS_Store?
|
|
49
|
+
._*
|
|
50
|
+
.Spotlight-V100
|
|
51
|
+
.Trashes
|
|
52
|
+
ehthumbs.db
|
|
53
|
+
Thumbs.db
|
|
54
|
+
|
|
55
|
+
# Logs
|
|
56
|
+
*.log
|
|
57
|
+
|
|
58
|
+
# Temporary files
|
|
59
|
+
*.tmp
|
|
60
|
+
*.temp
|
|
61
|
+
.cache/
|
|
62
|
+
|
|
63
|
+
# maturin / PyO3
|
|
64
|
+
*.so
|
|
65
|
+
*.pyd
|
|
66
|
+
.eggs/
|
|
67
|
+
|
|
68
|
+
# Testing
|
|
69
|
+
.pytest_cache/
|
|
70
|
+
.coverage
|
|
71
|
+
htmlcov/
|
biston-0.2.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
biston is a tool for analyzing Python code. It's a hybrid Rust/Python project that builds a Rust binary (`biston`) but packages it as a Python package using maturin for easy distribution via pip/uv.
|
|
8
|
+
|
|
9
|
+
## Common Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Pre-commit checks (always run before committing)
|
|
13
|
+
cargo fmt --check && cargo clippy --all-targets --all-features -- -D warnings && cargo test --all-features
|
|
14
|
+
|
|
15
|
+
# Run tests
|
|
16
|
+
cargo test
|
|
17
|
+
|
|
18
|
+
# Build and install locally for testing
|
|
19
|
+
maturin develop
|
|
20
|
+
|
|
21
|
+
# Full review (fmt, clippy, tests, audit, deny)
|
|
22
|
+
make review
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Development Workflow
|
|
26
|
+
|
|
27
|
+
All features and bug fixes follow TDD (red-green-refactor). No implementation code without a failing test first. Bug fixes must include a regression test that fails without the fix.
|
|
28
|
+
|
|
29
|
+
## Test Changes Require Deliberation
|
|
30
|
+
|
|
31
|
+
When a test fails during implementation:
|
|
32
|
+
|
|
33
|
+
1. **Stop and diagnose.** Understand WHY it fails before changing anything.
|
|
34
|
+
2. **Default assumption: the test is right.** Fix the implementation first.
|
|
35
|
+
3. **If the test genuinely needs updating** (requirements changed, API evolved), explain what changed and why the old assertion is no longer correct before modifying it.
|
|
36
|
+
4. **Never weaken an assertion just to make it pass.**
|
|
37
|
+
5. **If uncertain, ask.**
|
|
38
|
+
|
|
39
|
+
## Branch Hygiene
|
|
40
|
+
|
|
41
|
+
**Always merge `main` into your feature branch before creating a PR.** Run:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git fetch origin main && git merge origin/main
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then re-run the full check suite to verify the merge didn't introduce breakage.
|
|
48
|
+
|
|
49
|
+
## When Stuck
|
|
50
|
+
|
|
51
|
+
If hitting a wall:
|
|
52
|
+
1. Do not silently work around it — state the problem explicitly.
|
|
53
|
+
2. Do not attempt more than 3 approaches without reporting what was tried and why each failed.
|
|
54
|
+
3. Do not modify unrelated code hoping it fixes the issue.
|
|
55
|
+
4. Revert to last known good state if changes made things worse.
|
|
56
|
+
5. When in doubt, ask.
|
|
57
|
+
|
|
58
|
+
## Review Before Completing Work
|
|
59
|
+
|
|
60
|
+
Before marking any task as complete:
|
|
61
|
+
|
|
62
|
+
1. **Automated checks** (run automatically via prek pre-commit hook on `git commit`):
|
|
63
|
+
- `cargo fmt --all -- --check`
|
|
64
|
+
- `cargo clippy --all-targets --all-features -- -D warnings`
|
|
65
|
+
- `cargo test --all-features --bins`
|
|
66
|
+
|
|
67
|
+
2. **Deep review** (REQUIRED for all significant changes):
|
|
68
|
+
- Run the `rust-review` skill (`/rust-review`) before marking work as complete
|
|
69
|
+
- Address all 🔴 Must Fix items before completing
|
|
70
|
+
- Address 🟡 Should Fix items unless there's a documented reason not to
|
|
71
|
+
|
|
72
|
+
3. **Full review** (run before pushing):
|
|
73
|
+
- `make review`
|
|
74
|
+
|
|
75
|
+
### Code Rules
|
|
76
|
+
- No `.unwrap()` outside tests — use `.context()` when propagating errors with `?`
|
|
77
|
+
- No `MutexGuard` held across `.await`
|
|
78
|
+
- Prefer `&str`/`&[T]`/`&Path` over owned types in function parameters when ownership isn't needed
|
|
79
|
+
- Tests must assert on values, not just "runs without panic"
|
|
80
|
+
- Flaky tests need root-cause analysis, not looser assertions
|