1. C++ / Говнокод #9472

    +1005

    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
    unsigned
    int
    length () {
    
        unsigned
        int
            number = (this -> number + 1) % 16;
        int
            second = size - number;
    
    
        return (second / 16) + (1 % ((second % 16) + 1)) + (1 % (number + 1));
    }

    Вот такая фигня у нас в коде, работающем в аппаратуре отображения и протоколирования данных на АЭС.
    Авторское форматирование сохранено.

    Нашли когда оно с новыми конфигами стало падать от деления на ноль при запуске.

    Balthasar, 17 Февраля 2012

    Комментарии (33)
  2. PHP / Говнокод #9471

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) > 47)
    	$_POST["NEW_LOGIN"] = substr($arResult["AUTH"]["NEW_LOGIN"], 0, 47);
    
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) < 3)
    	$arResult["AUTH"]["NEW_LOGIN"] .= "_";
    
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) < 3)
    	$arResult["AUTH"]["NEW_LOGIN"] .= "_";

    битрикс, компонент sale.order.ajax

    ast, 17 Февраля 2012

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

    +116

    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
    bool IsAdd = false;
    
    
                if (EditAnalysisTable.Rows.Count == 1)
                {
                    if (EditAnalysisTable.Rows[0][4].ToString() == string.Empty)
                    {
                        drow = EditAnalysisTable.Rows[0];
                    }
                    else
                    {
                        IsAdd = true;
                    }
                }
                else
                {
                    IsAdd = true;
                }
                if (IsAdd)
                {
                    drow = EditAnalysisTable.NewRow();
                    EditAnalysisTable.Rows.Add(drow);
                }

    Indian style: у них свои законы логики

    Nataly, 17 Февраля 2012

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

    +176

    1. 1
    2. 2
    3. 3
    public function setPIDorSEORedirect($id, $disableVarName = '') {
            ........
    }

    отличное название метода)))

    aleksssmix, 17 Февраля 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    if ((ddlProbType.Text != "" && ddlProbType.Text != "Select") && (txtDesc.Text != ""))
                {
                    if ((txtDesc.Text.Trim() == string.Empty))
                    {

    Indian style: чем больше скобок, тем лучше!

    Nataly, 17 Февраля 2012

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

    +145

    1. 1
    а у самих на сайте (http://govnokod.ru/) при входе если после OpenID поставить пробел, то войти нельзя!

    Nataly, 17 Февраля 2012

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

    +155

    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
    <?php
    //скрипт для выполнения SQL запросов
    function runQuery($str = false, $returnType='', $indexField = false, $from = false, $limit = false, $aggregate = false)
    {
    	if (!$str){ //Проверка на наличие SQL
    		return false;
    	}
    	
    	//Будем сохранять SQL запросы с результатами в cache
    	//Для этого создадим массив глобальный
    	if (!isset($GLOBALS['dbcache'])){
    		$GLOBALS['dbcache'] = array();
    	}
    	//Но использовать этот cache не будем
    	if (0 && isset($GLOBALS['dbcache'][$str])){
    		$this->cached = true;
    		return $GLOBALS['dbcache'][$str];
    	}
    	
    	//...
    	//Строки для получения данных с SQL, записываються в $retValue
    	//...
    	
    	//Вот получили результат, сохраним его в ранее заданный массив
    	if ($str != 'SELECT LAST_INSERT_ID()'){
    		$GLOBALS['dbcache'][$str] = $retValue;
    	}
    	return $retValue;
    }

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

    Edd, 17 Февраля 2012

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

    +158

    1. 1
    2. 2
    3. 3
    public function setExludeSection($string) {
            $this->setExcludeSection($string);
    }

    исправление опечаток)))

    aleksssmix, 17 Февраля 2012

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

    +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
    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
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    scheme (i1 i2 i3 i4 i5 i6 i7) major7 (out):
    Local l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11 l12 l13 l14 l15 l16 l17 l18 l19 l20 l21 l22 l23 l24 l25 l26 l27 l28 l29 l30 l31 l32 l33 l34
    (i1 i2 i3 i4) alo (l1)
    (i1 i2 i3 i5) alo (l2)
    (i1 i2 i3 i6) alo (l3)
    (i1 i2 i3 i7) alo (l4)
    (i1 i2 i4 i5) alo (l5)
    (i1 i2 i4 i6) alo (l6)
    (i1 i2 i4 i7) alo (l7)
    (i1 i2 i5 i6) alo (l8)
    (i1 i2 i5 i7) alo (l9)
    (i1 i2 i6 i7) alo (l10)
    (i1 i3 i4 i5) alo (l11)
    (i1 i3 i4 i6) alo (l12)
    (i1 i3 i4 i7) alo (l13)
    (i1 i3 i5 i6) alo (l14)
    (i1 i3 i5 i7) alo (l15)
    (i1 i3 i6 i7) alo (l16)
    (i1 i4 i5 i6) alo (l17)
    (i1 i4 i5 i7) alo (l18)
    (i1 i4 i6 i7) alo (l19)
    (i2 i3 i4 i5) alo (l20)
    (i2 i3 i4 i6) alo (l21)
    (i2 i3 i4 i7) alo (l22)
    (i2 i3 i5 i6) alo (l23)
    (i2 i3 i5 i7) alo (l24)
    (i2 i3 i6 i7) alo (l25)
    (i2 i4 i5 i6) alo (l26)
    (i2 i4 i5 i7) alo (l27)
    (i2 i4 i6 i7) alo (l28)
    (i2 i5 i6 i7) alo (l29)
    (i3 i4 i5 i6) alo (l30)
    (i3 i4 i5 i7) alo (l31)
    (i3 i4 i6 i7) alo (l32)
    (i3 i5 i6 i7) alo (l33)
    (i4 i5 i6 i7) alo (l34)
    (l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11 l12 l13 l14 l15 l16 l17 l18 l19 l20 l21 l22 l23 l24 l25 l26 l27 l28 l29 l30 l31 l32 l33 l34) and34 (out)
    end
    
    scheme (i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34) and34 (out):
    local l1 l2 l3 l4 l5 l6 l7 l8 l9 l10 l11 l12 l13 l14 l15 l16 l17 l18 l19 l20 l21 l22 l23 l24 l25 l26 l27 l28 l29 l30 l31 l32 l33
    (i1 i2) and (l1)
    (l1 i3) and (l2)
    (l2 i4) and (l3)
    (l3 i5) and (l4)
    (l4 i6) and (l5)
    (l5 i7) and (l6)
    (l6 i8) and (l7)
    (l7 i9) and (l8)
    (l8 i10) and (l9)
    (l9 i11) and (l10)
    (l10 i12) and (l11)
    (l11 i12) and (l12)
    (l12 i13) and (l13)
    (l13 i14) and (l14)
    (l14 i15) and (l15)
    (l15 i16) and (l16)
    (l16 i17) and (l17)
    (l17 i18) and (l18)
    (l18 i19) and (l19)
    (l19 i20) and (l20)
    (l20 i21) and (l21)
    (l21 i22) and (l22)
    (l22 i23) and (l23)
    (l23 i24) and (l24)
    (l24 i25) and (l25)
    (l25 i26) and (l26)
    (l26 i27) and (l27)
    (l27 i28) and (l28)
    (l28 i29) and (l29)
    (l29 i30) and (l30)
    (l30 i31) and (l31)
    (l31 i32) and (l32)
    (l32 i33) and (l33)
    (l33 i34) and (out)
    end
    
    scheme (i1 i2 i3 i4) alo (out):
    local l1 l2 l3
    (i1 i2) or (l1)
    (l1 i3) or (l2)
    (l2 i3) or (l3)
    (l3 i4) or (out)
    end

    Восьмибитное "большинство"? НУ ЭТО ЖЕ ОЧЕВИДНО КОКОКОКО

    lolwwut, 17 Февраля 2012

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

    +112

    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
    public enum DataBits {
    	FIVE(SerialPort.DATABITS_5),
    	SIX(SerialPort.DATABITS_6),
    	SEVEN(SerialPort.DATABITS_7),
    	EIGHT(SerialPort.DATABITS_8);
    	
    	private final int value;
    	
    	private DataBits(final int value) {
    		this.value = value;
    	}
    	
    	public int getValue() {
    		return value;
    	}
    	
    	@Override
    	public String toString() {
    		return Integer.toString(value);
    	}
    }

    Завернули энум старого образца в нормальный.

    someone, 17 Февраля 2012

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