BetaViberTest is in active development — expect breaking changes.
Overview
DocsRulesCode Duplication
#007mediumCode Quality

Code Duplication

Detects duplicate code blocks across files using sliding window hashing.

Rule ID:code-duplication

Examples#

BadSame validation logic in 3 files
// pages/signup.tsx
function validateForm(data) {
  if (!data.email.includes('@')) return 'Invalid email';
  if (data.password.length < 8) return 'Password too short';
  if (data.password !== data.confirm) return 'Passwords don\'t match';
  return null;
}

// pages/settings.tsx — SAME LOGIC COPY-PASTED
function validateForm(data) {
  if (!data.email.includes('@')) return 'Invalid email';
  if (data.password.length < 8) return 'Password too short';
  if (data.password !== data.confirm) return 'Passwords don\'t match';
  return null;
}
GoodExtract to shared module
// lib/validation.ts — single source of truth
export function validateAuthForm(data: AuthFormData) {
  if (!data.email.includes('@')) return 'Invalid email';
  if (data.password.length < 8) return 'Password too short';
  if (data.password !== data.confirm) return 'Passwords don\'t match';
  return null;
}

// pages/signup.tsx
import { validateAuthForm } from '@/lib/validation';

// pages/settings.tsx
import { validateAuthForm } from '@/lib/validation';

What It Detects#

high20+ duplicate lines across files
{N} duplicate lines found across {N} files

Fix: Extract to a shared module to follow the DRY principle.

medium10-19 duplicate lines across files
{N} duplicate lines found across {N} files

Fix: Extract to a shared module to follow the DRY principle.

Configuration#

This rule is enabled by default. To disable it:

.vibertestrc.jsonjson
{
  "rules": {
    "code-duplication": {
      "enabled": false
    }
  }
}