parallax
Find code that does the same logical job through different paths.
Token-similarity tools (jscpd, PMD CPD, pylint duplicate-code) detect copy-paste. parallax detects something different: two pieces of code that touch the same set of resources, regardless of how the code is written. Different filters, different return shapes, even different languages.
Model
A unit of code (function, method, file, module, microservice, ...) touches a set of resources (database tables, HTTP endpoints, Redis keys, env vars, file paths, ...). Units sharing the same resource set are clustered as duplication candidates.
Both unit detection and resource detection are pluggable per extractor.
Built-in extractors
| Name | Unit | Resource |
|---|---|---|
sqlalchemy |
Python function/method | SQLAlchemy ORM model classes |
django |
Python function/method | Django ORM model classes |
http-urls |
any text file | HTTP URL paths |
env-vars |
any text file | Environment variable names |
redis-keys |
any text file | Redis key namespaces |
Installation
pip install parallax-scan
Usage
parallax scan path/to/repo
parallax scan path/to/repo --extractor sqlalchemy
parallax scan path/to/repo -e sqlalchemy -e http-urls
parallax scan path/to/repo --min-resources 3 --top 20
parallax scan path/to/repo --cross-file-only
parallax scan path/to/repo --format html -o report.html
parallax scan path/to/repo --format sarif -o parallax.sarif
Configuration
Drop .parallax.toml at your repo root:
[scan]
min_resources = 3
min_cluster_size = 2
[ci]
max_cluster_size = 5
[[ignore]]
resources = ["User", "Place"]
reason = "Generic"
In CI:
parallax scan . --ci
parallax scan . --format sarif -o parallax.sarif
--ci exits non-zero only when a cluster meets ci.max_cluster_size. Without it, any cluster is non-zero.
Comparison
| Tool | Catches | Doesn't catch |
|---|---|---|
| jscpd, PMD CPD, pylint duplicate-code | Token-similar copy-paste | Code with different surface shape |
| Sourcegraph | Manual code search | Automatic detection |
pydeps, dependency-cruiser |
Module-level imports | Same-resource overlap |
| semgrep | Hand-written patterns | Discovery |
| parallax | Same-resource overlap regardless of shape | Single-instance bad patterns |
Status
Alpha. API and CLI are unstable until 1.0.
Writing an extractor
from pathlib import Path
from typing import Iterable
from parallax import Unit
from parallax.extractors.base import Extractor
class TerraformAwsExtractor(Extractor):
name = "terraform-aws"
def extract(self, root: Path) -> Iterable[Unit]:
for tf in root.rglob("*.tf"):
...
Register in parallax.extractors.BUILTIN_EXTRACTORS.
License
MIT
Metadata
Release files for parallax-scan 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| parallax_scan-0.3.0.tar.gz | 28.0 kB | Without provenance | Details for parallax_scan-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| parallax_scan-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for parallax_scan-0.3.0-py3-none-any.whl |
Total release size: 56.0 kB
Release files / parallax_scan-0.3.0.tar.gz
| Download URL | parallax_scan-0.3.0.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd0c4e8a7105154beef960bc45b23d6789173b729ed0444981120e781f9df784
|
|
BLAKE2b-256 checksum How to use checksums |
5e6e024cc637745da961f31538917b24d90bf802c0fdb7d3974d853207cfe0c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / parallax_scan-0.3.0-py3-none-any.whl
| Download URL | parallax_scan-0.3.0-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76a9af0f08fe29737db3f8e62ad7935a763fec61bb55816ef699d25ef86383e9
|
|
BLAKE2b-256 checksum How to use checksums |
3de6f910e87e45ead74da8942eb1ea71485d2f650a81143cdcb0ea3391f80f52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for parallax-scan 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.