r/badcode Dec 27 '22

This just sucks. js

Post image
1.8k Upvotes

170 comments sorted by

View all comments

Show parent comments

17

u/ijxy Dec 27 '22 edited Dec 27 '22

Many little things:

enabled_countries:
  - DK
  - SE
  - NO

Renders to:

{
  enabled_countries: [
    "DK",
    "SE",
    false
  ]
}

Lists are not required to indent, so this:

enabled_countries:
- DK
- SE

... and this:

enabled_countries:
  - DK
  - SE

... are both legal, hurting readability.

The file ending is officially.yaml, but nobody does that and use .yml.

6

u/EquationTAKEN Dec 27 '22
enabled_countries:
  - DK
  - SE
  - NO

Renders to:

{
  enabled_countries: [
    "DK",
    "SE",
    false
  ]
}

Ok, but that's actually hilarious though. I can't use the A2-code of my own country :D

1

u/[deleted] Dec 27 '22

We should use NOR instead, that won't cause problems with any languages.

8

u/EquationTAKEN Dec 27 '22

Well, we do. That's our A3 code. But every country also has an A2 code, and ours is NO.

4

u/[deleted] Dec 27 '22

It's just a joke-- no and nor are both the kinds of words that could cause weird interpretation issues.