dslop 1.0.6 → 1.0.7
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.
- package/CHANGELOG.md +2 -27
- package/README.md +14 -117
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## v1.0.7
|
|
4
4
|
|
|
5
5
|
## v1.0.6
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### 🏡 Chore
|
|
10
|
-
|
|
11
|
-
- Add changelogen for automated changelogs ([7cb82db](https://github.com/turf-sports/dslop/commit/7cb82db))
|
|
12
|
-
|
|
13
|
-
### ❤️ Contributors
|
|
14
|
-
|
|
15
|
-
- Siddharth Sharma <sharmasiddharthcs@gmail.com>
|
|
16
|
-
|
|
17
|
-
## v1.0.5
|
|
18
|
-
|
|
19
|
-
### 🚀 Features
|
|
20
|
-
|
|
21
|
-
- Initial public release
|
|
22
|
-
- Detect duplicate and similar code blocks across your codebase
|
|
23
|
-
- Smart normalization (strings, numbers, colors) for structural comparison
|
|
24
|
-
- Monorepo mode with `--cross-package` flag
|
|
25
|
-
- JSON output support
|
|
26
|
-
- Configurable similarity threshold and minimum block size
|
|
27
|
-
|
|
28
|
-
### 📦 Publishing
|
|
29
|
-
|
|
30
|
-
- Available via `npx dslop`
|
|
31
|
-
- Auto-versioning with changelogs
|
|
32
|
-
|
|
7
|
+
- Initial release
|
package/README.md
CHANGED
|
@@ -1,138 +1,35 @@
|
|
|
1
1
|
# dslop
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
Run instantly with npx (no install required):
|
|
3
|
+
Find duplicate code in your codebase.
|
|
8
4
|
|
|
9
5
|
```bash
|
|
10
6
|
npx dslop .
|
|
11
7
|
```
|
|
12
8
|
|
|
13
|
-
##
|
|
9
|
+
## Install
|
|
14
10
|
|
|
15
11
|
```bash
|
|
16
|
-
|
|
17
|
-
npm install -g dslop
|
|
18
|
-
|
|
19
|
-
# Or with other package managers
|
|
20
|
-
pnpm add -g dslop
|
|
21
|
-
bun add -g dslop
|
|
22
|
-
yarn global add dslop
|
|
12
|
+
npm i -g dslop
|
|
23
13
|
```
|
|
24
14
|
|
|
25
15
|
## Usage
|
|
26
16
|
|
|
27
17
|
```bash
|
|
28
|
-
#
|
|
29
|
-
dslop
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
dslop ./src -m 6 -s 80
|
|
33
|
-
|
|
34
|
-
# Only show duplicates across packages (great for monorepos)
|
|
35
|
-
dslop . --cross-package
|
|
36
|
-
|
|
37
|
-
# Output as JSON
|
|
38
|
-
dslop . --json
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Or run without installing:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx dslop .
|
|
45
|
-
bunx dslop .
|
|
46
|
-
pnpm dlx dslop .
|
|
18
|
+
dslop . # scan current directory
|
|
19
|
+
dslop ./src -m 6 -s 80 # 6 line min, 80% similarity
|
|
20
|
+
dslop . --cross-package # only cross-package dupes (monorepos)
|
|
21
|
+
dslop . --json # json output
|
|
47
22
|
```
|
|
48
23
|
|
|
49
24
|
## Options
|
|
50
25
|
|
|
51
|
-
|
|
|
52
|
-
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
| `--
|
|
57
|
-
| `--
|
|
58
|
-
| `--json` | | | Output as JSON |
|
|
59
|
-
| `--help` | `-h` | | Show help |
|
|
60
|
-
| `--version` | `-v` | | Show version |
|
|
61
|
-
|
|
62
|
-
## How It Works
|
|
63
|
-
|
|
64
|
-
1. **Scanning**: Recursively scans files matching the specified extensions
|
|
65
|
-
2. **Block Extraction**: Extracts code blocks using a sliding window approach at multiple granularities
|
|
66
|
-
3. **Normalization**: Replaces string literals, numbers, and colors with placeholders for structural comparison
|
|
67
|
-
4. **Hash Grouping**: Groups exact duplicates by hash for fast matching
|
|
68
|
-
5. **Similarity Matching**: Uses Jaccard similarity on line sets for near-duplicates
|
|
69
|
-
6. **Filtering**: Removes overlapping blocks and deduplicates groups
|
|
70
|
-
|
|
71
|
-
## Monorepo Mode
|
|
72
|
-
|
|
73
|
-
Use `--cross-package` to find duplicates that span across different packages/apps - perfect for identifying code that should be moved to a shared library:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
dslop . --cross-package
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
This filters results to only show duplicates where occurrences are in different `apps/`, `packages/`, or `libs/` directories.
|
|
80
|
-
|
|
81
|
-
## Example Output
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
Scanning ./src...
|
|
85
|
-
Extensions: ts, tsx, js, jsx
|
|
86
|
-
Min block size: 4 lines
|
|
87
|
-
Similarity threshold: 70%
|
|
88
|
-
Normalization: enabled
|
|
89
|
-
|
|
90
|
-
Scanned 81 files (15,672 lines) in 129ms
|
|
91
|
-
Extracted 13,920 code blocks
|
|
92
|
-
|
|
93
|
-
Found 500 duplicate groups in 51ms
|
|
94
|
-
|
|
95
|
-
────────────────────────────────────────────────────────────────────────────────
|
|
96
|
-
DUPLICATE CODE DETECTED
|
|
97
|
-
────────────────────────────────────────────────────────────────────────────────
|
|
98
|
-
|
|
99
|
-
Group 1 │ EXACT │ 28 lines × 2 occurrences = 56 lines of duplication
|
|
100
|
-
|
|
101
|
-
├─ QuarterlyWinnerMessagePreview.tsx:197-224
|
|
102
|
-
├─ CoachEnteredMessagePreview.tsx:113-140
|
|
103
|
-
|
|
104
|
-
Code preview:
|
|
105
|
-
│ <View style={{
|
|
106
|
-
│ backgroundColor: "white",
|
|
107
|
-
│ ...
|
|
108
|
-
|
|
109
|
-
SUMMARY
|
|
110
|
-
────────────────────────────────────────────────────────────────────────────────
|
|
111
|
-
Total duplicate groups: 500
|
|
112
|
-
Exact matches: 450
|
|
113
|
-
Similar matches: 50
|
|
114
|
-
Files affected: 65
|
|
115
|
-
Total duplicate lines: 12,340
|
|
116
|
-
Average similarity: 95%
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Development
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
# Clone and install
|
|
123
|
-
git clone https://github.com/turf-sports/dslop.git
|
|
124
|
-
cd dslop
|
|
125
|
-
bun install
|
|
126
|
-
|
|
127
|
-
# Run in dev mode
|
|
128
|
-
bun run dev
|
|
129
|
-
|
|
130
|
-
# Build for npm
|
|
131
|
-
bun run build
|
|
132
|
-
|
|
133
|
-
# Create standalone binary
|
|
134
|
-
bun run build:binary
|
|
135
|
-
```
|
|
26
|
+
| Flag | Default | Description |
|
|
27
|
+
|------|---------|-------------|
|
|
28
|
+
| `-m, --min-lines` | 4 | min lines per block |
|
|
29
|
+
| `-s, --similarity` | 70 | similarity threshold (0-100) |
|
|
30
|
+
| `-e, --extensions` | ts,tsx,js,jsx | file extensions |
|
|
31
|
+
| `--cross-package` | | only show dupes across packages |
|
|
32
|
+
| `--json` | | json output |
|
|
136
33
|
|
|
137
34
|
## License
|
|
138
35
|
|
package/dist/index.js
CHANGED
|
@@ -6559,7 +6559,7 @@ async function scanDirectory(targetPath, options) {
|
|
|
6559
6559
|
}
|
|
6560
6560
|
|
|
6561
6561
|
// index.ts
|
|
6562
|
-
var VERSION = process.env.npm_package_version || "1.0.
|
|
6562
|
+
var VERSION = process.env.npm_package_version || "1.0.7";
|
|
6563
6563
|
function showHelp() {
|
|
6564
6564
|
console.log(`
|
|
6565
6565
|
dslop - Detect Similar/Duplicate Lines Of Programming
|