Skip to main content

Small code clone detection tool. It implements an algorithm from SourcererCC with adaptive prefix filtering optimizations and displays its results as HTML.

It works with JavaScript, Python, Java, Go, C++, PHP, C#, C, Swift, Kotlin and Haskell.

Supported platforms

potator supports Linux and macOS. It is possible to use potator on Windows under WSL

Installation

Using pip

potator can be installed using pip

pip install potator

Using installation script

git clone https://github.com/otzhora/potator
cd potator
./install.sh

Usage

Using potator as a standalone cli application

potator [-h] [-d {Naive,Filtering}] [--depth DEPTH] [-t THRESHOLD] [-g GRANULARITY] [-o OUT] directory 

Options

  • You can choose one of two detectors: Naive and Filtering. Naive detector compares every possible combination of source code fragments and calculates Jaccard similarity between them. Filtering detector implements algorithm from SourcererCC paper with an adaptive prefix filtering optimizations.
  • depth parameters specify the maximum depth of adaptive prefix. depth=2 is recommended. Since it offers the optimal balance between costs of building index and querying it.
  • threshold is the minimum score that two code fragments should have to be considered clones.
  • granularity specifies granularity of code blocks. Options are functions and classes. functions is recommended.
  • out specifies the name of the resulting html
  • directory is the directory with files on which to perform search.

You can also do export DEBUG=1 before the search, then profiling information will be printed out.

Using potator as python package

You can import detectors or entities extractor from potator and use them to work with source code.

>>> from potator.detectors import FilteringDetector
>>> detector = FilteringDetector()
>>> detector.detect(directory, thershold, granularity)
>>> from potator.extractors import EntitiesExtractor
>>> EntitiesExtractor.extract_data_from_directory(directory, granularity)

Metadata

Release files for potator 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for potator 0.1.4
File Size Uploaded
potator-0.1.4.tar.gz 9.8 kB Details

Release files / potator-0.1.4.tar.gz

Download URL potator-0.1.4.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
803608b200a31bda785c4d97277d7c98955ee088bc29c429437f32194dbc1a84
BLAKE2b-256 checksum
How to use checksums
4956fa3f903a8555464bcd34b55708be044e9a089f209f7ef19282a2608d266a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page