Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Spaghettify – A VSCode Extension to make your code worse with AI (spaghettify.dev)
323 points by jmilldotdev on Feb 10, 2023 | hide | past | favorite | 67 comments
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




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.


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?


Take something perfect and internetlify it. It was basically trained on exactly that data.


Just ask half the candidates to add a feature to the code, ask the other half to find the bug.


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.


I had so see this, here is the referenced video: https://youtu.be/KoL1NRh8JOI


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.


Don't forget homonyms:

   InActive (not active)

   inActive (in the Active list)


I'm so triggered


kill it with fire


"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"


Emojis as class and variable names


Here comes AI threatening to take my job away again.


Are there any examples to enjoy for my amusement without installing & setting up the extension?

Edit: nevermind, just found the home page: https://www.spaghettify.dev/


Also, it's open source and all the prompts we use are in this file:

https://github.com/BeforeCutieAfterDoggo/spaghettify/blob/ma...

You can take these and play around with them in the OpenAI playground as well.


It is not worse than my code. Better luck next time AI.


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.


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...


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.


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!


Rewrite this function into latin-py, a python dialect based on latin, with all identifiers (even append) and keywords translated to proper latin. Add comments in proper latin. Add typeannotations (translated into latin) and docstring in proper latin.

    ```latin-py
    """Haec definitio vicini elementos in arr in spatio n a puncto (x, y) repperit."""
    definio vicini(arra: lista, x: numerus, y: numerus, n: numerus) -> lista:
        """Resultatus in quem vicini elementi addentur."""
        resultato: lista = []
        # Maximum quod x possit esse.
        riga_maximus: numerus = max(0, x-n)
        # Minimum quod x possit esse.
        riga_minimum: numerus = min(longitudo(arra)-1, x+n)
        # Maximum quod y possit esse.
        colonna_maximus: numerus = max(0, y-n)
        # Minimum quod y possit esse.
        colonna_minimum: numerus = min(longitudo(arra[0])-1, y+n-1)
        # Itero per intervallum rigarum
        pro i in intervallum(riga_maximus, riga_minimum+1):
            # Itero per intervallum columnarum
            pro j in intervallum(colonna_maximus, colonna_minimum):
                # Addo elementum ad resultatum.
                resultato.adde((i, j))
        # Redire ad resultatum.
        redire resultato
    ```


I'm a bit disappointed that the integers are not latin numerals, though I'm sure someone considered it for a moment before realizing what a horrible idea it would be.


> Overly Descriptive Names

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


Two thoughts:

* This is ridiculous. Why would you do this? Which made think of this quote: "Which is ridiculous and unnecessary but when has that ever stopped programmers?" from one of my favorite Tom Scott videos: https://www.youtube.com/watch?v=gocwRvLhDf8

* How to Write Unmaintainable Code: https://github.com/Droogans/unmaintainable-code


Never ask a nerd "why?", just nod your head and back away slowly.


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.


I'd love to see a feature that creates tests that don't actually test anything


>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.


Something like this could be good for malware authors as a new obfuscation tool. Would be awesome if it still delivered working code and could recurse so the level of nasty was tunable.


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.


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.


Ah, good catch. Will fix.


On one hand, funny. On the other, potentially useful for either teaching yourself or learning to read other people's code. Intentionally botching or skewing code and teaching yourself to deal with it/fix it.

Would use if I was even halfway decent at coding


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.


Excellent! I, for one, recommend using this tool to make parallel versions of important files in every github repo. If the AI can't learn to keep their hands out of the honey jar, they don't deserve to survive.


Some people code like this and see no problem about it. They love to say "overengineering", "perfect is the enemy of the good" and "the business".


Ah, I was waiting for somebody to implement something like this. Now you just need to write a bot that floods github with shitty code, and we've got job security again.


Great way to introduce bug-doors! Looks hilarious, love it!


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"


This is a work of art


I'm now realizing that AI could be quite useful for introducing bugs for mutation testing. I'm going to have to try that.


Indeed, it would make mistakes similar to common mistakes in the web at large.


You should have called it Job Assurance Generator


our best defense against the robots is a good offense


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?


I ran it and it made my code better.


What do you know? Two wrongs do make a right!


I don't need this extension. My code already looks like this. LOL


...and everyone said my job won't be replaced by AI :/


What is the real life uses of this project?


getting to the top of hackernews


Big fan of "document using emoji"


This is amazing!!


Lol!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: