1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #23858

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    var i, j;
    
    loop1:
    for (i = 0; i < 3; i++) {      //The first for statement is labeled "loop1"
       loop2:
       for (j = 0; j < 3; j++) {   //The second for statement is labeled "loop2"
          if (i === 1 && j === 1) {
             continue loop1;
          }
          console.log('i = ' + i + ', j = ' + j);
       }
    }

    Метки в js. Баян?
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

    vistefan, 03 Марта 2018

    Комментарии (6)
  3. C++ / Говнокод #23835

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    class PriceCache {
    public:
      FlightStorage(const std::size_t count) {
        for (std::size_t i = 0; i < count; ++i) {
          flights.emplace_back(FlightCache::get(i));
          prices.emplace_back(&flights.back(), Price::getFor(flights.back()));
        }
      }
    
    private:
      std::vector<Flight> flights;
      std::vector<const Flight *, double> prices;
    };

    "случайные сегфолты при обращении к PriceCache::prices"

    Elvenfighter, 28 Февраля 2018

    Комментарии (6)
  4. Swift / Говнокод #23691

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    public class DialogBuilder: NSObject {
    
        private var style: UIAlertControllerStyle
        private var titleColor: UIColor?
    
        /**
         * initial DialogBuilder with UIAlertControllerStyle and  for title color
         */
        public init(style: UIAlertControllerStyle = .alert, titlecolor : UIColor?) {
            self.style = style
            if(titlecolor != nil)
            {self.titleColor = titlecolor}
        }
        /**
         * initial DialogBuilder with UIAlertControllerStyle
         */
        public init(style: UIAlertControllerStyle = .alert) {
            self.style = style
        }
    
        ...
    }

    wwweshka, 31 Января 2018

    Комментарии (6)
  5. Swift / Говнокод #23686

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    func onlyCashLessEUR(_ rates : [CurrencyRateMto]) ->  CurrencyRateItem {
        var EUR : CurrencyRateItem? = nil
        let cashLessEUR = rates.filter({$0.type.enumValue == CurrencyRateTypeMtoEnum.CASHLESS && $0.currency.isEUR() == true})
        if(cashLessEUR.count > 0){
            EUR = CurrencyRateItem(
                cashLessEUR.first?.currency.getIcon(),
                (cashLessEUR.first?.currency.id)!,
                NumberFormatting.sum(cashLessEUR.first?.buyPrice?.price),
                NumberFormatting.sum(cashLessEUR.first?.sellPrice?.price))
        }
        if(EUR == nil){
            EUR = CurrencyRateItem(
                UIImage.init(named: "currency_eur"),
                "EUR",
                "-",
                "-")
        }
        return EUR!
    }

    "Я форматирую как далбаёб, и мне похер на то, что cashLessEUR.first опционален, я буду его юзать дальше".

    wwweshka, 30 Января 2018

    Комментарии (6)
  6. Python / Говнокод #23682

    +1

    1. 1
    OrderedDict().fromkeys(['key1', 'key2', 'key3'], [])

    Снова сел на грабли с изменяемыми объектами

    syoma, 29 Января 2018

    Комментарии (6)
  7. C# / Говнокод #23671

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public static class TaskExtension
    	{
    		// Silences compiler warning: Because this call is not awaited,
    		// execution of the current method continues before the call is completed.
    		// Consider applying the 'await' operator to the result of the call
    		[MethodImpl(MethodImplOptions.AggressiveInlining)]
    		public static void NoWarning(this Task task) { }
    	}

    Коллеги добавили в код после введения правила treat warnings as errors

    cherepets, 25 Января 2018

    Комментарии (6)
  8. JavaScript / Говнокод #23628

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var id = setTimeout(function timer() {
    	var d = new Date()
    	document.getElementById('text').innerHTML = (d.getHours() < 10 ? '0'+d.getHours() : d.getHours())+':'+(d.getMinutes() < 10 ? '0'+d.getMinutes() : d.getMinutes() )+':'+(d.getSeconds() < 10 ? '0'+d.getSeconds() : d.getSeconds())
    	id = setTimeout(timer, 1000)
    }, 1000)

    Вот чем крут js это простотой и ненадобности ставить точки с запятыми!

    fuckercoder, 30 Декабря 2017

    Комментарии (6)
  9. Си / Говнокод #23566

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    #define POLY 0x8408
    /*
    //                                      16   12   5
    // this is the CCITT CRC 16 polynomial X  + X  + X  + 1.
    // This works out to be 0x1021, but the way the algorithm works
    // lets us use 0x8408 (the reverse of the bit pattern).  The high
    // bit is always assumed to be set, thus we only use 16 bits to
    // represent the 17 bit value.
    */
    
    unsigned short crc16(unsigned char *data_p, size_t length)
    {
      unsigned char i;
      unsigned int data;
    
      if ( length == 0 ) return 0;
      unsigned int crc = 0xFFFF;
      do
      {
        data = *data_p++;
        for ( i=0; i < 8; i++ )
        {
          if ( (crc ^ data) & 1 )
            crc = (crc >> 1) ^ POLY;
          else
            crc >>= 1;
          data >>= 1;
        }
      } while ( --length != 0 );
    
      crc = ~crc;
      data = crc;
      crc = (crc << 8) | ((data >> 8) & 0xff);
      return (unsigned short)(crc);
    }

    Типичный пример непортабельной хуйни на Си.

    j123123, 07 Декабря 2017

    Комментарии (6)
  10. Java / Говнокод #23521

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    while( (i=xyi.read()) != -1 )
    	    {
    	    	al.add( i+b-e*b*e+b+e-b+e-b+e+e+e+e+b-b-e+b+b-xer*e-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer );
    	    }
    	    for(int n=0; n<al.size(); n++)
    	    	out.println(al.get(n));
    	    out.println("\nА теперь ебашим в обратку...");
    	    Thread.sleep(1000);
    	    int pizdec;
    	    for(int n=0; n<al.size(); n++)
    	    {
    	    	i = al.get(n);
    	    	pizdec = i+xer*e-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-xer-b+e-b+e-b+e+e+e+e+b-b-e+b+b+e*b*e-b;
    	    	out.print((char)pizdec);
    	    }

    пиздец сложный код!
    выдаёт вот что: ◇◓▸○◇◊○◘▎●◔▏□╰╯▆▆▆▆●◔◚▆●▣▖□╰╯▆▆▆▆●◔◚▆◈▣▝ ▝▒▆○▣▟▟▟▒▆◞○◘▣▗▙□╰╯▆▆▆▆▧◘◘◇◟▲●◙◚▢▯◔◚○◍○◘ ▤▆◇◒▆▣▆◔○◝▆▧◘◘◇◟▲●◙◚▢▤▎▏□╰╯▆▆▆▆◝◎●◒○▎▆▎● ▣◞◟●▔◘○◇◊▎▏▏▆▇▣▆▓▗▆▏╰╯▆▆▆▆◡╰╯▆▆▆▆╯◇◒▔◇◊◊ ▎▆●░◈▓○▐◈▐○░◈░○▓◈░○▓◈░○░○░○░○░◈▓◈▓○░◈░◈▓ ◞○◘▐○▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○ ◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▆▏□╰╯▆▆▆▆◣╰ ╯▆▆▆▆◌◕◘▎●◔◚▆◔▣▖□▆◔▢◇◒▔◙●◠○▎▏□▆◔░░▏╰╯▆▆▆ ▆╯◕◛◚▔◖◘●◔◚◒◔▎◇◒▔◍○◚▎◔▏▏□╰╯▆▆▆▆◕◛◚▔◖◘●◔◚ ◒◔▎█◂◔⥶▆⦨⦛⦥⦛⦦⦲▆⦛⦗⦖⦮⦞⦢▆⦘▆⦤⦗⦦⦖⦨⦠⦩▔▔▔█▏□╰╯▆ ▆▆▆►◎◘○◇◊▔◙◒○○◖▎▗▖▖▖▏□╰╯▆▆▆▆●◔◚▆◖●◠◊○◉□╰ ╯▆▆▆▆◌◕◘▎●◔◚▆◔▣▖□▆◔▢◇◒▔◙●◠○▎▏□▆◔░░▏╰╯▆▆▆ ▆◡╰╯▆▆▆▆╯●▆▣▆◇◒▔◍○◚▎◔▏□╰╯▆▆▆▆╯◖●◠◊○◉▆▣▆● ░◞○◘▐○▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞ ○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◞○◘▓◈░○▓◈░○▓◈ ░○░○░○░○░◈▓◈▓○░◈░◈░○▐◈▐○▓◈□╰╯▆▆▆▆╯◕◛◚▔◖◘ ●◔◚▎▎◉◎◇◘▏◖●◠◊○◉▏□╰╯▆▆▆▆◣╰╯◣╰╯◉◇◚◉◎▎▯▵▫◞ ◉○◖◚●◕◔▆○▏▆◡╰╯╯◕◛◚▔◖◘●◔◚◒◔▎█⦫⦩⦟▆⦨⦖⦢▆⦥⦡⦖⦘ ⦖⦡▇█▏□╰╯◣╰▆▆◣╰◣╰

    FlowerGay, 13 Ноября 2017

    Комментарии (6)
  11. bash / Говнокод #23518

    −7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #!/bin/bash
    echo Я говно на баш!
    while true; do
    read PS1
    PS2="${PS2} ${PS1} Смищно правда?"
    echo $PS2
    don

    RUSSIAN-PROGRAMMER, 11 Ноября 2017

    Комментарии (6)