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

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private void showProgress() {
        if(mIndProgressVisible && mIndProgress != null && mIndProgress.isShowing()) return;
        if(!mIndProgressVisible && (mIndProgress == null || !mIndProgress.isShowing())) return;
    
        ...
    }

    Не ходите, дети, в Африку гулять

    StanDalone, 30 Декабря 2014

    Комментарии (2)
  3. 1C / Говнокод #17327

    −124

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    Процедура Флажок1ПриИзменении(Элемент)
    	
    	//выбираем контрагента
    	ТК	= табК.найти(Контрагент, "контрагент");
    	
    	Первый	= 2+2;
    	для кк=0 по табК.Количество()-1 цикл
    		элементыформы.МаршрутныйЛистК.Область("C"+число(кк*3+1+Первый)).Видимость	= (ОтобразитьВсеМеста и ТабК[кк]=ТК);
    	конеццикла;	
    	
    	
    КонецПроцедуры

    Продукт "1С:Молокозавод. Международная поставка для пользователей "1С:Управление производственным предприятием "
    Форма документа "МОЛ_ЗаказПоМаршруту".
    Фирма "ЦНТУиК" (ЗАО "Центр научно-технических услуг и консультаций").
    Не понятно что они курят.

    x-salik, 18 Декабря 2014

    Комментарии (2)
  4. Java / Говнокод #17320

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static long inFuture(final long time, final long current, final int period) {
            long newtime = current;
            while (newtime < current) {
                newtime += period;
            }
            return newtime;
        }

    я сегодня продуктивен )
    на этот раз...
    последовательный инкремент = )

    Lure Of Chaos, 15 Декабря 2014

    Комментарии (2)
  5. Куча / Говнокод #17283

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    # Path for asterisk
    # Default Value: /usr/sbin/asterisk
    WHICH_asterisk=/usr/sbin/asterisk
    
    # Path for rm
    # Default Value: /bin/rm
    WHICH_rm=/bin/rm
    
    # Path for tail
    # Default Value: /usr/bin/tail
    WHICH_tail=/usr/bin/tail

    Конфигурационный файл amportal.conf в freepbx :)

    shinespb, 10 Декабря 2014

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

    +153

    1. 1
    2. 2
    3. 3
    var getSelectedTabName = function() {
      return $('#costs-category').find('.tabs-v4-i_active').find('.tabs-v4-l').data('category_alias');
    };

    Кто-то ниасилил селекторы в jquery

    fake, 01 Декабря 2014

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

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private bool CompareLvlCats(string[] cat,List<string[]> cats, int lvl)
    {
        if (lvl == 1) return cats.Find(x => x[0] == cat[0] && (x[1] != cat[1] ||x[1]!="")) != null;
        if (lvl == 2) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && (x[2] != cat[2] || x[2] != "")) != null;
        if (lvl == 3) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && (x[3] != cat[3] || x[3] != "")) != null;
        if (lvl == 4) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && x[3] == cat[3] && (x[4] != cat[4] || x[4] != "")) != null;
        if (lvl == 5) return cats.Find(x => x[0] == cat[0] && x[1] == cat[1] && x[2] == cat[2] && x[3] == cat[3] && x[4] == cat[4] && (x[5] != cat[5] || x[5] != "")) != null;
        if (lvl == 6) return false;
        return false;
    }

    Здесь мы идём снова.

    pushistayapodmyshka, 29 Ноября 2014

    Комментарии (2)
  8. C++ / Говнокод #17206

    +51

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    QDir startupFolder = QDir(AppSettings->value("SoftStartupFolder").toString());
    if (!startupFolder.isAbsolute())
    {
        startupFolder.setPath(QCoreApplication::applicationDirPath()+QDir::separator()+AppSettings->value("SoftStartupFolder").toString());
        startupFolder = QDir(startupFolder.absolutePath());
    }

    а иначе дальше файлы будут честно искаться в папке с названиями из точки или двух, а относительные пути браться от чего угодно кроме текущей папки или папки с прогой.

    kin63camapa, 28 Ноября 2014

    Комментарии (2)
  9. Java / Говнокод #17175

    +72

    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
    private String shutdown = "SHUTDOWN";
    
    ........
    
    // Read a set of characters from the socket
    int expected = 1024; // Cut off to avoid DoS attack
    
    <--Зачем это тут?-->
    while (expected < shutdown.length()) {
        if (random == null)
            random = new Random();
        expected += (random.nextInt() % 1024);
    }
    
    
    while (expected > 0) {
        int ch = -1;
        try {
            ch = stream.read();
        } catch (IOException e) {
            log.warn("StandardServer.await: read: ", e);
            ch = -1;
        }
        if (ch < 32)  // Control character or EOF terminates loop
            break;
        command.append((char) ch);
        expected--;
    }

    Не понимаю зачем тут while. Авторы Apache Tomcat расскажите...

    mrFoxs, 25 Ноября 2014

    Комментарии (2)
  10. JavaScript / Говнокод #17135

    +159

    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
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    function get() {
      var a, g, d = app.vk.friend.OSS;
      1 > db.contacts.length && VK.api( "friends.get", {fields: "photo_rec,contacts"}, function ( j )
      {
        if ( j.response )
        {
          try
          {
            app.vk.friend.inited = !1;
            g = j.response.length;
            var e = [], b, f = null, m = null;
            for ( a = 0; a < g; a++ )
            {
              b = j.response[a].mobile_phone || "";
              var m = f = null, c = b.match( /\d/g );
              if ( !c || !(7 == c.length && "9" == c[0] || 10 == c.length || 11 == c.length) )
              {
                b = null;
              }
              b && 11 == c.length && (b = "bbbccccccc".replace( "a", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "b", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ).replace( "c", c[10] ));
              b && 10 == c.length && (b = "bbbccccccc".replace( "b", c[0] ).replace( "b", c[1] ).replace( "b", c[2] ).replace( "c", c[3] ).replace( "c", c[4] ).replace( "c", c[5] ).replace( "c", c[6] ).replace( "c", c[7] ).replace( "c", c[8] ).replace( "c", c[9] ));
              b && (7 == c.length && "9" == c[0]) && (b = null);
              b && 10 == c.length && (f = c[0] + c[1] + c[2]);
              b && 11 == c.length && (f = c[1] + c[2] + c[3]);
              b && (e[e.length] = b);
              m = d[null != f ? 2 : 0];
              db.contacts[db.contacts.length] = {uid: j.response[a].uid, first_name: j.response[a].first_name, last_name: j.response[a].last_name, name: j.response[a].first_name + " " + j.response[a].last_name, photo: j.response[a].photo || j.response[a].photo_rec || j.response[a].photo_big, phoneOrig: j.response[a].mobile_phone || "", phone: b, mask: f, oper: m, oper_i: m == d[1] ? 2 : m != d[0] ? 1 : 0, app_status: 0}
            }
            var p, i = app.scnet.form.checkNumbers( e );
            g = i.SUBSCRIBER && i.SUBSCRIBER.length ? i.SUBSCRIBER.length : i.SUBSCRIBER ? 1 : 0;
            1 == g && (i.SUBSCRIBER = [i.SUBSCRIBER]);
            for ( a = 0; a < g; a++, p = null )
            {
              1 == i.SUBSCRIBER[a].SELF && (p = db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN )), p && (db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper = d[1], db.contacts.find( "phone", i.SUBSCRIBER[a].MSISDN ).oper_i = 2);
            }
            document.all ? setTimeout( app.vk.friend.getAppFri, 1E3 ) : document.all || app.vk.friend.getAppFri()
          }
          catch ( t )
          {}
        }
      } )
    }

    Здесь прекрасно всё, и как картины Босха можно рассматривать эту лапшу бесконечно.

    bodeaux, 19 Ноября 2014

    Комментарии (2)
  11. Assembler / Говнокод #17114

    +147

    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
    strnstr proc
    	jrcxz @@3
    	push rdi
    	push rsi
    	mov rdi,rdx
    	mov al,[r9]
    	inc r9
    	dec r8
    @@1:
    	repne scasb
    	jne @@2
    	cmp rcx,r8
    	jb @@2
    	mov rsi,r9
    	mov rdx,rdi
    	mov r10,rcx
    	mov rcx,r8
    	repe cmpsb
    	je @@2
    	mov rcx,r10
    	mov rdi,rdx
    	jmp @@1
    @@2:
    	sete al
    	movzx rax,al
    	neg rax
    	and rax,rdi
    	pop rsi
    	pop rdi
    	ret
    @@3:
    	xor rax,rax
    	ret
    strnstr endp

    PSTR __fastcall strnstr(SIZE_T n1, const void* str1, SIZE_T n2, const void* str2);

    zhukas, 15 Ноября 2014

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