1. PHP / Говнокод #10939

    +55

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $i = 0;
    foreach($_POST['union'] as $key=>$value) {
    	$i++;
    	if ($i == 1) {
    		$fid = $key;
    	}
    	if ($i > 1) {
    		[код поскипан]
    	}
    }

    Ну почему не используется if { } else { }?

    domaster, 13 Июня 2012

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

    −121

    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
    Функция ЧерезНоль(Значность) Экспорт
    	Оборот=10;
    	Если Значность=2 Тогда
    		Оборот=100;
    	ИначеЕсли Значность=3 Тогда
    		Оборот=1000
    	ИначеЕсли Значность=4 Тогда
    		Оборот=10000
    	ИначеЕсли Значность=5 Тогда
    		Оборот=100000
    	ИначеЕсли Значность=6 Тогда
    		Оборот=1000000
    	ИначеЕсли Значность=7 Тогда
    		Оборот=10000000
    	ИначеЕсли Значность=8 Тогда
    		Оборот=100000000
    	ИначеЕсли Значность=9 Тогда
    		Оборот=1000000000
    	ИначеЕсли Значность=10 Тогда
    		Оборот=10000000000
    	ИначеЕсли Значность=11 Тогда
    		Оборот=100000000000
    	ИначеЕсли Значность=12 Тогда
    		Оборот=1000000000000
    	ИначеЕсли Значность=13 Тогда
    		Оборот=10000000000000
    	ИначеЕсли Значность=14 Тогда
    		Оборот=100000000000000
    	ИначеЕсли Значность=15 Тогда
    		Оборот=1000000000000000
    	КонецЕсли;	
     Возврат Оборот		
    КонецФункции

    суровое возведение в степень)

    dmurdoc, 13 Июня 2012

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

    −37

    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
    static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        QPainterPath::MoveToElement, QPainterPath::LineToElement,
        ... еще 12 строк ...
        QPainterPath::MoveToElement, QPainterPath::LineToElement
    };
    
    static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 1
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 2
        ... еще 29 строк ...
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 31
        QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 32
    };

    Qt 4.x.x, src/gui/painting/qpaintengineex.cpp
    Как я понял, используется для ускорения функций drawLines и clip (дабы не выделять память и не заполнять path каждый раз).

    bormand, 13 Июня 2012

    Комментарии (37)
  4. C# / Говнокод #10936

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    return status == TestStatus.Skipped
                        ? TestResultStatus.Skiped
                        : status == TestStatus.Inconclusive
                        ? TestResultStatus.Skiped
                        : status == TestStatus.Failed
                        ? TestResultStatus.Failed
                        : status == TestStatus.Passed
                        ? TestResultStatus.Passed 
                        : TestResultStatus.Failed;

    dirtygopher, 13 Июня 2012

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

    −51

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void a() 
    {
    }
     
    void b()
    {
      return a();
    }

    Компилится.
    http://ideone.com/8eP1w

    HaskellGovno, 13 Июня 2012

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function out(message) {
        try {
            alert(message);
        } catch (e) {
            try {
                document.write(message);
            } catch (e) {
                throw "Cannot write";
            }
        }
    }

    хуита, 13 Июня 2012

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

    +69

    1. 1
    $file[] = $_FILES[''.$key.''];

    Подобное "приведение типов (?)" для $key просто убивает. Размазано по всему проекту...

    domaster, 13 Июня 2012

    Комментарии (4)
  8. Pascal / Говнокод #10930

    +95

    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
    function IntToHex(Num: Int64; Digits: Byte): String;
    type
      DataInt = Array[0..7] of Byte;
    var
      I:Byte;
      Data: ^DataInt;
    begin
      Data := @Num;
      Result := '';
      for I := Trunc(Digits/2)-1 downto 0 do begin
        if SizeOf(DataInt) < I then
          Result := Result+'00'
        else begin
          case Data^[I] of
            0: Result := Result+'00';
            1: Result := Result+'01';
            2: Result := Result+'02';  
            { ........... }
            253: Result := Result+'FD'; 
            254: Result := Result+'FE';      
            255: Result := Result+'FF';
           end;
        end;
      end;
    end;

    Давно писал функцию для перевода числа в 16-ричное представление.
    Причина - нужно было отдельную функцию без лишнего.
    Вот такой вот жестокий быдло код :))

    haker, 13 Июня 2012

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

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    static char[] decToBin(int n)
    {
        byte size = sizeof(int) * 8;
        char[] result = new char[size];
    
        for (int i = 0; i < size; i++) 
        {
            result[size - i - 1] = (((n >> i) & 1).ToString().ToCharArray()[0]);
        }
        return result;
    }

    Плохо пахнущий транслятор непосредственно в дополнительный код.

    vistefan, 12 Июня 2012

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

    +52

    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
    <?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
    <?if (!empty($arResult)):?>
    <ul id="horizontal-multilevel-menu">
    <?
    $previousLevel = 0;
    foreach($arResult as $arItem):?>
    	<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
    		<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
    	<?endif?>
    	<?if ($arItem["IS_PARENT"]):?>
    		<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    			<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a>
    				<ul>
    		<?else:?>
    			<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>" class="parent"><?=$arItem["TEXT"]?></a>
    				<ul>
    		<?endif?>
    	<?else:?>
    		<?if ($arItem["PERMISSION"] > "D"):?>
    			<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    				<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a></li>
    			<?else:?>
    				<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li>
    			<?endif?>
    		<?else:?>
    			<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    				<li><a href="" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
    			<?else:?>
    				<li><a href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
    			<?endif?>
    		<?endif?>
    	<?endif?>
    	<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
    <?endforeach?>
    <?if ($previousLevel > 1)://close last item tags?>
    	<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
    <?endif?>
    </ul>
    <div class="menu-clear-left"></div>
    <?endif?>

    Очередной говнокод от битрикса. "Генерация" выпадающего горизонтального меню.

    avtorfox, 12 Июня 2012

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