Show HN: Spaghettify – A VSCode Extension to make your code worse with AI (spaghettify.dev)

323 points by jmilldotdev ↗ HN
Recently, I saw Github Next Code Brushes (https://githubnext.com/projects/code-brushes) which is a VSCode extension that can use AI to do things like make your code more readable, add types, etc.

This inspired me: what if there was an extension that could use AI to make your code worse as well?

Meet Spaghettify. An extension I developed that can do things like:

- Obscure your code

- Introduce a bug

- Make the variable names way too descriptive

- Use nonsymmetrical whitespace

- Add irrelevant/rambling comments

- Document the code with emoji

- Document the code in any style (Dirty Limerick, Fast Talkin' 1930s Gangster)

I built this extension over the last couple of days and released it in collaboration with BCAD.one. It's available on the VSCode Marketplace, you will need an OpenAI API Key to use it. You can grab it here:

(https://marketplace.visualstudio.com/items?itemName=BCAD.spa...)

Code here:

https://github.com/BeforeCutieAfterDoggo/spaghettify

69 comments

[ 2.6 ms ] story [ 139 ms ] thread
This is pretty amazing. I'm inspired to go write something similar now, that uses AI to pad out source code to exactly 80 characters per-line...
Vertical screen users thank you in advance!
> Overly Descriptive Names

Looks like regular Lisp function names to me ¯\_(ツ)_/¯

Add irrelevant comments has real world use for some students who are required to comment all of their code when submitting their work.
I’ve been trying to push students in the direction of fewer, better comments but it is a lonely hill to die on.
The obfuscation is a little too obvious. The people need something which defends their job security but still passes code review.
Involve a few layers of unneeded steps of indirection via a few hyped technologies. Now obfuscation is not easily removed. Beware, it may bite the creators themselves
That’s like 90% of Java that uses spring.
>A VSCode Extension to make your code worse with AI

>Document the code with emoji

>Document the code in any style (Dirty Limerick, Fast Talkin' 1930s Gangster)

>worse

TIL I've been coding wrong my whole life. But it's the only way I know...

Wow, fast talkin' 1930s gangster documentation is pretty remarkable.

>> Listen up, ya mugs! I'm gonna give ya the lowdown on dis here function, getSourceImage().

>> Dis baby is the real deal. It's gonna give ya the goods on the source image. Ya got it? The source image! No more guessin' or snoopin' around, dis function'll give ya the straight dope.

How creative! Did you consider adding wrong comments? Because those are the worst! like flip the logic from arithmetic to subtraction and then have the bot summarize that.
That's a really good one. Like the 'introduce bug' one, but just the comments are factually incorrect.
Am I the only one that found the more explicitly named definition way easier to read? Sure the definition name was too large, but the inner variables were great.
There have been many moments in building this thing where I expected something terrible and got something that actually looked better than what I had.
Nah. I worked at a company that had a code style guide encouraging very verbose variable naming. It was awesome.
I read that feature on the list and immediately thought "I bet that improves more code than it harms"
The little animation at the top wraps when it gets to “Well Documented” on mobile. The whole page keeps shifting up and down. It’s really hard to read. Maybe it’s on purpose but just pointing it out. It detracted from the comedy for me. Otherwise love the gag.
Oh can you have it add code blocks that are commented out?

And have it do the opposite of "Extract a method" - oh and have a class call a method on another class that calls a method on another class that calls a method on the original class (but for every single thing that needs to happen in the critical path)?

If you can't, I have some developers I'm cleaning up after who can...

Awesome.

Evil ideas for improvements.

Random typos in class name, function names, comments, such as: inheritance -> enheritance class -> clas cannot -> cannont

Pick related words: person -> user, account, customer

Random swapping plural/singular users -> user

Append "Class" to classnames. example: User -> UsersClass

Insert rant comments about, politics, religion, profanity.

"privite" and "private" and "privet" but there are #defines to make them work anyway.

I actually saw code that looked like that from a very dyslexic mate of mine who I worked with a long time ago.

also, common capitalization mixups: "ID vs. Id", "snapshot vs. snapShot", "username vs. userName"
Don't forget homonyms:

   InActive (not active)

   inActive (in the Active list)
You should have called it Job Assurance Generator
our best defense against the robots is a good offense
I used to spend lots of time to prepare some coding tests that mimic real-world situations for candidates, like introducing a small bug to an example code or pretending I've bad coding practice etc.

Now I found the best tool ever! Thank you.

What (presumably!) was built as a joke will actually help me a lot. For my side-project (devscreen.io) we have to make lots of realistic coding tests and pull requests with bugs in them for candidates to work on as part of a technical interview. It's actually more time consuming than you'd think to intentionally insert bugs into code in a way that isn't super obvious, so thank you!
I think use cases like this are the right ones for generated code from language models.

I'm pretty sure the vast majority of training data is more buggy than not and literally writing the code is only half of what it takes. The other half is comprehension of the problem it solves which is usually missing from documentation at the level of mere snippets.

Take something perfect and internetlify it. It was basically trained on exactly that data.
Something I wonder is what the computing landscape (and tech recruiting) will looks like once we reach a critical mass of "GitHub Co-Pilot native" devs. Especially with the bootcamp craze.

Are we going to see hires basically trying code generation until it builds?

Bugs-as-a-Service (BAAS)
"Because, you see, bugs are a way of connecting people to the real world. Reminding them that, at the end of the day, it is just a game." — Matt Jablonsky, Head of Bug Creation Department

Quote from an Aprils Fools video for The Witcher 3.

Just ask half the candidates to add a feature to the code, ask the other half to find the bug.
I don't need this extension. My code already looks like this. LOL
Here comes AI threatening to take my job away again.
It is not worse than my code. Better luck next time AI.
(comment deleted)
I ran it and it made my code better.
What do you know? Two wrongs do make a right!
Big fan of "document using emoji"
When you introduce a bug, is it a dumb random bug, or an intelligent AI bug?

In other words, would the bug work for me or the user?

When I say work for me, what I mean is, considering decompiler tools like https://ghidra-sre.org/ can shine light where once there wasn't, would the bug generates lots of unnecessary work for me, or could I use the bug as a stealth form of copy protection, where those with illegal copies get bitten by the bug and eventually forced into purchasing said code?

I've seen that technique used with a software company supplying addons to other programming companies. Cant say its a technique taught at places like University.

Nice. A few more ideas: consolidate small functions into one huge function; change await to callback hell in JS; goto!
The reverse of refactoring. Defactoring? Factoring?