Shittier: Code formatting tool that makes your code look terrible(github.com)
github.com
Shittier: Code formatting tool that makes your code look terrible
https://github.com/rohitdhas/shittier
83 comments
Swap randomly between direct style (async/await) and pre ES2017 .then() chaining.
Minify every third variable randomly.
Minify every third variable randomly.
> Minify every third variable randomly.
So, Go?
So, Go?
This is rookie-level shittifying. What it needs to do is insert `with` blocks at random, with various levels of nesting, so you completely lose track of the scope of any object property.
Too "bad" that `with` blocks are forbidden in strict mode and most JS is strict mode by default now. You could somewhat approximate it with lots of unadorned blocks and complex object destructuring.
{
const { prop1: a, prop2: A, prop3: xTy } = obj
// …
{
const { prop1: A, prop2: xTy, prop3: a } = obj
// …
}
}
Something like that.Heh.
And randomly add "-Decorator" suffix to class names.
Ages ago, I tried to diplomatically explain to our Senior Architect Grand Poobah (and my team lead) that one set of Decorators are actually Chain of Commands. And that they shouldn't be silently swallowing exceptions.
After a few minutes, he says "u/specialist, I'm surprised someone with your experience doesn't understand architecture." Then gets up and walks away.
And randomly add "-Decorator" suffix to class names.
Ages ago, I tried to diplomatically explain to our Senior Architect Grand Poobah (and my team lead) that one set of Decorators are actually Chain of Commands. And that they shouldn't be silently swallowing exceptions.
After a few minutes, he says "u/specialist, I'm surprised someone with your experience doesn't understand architecture." Then gets up and walks away.
That’s exactly what my company’s legacy code base looks like..
No one wants to reformat the files because then it will mess up with git history.
It was horrendous to look at at first, but I’ve gotten used to it by now and just apply the same random style to whatever snippets I modify. :)
It was horrendous to look at at first, but I’ve gotten used to it by now and just apply the same random style to whatever snippets I modify. :)
> No one wants to reformat the files because then it will mess up with git history.
GitHub will use a file `.git-blame-ignore-revs` to allow blame to ignore commits that make those kind of changes. (This is the format used for the `--ignore-revs-file` option to `git blame`.)
GitHub will use a file `.git-blame-ignore-revs` to allow blame to ignore commits that make those kind of changes. (This is the format used for the `--ignore-revs-file` option to `git blame`.)
Git has something for every occasion I ever encountered with a need for something I knew was technically possible but didn't know if git would let me do it. It let me do it every time, truly the hacker's utility.
[deleted]
Whenever there is a chain of method calls put all in a single line.
Rather than putting identifiers into MOckiNG sPongeBob CasE, it should apply a standard case convention (including initialism, Systems Hungarian with incorrect types, etc) at random for each identifier.
function Make_List(firstString, second_string, chThirdString) {
var a = [firstString, second_string, chThirdString];
return a;
}The problem with this tool is that it’s too easy to revert most of its work (everything except for the case changes in identifiers, AFAICT) using a prettifier.
To make it robust against such adversary attacks it should incorporate the teachings of “How To Write Unmaintainable Code” (https://github.com/Droogans/unmaintainable-code)
To make it robust against such adversary attacks it should incorporate the teachings of “How To Write Unmaintainable Code” (https://github.com/Droogans/unmaintainable-code)
I used to work with a fella that wrote code similar to this. To him, code seemed to be a scratchpad, a place to jot down ideas and try them out. Once an idea worked out, he shipped it. Done.
Impossible to maintain, but damn if he couldn't churn out some quality works. Bug laden, sure, but the core ideas were great – at times even brilliant. There was a certain beauty to the chaos.
Prettier wasn't around then, and code for matters weren't much of a thing at all really. Can't help but think if that would've helped or stymied his process. Certainly would've helped the rest of us though!
Impossible to maintain, but damn if he couldn't churn out some quality works. Bug laden, sure, but the core ideas were great – at times even brilliant. There was a certain beauty to the chaos.
Prettier wasn't around then, and code for matters weren't much of a thing at all really. Can't help but think if that would've helped or stymied his process. Certainly would've helped the rest of us though!
> Impossible to maintain, but damn if he couldn't churn out some quality works. Bug laden, sure
That doesn’t sound like quality work.
I’ve had colleagues like that, they’re a pain in the ass because they look productive at the cost of everyone else holding the bag, and while they’re useful for exploratory or prototypal work it can be difficult to make the stakeholder understand that no the bug-ridden mess with an injection per SQL query is not going into production ever.
I’ve wondered if forcing them to use a very restrictive langage could help channel the mess somewhat.
That doesn’t sound like quality work.
I’ve had colleagues like that, they’re a pain in the ass because they look productive at the cost of everyone else holding the bag, and while they’re useful for exploratory or prototypal work it can be difficult to make the stakeholder understand that no the bug-ridden mess with an injection per SQL query is not going into production ever.
I’ve wondered if forcing them to use a very restrictive langage could help channel the mess somewhat.
> I’ve wondered if forcing them to use a very restrictive langage could help channel the mess somewhat.
StyleCop in C# (and ESLint/Prettier to a lesser extent in JS land) works extremely well for this. It's very quick to red squiggle your style problems when you're writing, can often automatically fix the problem, and keeps everyone committing code that looks one way.
It drove me nuts when I started doing work in a team, but I got used to it quick and we rarely bikeshed now.
StyleCop in C# (and ESLint/Prettier to a lesser extent in JS land) works extremely well for this. It's very quick to red squiggle your style problems when you're writing, can often automatically fix the problem, and keeps everyone committing code that looks one way.
It drove me nuts when I started doing work in a team, but I got used to it quick and we rarely bikeshed now.
> difficult to make the stakeholder understand that no the bug-ridden mess with an injection per SQL query is not going into production ever.
Why do you bother saving the stakeholder from themselves?
Why do you bother saving the stakeholder from themselves?
Usually because you will inevitably get tasked with fixing something in that mess, and will have to slowly sacrifice your soul to get into the warped brain of that 'prodigy' coworker to understand the code if you don't.
Often these people are clients, so it's partly the team job to save them from themselves.
Because the stakeholders often don't have the wherewithal to understand the difference so we shouldn't let the charlatans and terminally flawed take advantage of them.
There is an interesting difference in philosophy in this and the parent. One is the mindset that engineering is a profession and the other something of a market will sort itself out approach.
Unfortunately we’re living in a world where the doors are coming off airplanes mid flight.
Unfortunately we’re living in a world where the doors are coming off airplanes mid flight.
Is that not considered part of a developers job?
[deleted]
Worked with a company that outsourced their code. Contract stated that source code must be provided so in an effort to be pricks, the outsourced company provided their code on fanfold dot matrix printouts using a line printer from the 80s. It arrived in three very heavy boxes not even folded neatly.
This reminded me of that for some reason.
This reminded me of that for some reason.
Malicious Compliance is the term
I could see someone triggering a proper obfuscator (not this) as a time bomb, rendering the code in a permanent frozen feature state - usable but unmaintainable by future employees. (The contract says only to “write code to do this feature…”.) Do contracts provide legal barriers to this?
As a party to a contract, if you act in a way that denies to the other party the benefit to which they are entitled, you could be said to have breached the implicit obligation of good faith and fair dealing that is more or less implied in every contract.
In general it does. doing bad work is better, because you deliver poor quality. but if you deliver something and then break it on purpose, it's like breaking something that belong to the company(not you). Remember that everything you do in a company don't belong to you.
[deleted]
That would be a good way to destroy the reputation of your company lmao. Leaving nothing but horrors in your wake. Kind of funny, though, even if it's cruel to everyone who comes after you.
I'm sure this wouldn't make half as much difference to my code as I'd like to think…
> Random indentation for a chaotic code structure.
One to add if it isn't there already: some blocks indented by tab, some by spaces, some mixed.
> Random indentation for a chaotic code structure.
One to add if it isn't there already: some blocks indented by tab, some by spaces, some mixed.
Cool, now I can copy highly structured and perfectly formatted code from LLMs and make it look I hacked it all on my own last night
wait, you're not running a linter on save?
No, since it DEFINITELY would look like AI generated it.
>Shittier is a purely satirical project
And yet, I'm sure some folks will find serious applications, like in cases of malicious compliance when having to share your code against your will.
And yet, I'm sure some folks will find serious applications, like in cases of malicious compliance when having to share your code against your will.
Minify + Shittier seems like a fun idea to make analysing the code even more painful :D
I was thinking maybe it could be used for debugging, in the same way some have suggested a mode that reassigns names randomly so you can't rely on pattern matching as much
wouldn't that be easily solved by prettier?
I wonder if there are anti patterns you could use that would confound the parser in prettier?
We could create lots of config driven abstractions to confuse anyone without insider knowledge of a company.
Like allowing an application to use several different caching / database setups depending on values in property files.
Java / Spring has so much potential.
Like allowing an application to use several different caching / database setups depending on values in property files.
Java / Spring has so much potential.
Not sure if it has been posted yet, but yes: https://github.com/Droogans/unmaintainable-code
fine i'll minify it then
If it was deterministic - everyone on your team uses it to produce the same formatting, no matter show shitty it is - it would still meet the same goals as Prettier.
I would strongly disagree. People have different preferences on what makes code readable. But I would prefer anyone else's definition of readable to something that aims to objectively make code unreadable.
Consistently unreadable would train you to pick out syntax cues to read the code if actually forced to fix these issues.
Perhaps this could make useful synthetic data for improving large language models improving code, because you could have two pairs of code, better code, and the terrible code. This is probably already done internally at the top AI labs.
But to do that "shittier" would have to get a good implementation and turn on a bad implementation. Formatting might not be enough.
Howerver the main idea is very interesting.
Howerver the main idea is very interesting.
I would presume the code before was better than the code after, so that's how you could get two sets. It might not be much of a boost, it could depend, and I'm sure there are other data augmentation techniques. Good model improvement is usually an iterative loop, trying things out to optimise an objective.
It would be useful in conjunction with other data, but wouldn’t the model just learn the logic of the obfuscation code (unless perhaps you heavily regularised it?)
Yes in conjunction. For causal models like GPT, this sort of approach might help augment data, making it go further when training, or fine-tuning and the model could be trained on "improving" the bad code, actually the existing code. So the before and after would be reversed.
For encoder-decoder models they can can be trained, or fine-tuned on a more explicit translation task.
So just a kind of https://en.wikipedia.org/wiki/Data_augmentation
This reminds me of seeing others' code in the first year of university. There was a pretty basic intro to some language constructs, but for some reason the first exams were done on paper.
People wrote everything without indentation, or with inconsistent spacing. Somehow this also carried over to the code that they'd write in the computer, so it was pretty much unreadable, since you couldn't glance at a block of nested loops and realize what goes where.
People wrote everything without indentation, or with inconsistent spacing. Somehow this also carried over to the code that they'd write in the computer, so it was pretty much unreadable, since you couldn't glance at a block of nested loops and realize what goes where.
I felt so stupid when I had to write code on paper at uni.
This looks very much like the typescript formatter we use...
Is it possible to get something like this: https://i.redd.it/as700946ez9z.jpg , but without the indents? So a flat block of code aligned to the left, and all the brackets in a column on the right?
...just trying to be evil... :)
...just trying to be evil... :)
I found this while browsing the web a few days ago, exactly what you wanted :O
https://dimden.dev/beautifier/
https://dimden.dev/beautifier/
I cant decide whether I think this is supremely evil or just mad genius. Supremely evil mad genius maybe? :o)
I thought it was absolutely genius but I will never admit it.
But seriously, if anyone is to maintain code like this, this will force the lowest possible cyclomatic complexity.
But seriously, if anyone is to maintain code like this, this will force the lowest possible cyclomatic complexity.
Exactly, and to me that's the genius part. I feel almost dirty for kinda liking it.
You can't just force a python programmer to start coding in java without mental health support.
[deleted]
That's simply CoffeeScript, if you set an awkward screen resolution to overflow the screen on the right.
In Python it should turn a list of strings
Also possible in C and C++:
["foobar", "baz"]
into [
"foo"
"bar",
"baz"
]
to infuriate people further.Also possible in C and C++:
char * strings[] = {
"foo"
"bar",
"baz"
};What is wrong with the C example? I split array literals like that.
What is this internet law about not knowing satire from "lunatics" called now again ...
What is this internet law about not knowing satire from "lunatics" called now again ...
This comment really drives the point home
Needs a --check that enforces a minimum number of prettier violations per 100 lines :^)
I know this is satirical, but I would actually use this with my web development students as an exercise if it introduced more subtle shittiness that they would have to fix.
Having a code generator for each and everything mandating accutely expensive dependencies (massive and complex scripting language/templating SDK) is brilliant too...
Please make sure to ship this as a prebuilt .exe file.
Not nearly as shitty as the code I have to work with
Sometimes the nightmare is some mix of organized and chaotic. I had the responsibility of rewriting from scratch a C codebase that was deliberately obfuscated. The spacing and bracketing and general code style was almost perfect. But every name was obfuscated into nonsensical single letters and contractions, and every ostensibly simple math operation was separated into a multiline series of single stateful operations on a variable. Plus, global variables.
Surprised I managed to do it at all, but it was circumstantial evidence for what each operation did that helped immensely, plus a few logical and mathematical lightbulb moments. Rewriting it in Nim has also helped me make it well-organized and self-documenting. I have a document full of pseudocode but it looks basically exactly the same as the Nim code!
Surprised I managed to do it at all, but it was circumstantial evidence for what each operation did that helped immensely, plus a few logical and mathematical lightbulb moments. Rewriting it in Nim has also helped me make it well-organized and self-documenting. I have a document full of pseudocode but it looks basically exactly the same as the Nim code!
for when a company want the opensource label but is too selfish to share.
A reminder that spaghettify exists too https://www.spaghettify.dev/
Emoji comments, that's something I'm taking home, thanks
Can you make it so it takes my beautifully arranged imports and mushes them together using brackets and commas? Oh wait..
A.K.A job security.
With some smudge/clean filter or wathcamacallit you can make your job easy at the same time.
[deleted]
1. Convert leading indentation to tabs or spaces at random.
2. Insert trailing spaces.
3. Use varying indentation styles - pick at random from: https://en.wikipedia.org/wiki/Indentation_style#Overview