dslop 1.0.0 → 1.0.1
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/README.md +48 -22
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,23 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
**D**etect **S**imilar/**L**ines **O**f **P**rogramming - A fast duplicate code detector.
|
|
4
4
|
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
Run instantly with npx (no install required):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx dslop .
|
|
11
|
+
```
|
|
12
|
+
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
|
|
16
|
+
# Install globally
|
|
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
|
|
9
23
|
```
|
|
10
24
|
|
|
11
25
|
## Usage
|
|
12
26
|
|
|
13
27
|
```bash
|
|
14
28
|
# Scan current directory
|
|
15
|
-
|
|
29
|
+
dslop .
|
|
16
30
|
|
|
17
31
|
# Scan specific directory with options
|
|
18
|
-
|
|
32
|
+
dslop ./src -m 6 -s 80
|
|
33
|
+
|
|
34
|
+
# Only show duplicates across packages (great for monorepos)
|
|
35
|
+
dslop . --cross-package
|
|
19
36
|
|
|
20
37
|
# Output as JSON
|
|
21
|
-
|
|
38
|
+
dslop . --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or run without installing:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx dslop .
|
|
45
|
+
bunx dslop .
|
|
46
|
+
pnpm dlx dslop .
|
|
22
47
|
```
|
|
23
48
|
|
|
24
49
|
## Options
|
|
@@ -43,26 +68,16 @@ bun run index.ts . --json
|
|
|
43
68
|
5. **Similarity Matching**: Uses Jaccard similarity on line sets for near-duplicates
|
|
44
69
|
6. **Filtering**: Removes overlapping blocks and deduplicates groups
|
|
45
70
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
All detection parameters are configurable in `src/constants.ts`:
|
|
71
|
+
## Monorepo Mode
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
// Block extraction
|
|
52
|
-
MAX_BLOCK_SIZE = 100 // Maximum lines per block
|
|
53
|
-
BLOCK_SIZE_MULTIPLIER = 1.5 // Growth factor for multi-size extraction
|
|
54
|
-
MIN_MEANINGFUL_LINE_RATIO = 0.6 // Skip blocks with too many comments/whitespace
|
|
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:
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
MAX_BLOCKS_FOR_SIMILARITY = 10000 // Skip similarity for large codebases
|
|
59
|
-
GROUP_OVERLAP_THRESHOLD = 0.5 // Dedup threshold
|
|
60
|
-
|
|
61
|
-
// Output
|
|
62
|
-
MAX_GROUPS_DETAILED = 20 // Max groups to show in detail
|
|
63
|
-
MAX_MATCHES_IN_SUMMARY = 5 // Max file matches per group
|
|
75
|
+
```bash
|
|
76
|
+
dslop . --cross-package
|
|
64
77
|
```
|
|
65
78
|
|
|
79
|
+
This filters results to only show duplicates where occurrences are in different `apps/`, `packages/`, or `libs/` directories.
|
|
80
|
+
|
|
66
81
|
## Example Output
|
|
67
82
|
|
|
68
83
|
```
|
|
@@ -101,11 +116,22 @@ SUMMARY
|
|
|
101
116
|
Average similarity: 95%
|
|
102
117
|
```
|
|
103
118
|
|
|
104
|
-
##
|
|
119
|
+
## Development
|
|
105
120
|
|
|
106
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
|
+
|
|
107
133
|
# Create standalone binary
|
|
108
|
-
bun build
|
|
134
|
+
bun run build:binary
|
|
109
135
|
```
|
|
110
136
|
|
|
111
137
|
## License
|
package/dist/index.js
CHANGED