323 points · by jmilldotdev · 3y ago · 67 comments
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:
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.
Are we going to see hires basically trying code generation until it builds?
Quote from an Aprils Fools video for The Witcher 3.
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.
InActive (not active)
inActive (in the Active list)I actually saw code that looked like that from a very dyslexic mate of mine who I worked with a long time ago.
Edit: nevermind, just found the home page: https://www.spaghettify.dev/
https://github.com/BeforeCutieAfterDoggo/spaghettify/blob/ma...
You can take these and play around with them in the OpenAI playground as well.
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...
```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
```Looks like regular Lisp function names to me ¯\_(ツ)_/¯
* 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
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.
>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...
>> 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.
Would use if I was even halfway decent at coding
Now I found the best tool ever! Thank you.