Skip to content

zulfff/Logic-Collision-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VS Code extension that finds contradictory conditions across your codebase

VS Code TypeScript License


Ever spent 3 hours debugging only to realize your auth check was backwards in one file? Yeah, me too.

This VS Code extension hunts down those sneaky logic contradictions that hide across your codebase. The bugs that compile fine, pass tests, and then blow up in production because isAdmin and !isAdmin both call deleteUser() in different files.

The bug this catches

You write this in auth.js:

if (user.role === "admin") {
  allowDelete();
}

Three months later, someone copies it to legacy.js and flips the condition:

if (user.role !== "admin") {
  allowDelete();  // wait what
}

Both conditions lead to the same outcome. That's not just wrong - it's dangerous because it looks intentional. This extension flags it in your problems panel before you ship it.

Another classic:

// utils.js
if (isLoggedIn) return showDashboard();

// somewhere-else.js  
if (!isLoggedIn) return showDashboard();  // how does this even work

What you get

  • Scans your whole workspace for if statements, ternaries, switches
  • Finds conditions that contradict each other across files
  • Drops warnings right in the VS Code problems panel
  • Click through to see where the conflict lives
  • Incremental scans on save (fast, doesn't hog CPU)
  • Caches results so re-scans are instant

Quick start

Install it:

# Clone it
git clone https://github.com/AryzXploit/Logic-Collision-Detector
cd Logic-Collision-Detector

# Install & build
npm install
npm run compile

# Package for VS Code
npm run package

Then in VS Code: Extensions → "..." → Install from VSIX → pick the .vsix file.

Or just run it: Open this folder in VS Code, hit F5, and a new window opens with the extension loaded. Open any JS/TS project and run "Scan Workspace for Logic Collisions" from the command palette.

Using it

Command Palette (Ctrl+Shift+P):

  • Logic Collision Detector: Scan Workspace - full scan
  • Logic Collision Detector: Clear All Diagnostics - wipe the warnings

Settings (.vscode/settings.json):

{
  "logicCollision.include": ["**/*.ts", "**/*.js"],
  "logicCollision.exclude": ["**/node_modules/**", "**/dist/**"],
  "logicCollision.enableOnChange": true
}
Setting What it does
include Which files to scan (default: js,ts,jsx,tsx)
exclude What to skip (node_modules, build dirs, etc)
enableOnChange Auto-scan when you save a file
maxFileSize Skip files bigger than this (default 1MB)

How it actually works

  1. Parses your code with the TypeScript compiler API
  2. Normalizes conditions - so a === b and b === a are seen as the same thing
  3. Indexes by condition, negated condition, and what the code actually does
  4. Detects two patterns:
    • Opposite conditions → same outcome (bug alert)
    • Same condition → opposite outcomes (inconsistency warning)

It handles double negations, flipped comparisons, and all the ways developers write the same logic differently.

Real talk

This won't catch everything. Nested ternaries that make you cry? Probably not. Logic built with eval()? Nope. Files over 1MB get skipped because life is too short.

But for the 90% case - finding that one backwards if statement that somehow made it through code review - this thing pays for itself in one bug caught.

Requirements

  • VS Code 1.74+
  • Node 16+ (if you're hacking on it)

License

MIT - do whatever, just don't blame me when you find out your entire auth system is backwards.

About

Find hidden logic contradictions in your codebase before they turn into production bugs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors