npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

smart-duplicate-detector

v1.0.0

Published

A high-precision static analysis engine to find structural code clones in Java.

Readme

Smart Duplicate Detector

Smart Duplicate Detector GUI

Overview

A Java tool that scans a codebase and flags methods with duplicate or highly similar logic before they become technical debt.

Developers often reuse or regenerate business logic without realizing an equivalent method already exists elsewhere in the codebase. Over time these duplicates drift apart, and bugs get fixed in one copy but not the other. Smart Duplicate Detector scans a project, compares every method, and reports matches above a similarity threshold—with file, line number, and score—so duplication is caught before it's merged.


The "Why": Technical Approach

Traditional duplicate detectors often rely on raw string matching or tokenization. This leads to a massive amount of "false positive" noise—flagging standard boilerplate, imports, or basic getters and setters as duplicated code.

Smart Duplicate Detector solves this using a two-step semantic approach:

  1. AST Method Parsing: By leveraging JavaParser, the engine parses the codebase into an Abstract Syntax Tree (AST) and isolates functional methods. It completely ignores class-level boilerplate, fields, and imports.

  2. Weighted Levenshtein Algorithm: Instead of basic string comparison, SDD compares the logic and structure of the methods using a custom Weighted Levenshtein distance algorithm. This accurately calculates similarity percentages, ensuring that only genuine logic clones are flagged while ignoring minor whitespace or variable renaming differences.


Features

  • Global CLI Tool: Wrapped in NPM for a frictionless 1-step installation and a global sdd command.
  • Modern Desktop App: Sleek, dark-themed Java Swing GUI powered by FlatLaf with real-time background scanning (SwingWorker).
  • High Precision: Structural extraction of every method into a comparable AST model.
  • Smart Scoring: Highly accurate similarity scoring via LevenshteinSimilarity.
  • Custom exception handling for invalid or empty project paths.
  • (Planned) Scan a public GitHub repository directly by URL instead of a local path.

Tech Stack

| Layer | Technology | | :--- | :--- | | Language | Java 17 | | Build & Distribution | Maven, Node.js / NPM (CLI Wrapper) | | Parsing | JavaParser | | Desktop GUI | Java Swing + FlatLaf (Modern Dark Theme) | | Backend / API | Javalin (REST, JSON via Jackson) | | Testing | JUnit 5 |


Architecture

smart-duplicate-detector/
├── package.json & index.js   # NPM Bridge for global 'sdd' command
├── model/                    # MethodModel, DuplicatePair
├── core/                     # ProjectScanner, AstMethodParser, SimilarityAlgorithm...
├── gui/                      # MainFrame (Swing Desktop App)
├── report/                   # AbstractReport, ConsoleReport
├── exceptions/               # InvalidProjectPathException, NoJavaFilesFoundException
├── api/                      # ApiServer (REST endpoints)
├── cli/                      # CliRunner
└── resources/                # (web frontend / static files)

🚀 Getting Started (End Users)

The easiest way to use Smart Duplicate Detector is via our NPM package, which automatically links the sdd command to your system.

Prerequisites

  • Java 17+
  • Node.js & NPM

Install Globally

npm install -g smart-duplicate-detector

Launch the UI

To launch the modern FlatLaf desktop dashboard, open your terminal anywhere and type:

sdd

Run via CLI (Headless)

To run a silent scan in your terminal without opening the GUI:

sdd --path ./path/to/project --threshold 0.80

🛠️ Developer Setup (Build from Source)

If you want to modify the Java engine or build the Fat-JAR yourself:

1. Clone the Repository

git clone https://github.com/fetehadin/smart-duplicate-detector.git
cd smart-duplicate-detector

2. Build the Engine

mvn clean package

3. Run Locally

java -jar target/smart-duplicate-detector.jar

Alternatively, run npm link in the root folder to test the global sdd command locally!


Usage Example (CLI & GUI Output)

Scanning project files...
Found 27 valid methods.
Running Levenshtein comparison engine...

DUPLICATE FOUND (92% similar)
 → EngineTest.java:14 -> testIdenticalSequenceLevenshteinScore
 → EngineTest.java:29 -> testDifferentSequenceLevenshteinScore

DUPLICATE FOUND (100% similar)
 → TestScenarios.java:6 -> calculateTaxUSA
 → TestScenarios.java:14 -> calculateTaxUK

Scan complete. 2 duplicate pairs found.

Known Limitations

  • Comparison is all-pairs (O(n²)): Fine for a single project, but not intended for massive, multi-gigabyte monorepos.
  • Only structural/token similarity is considered: No control-flow or semantic analysis yet.
  • GitHub-repo scanning (clone + scan by URL) is planned for a future release.

License

MIT — see LICENSE.