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

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    StringBuilder text = new StringBuilder();
    for (char letter : section.getName().toCharArray()){
        text.append(Character.toUpperCase(letter));
    }

    Вот так мы приводим текст к верхнему регистру

    ingenuus, 01 Июля 2016

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

    +6

    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
    $query_list_builder = array(
    	'1000' => " and account = $account_id and creator = $creator_id",
    	'0100' => " and account = $account_id and salepoint = $salepoint_id and creator <> $creator_id ",
    	'0010' => " and account = $account_id and creator <> $creator_id and salepoint <> $salepoint_id ",
    	'0001' => " and account IN ($watchlist) and creator <> $creator_id and salepoint <> $salepoint_id and account <> $account_id ",
    
    	'1100' => " and salepoint = $salepoint_id or creator = $creator_id and account = $account_id ",
    	'1010' => " and account = $account_id and salepoint <> $salepoint_id or creator = $creator_id ",
    	'1001' => " and account IN ($watchlist) and account <> $account_id or creator = $creator_id ",
    
    	'1110' => " and account = $account_id or creator = $creator_id and salepoint = $salepoint_id ",
    	'1101' => " and account IN ($watchlist) and account <> $account_id or creator = $creator_id or salepoint = $salepoint_id ",
    
    	'1111' => " and account IN ($watchlist) or account = $account_id or creator = $creator_id or salepoint = $salepoint_id ",
    	'0000' => " and creator <> $creator_id and salepoint <> $salepoint_id and account NOT IN ($watchlist) ",
    
    	'0011' => " and account IN ($watchlist) and salepoint <> $salepoint_id and creator <> $creator_id ",
    	'0111' => " and account IN ($watchlist) and creator <> $creator_id ",
    	'0110' => " and account = $account_id and creator <> $creator_id ",
    	'0101' => " and account IN ($watchlist) and account <> $account_id or salepoint = $salepoint_id and creator <> $creator_id ",
    	'1011' => " and account IN ($watchlist) and salepoint <> $salepoint_id or creator = $creator_id ",
    );

    daniser, 30 Июня 2016

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public void сдвинутьРяд()
      {
        this.caseInventory.setItem(24, this.caseInventory.getItem(23));
        this.caseInventory.setItem(23, this.caseInventory.getItem(22));
        this.caseInventory.setItem(22, this.caseInventory.getItem(21));
        this.caseInventory.setItem(21, this.caseInventory.getItem(20));
        this.caseInventory.setItem(20, null);
      }

    хмхмхмхмххмхмхм

    brinza, 28 Июня 2016

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

    +6

    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
    switch ($m->type) {
    			case 'photo':
    				echo sprintf('<div class="fb_photo %s"><a %s href="%s"><div style="background-image: url(\'%s\');"><b>%s</b><br>%s%s<div class="status">%s <img src="%s" /> %s <img src="%s" /></div></div></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), str_replace("_s", "_n", $m->picture), $m->from->name, (!empty($m->message) ? $m->message.'<br>' : ''), ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			case 'video':
    			case 'link':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				//echo sprintf('<div class="fb_link"><a href="%s"><div><img src="%s" /><b>%s</b><br>%s<div class="status">%s likes, %s comments</div></div></div></div>', $m->link, str_replace("_s", "_n", $m->picture), $m->from->name, $m->message, $m->likes->count, $m->comments->count);
    				break;
    			case 'status':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), '', '', $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			default:
    				//echo 'TODO: ' . $m->type;
    				//var_dump($m);
    				break;
    		}

    Верстка.
    Уровень - бог.

    valentinlazy, 27 Июня 2016

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

    +6

    1. 1
    habrahabr.ru/post/113215/

    Кодогенерируем вместе!

    dm_fomenok, 21 Июня 2016

    Комментарии (8)
  7. PHP / Говнокод #20199

    +6

    1. 1
    2. 2
    3. 3
    # https://github.com/mpak2/mpak.su/blob/607ee884dddc1df541aefc4f3b06ea5c2bfa4470/modules/users/pass.php
    
    if($_POST['new'] && $_POST['new'] == $_POST['ret']){

    Сравнение пароля на ==

    Для тех кто не знает, http://ideone.com/yPjk4K

    3_dar, 15 Июня 2016

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    > var x = new String("eval(x.toString())");
    undefined
    > eval(x.toString());
    RangeError: Maximum call stack size exceeded

    Yo dawg, I heard you like evaluation. So I put evaluation in your evaluation so you could evaluate while you evaluate
    Жаль что nodejs не осиливает заоптимизировать это как бесконечный цикл

    j123123, 31 Мая 2016

    Комментарии (20)
  9. C++ / Говнокод #20076

    +6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    for(int i = 0; i < codes.size(); ++i) {
        switch(i) {
            case 0: ret.code0 = codes[i]; break;
            case 1: ret.code1 = codes[i]; break;
            case 2: ret.code2 = codes[i]; break;
            case 3: ret.code3 = codes[i]; break;
            case 4: ret.code4 = codes[i]; break;
            case 5: ret.code5 = codes[i]; break;
        }
    }

    А всё потому, что ret.code[0-5] - битовые поля. Эх.

    Xom94ok, 25 Мая 2016

    Комментарии (58)
  10. C# / Говнокод #20075

    +6

    1. 1
    https://github.com/pascalabcnet/pascalabcnet

    ШОК! Говном компилируется говно. Это рекорд

    dm_fomenok, 25 Мая 2016

    Комментарии (59)
  11. C# / Говнокод #20058

    +6

    1. 1
    2. 2
    3. 3
    if (selectedGroup == null)
        return null;
    return selectedGroup;

    зачем if то?

    kontora, 23 Мая 2016

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