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

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(count($colors)>1){
        if($i==2){
            $col = $colors[1];
        }else{
            $col = $colors[0];
        }
    }else{
        $col=$colors[0];
    }

    Вот где не надо - тьма тернарных операторов, а где их логичнее всего ожидать - вот такой огород из IF/ELSE

    Khvorostin, 13 Октября 2014

    Комментарии (17)
  3. JavaScript / Говнокод #16682

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $(document).ready(function() {
            var links = $("a[href*='shop.mts.ru']");
            $.each(links, function(i, val) {
                $(val).attr('onclick', "_gaq.push(['_link', '" + $(val).attr('href') + "']); return false;");
            });
            //for ThreeSmallBanners adfox:
            $('a.offer_button').removeAttr('onclick');
        });

    mts.ru

    gost, 11 Сентября 2014

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

    −165

    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
    Функция ПолучитьЧистыйКод(Код) Экспорт
            //ЧистыйКод = "0";
    	ЧистыйКод = "";
    	Инд = 1;
    	Пока Инд < 18 Цикл
    		Символ = Сред(Код, Инд, 1);
    		Если Символ = " " ИЛИ Символ = "" ИЛИ Символ = " " Тогда   // А вот это - самая фееричная строка 
    			Инд = Инд + 1;
    			Продолжить;
    		Иначе 
    			ЧистыйКод = ЧистыйКод + Символ;
    		КонецЕсли;
    		Инд = Инд + 1;
    	КонецЦикла;
    	Возврат ЧистыйКод;
    КонецФункции

    Чел видимо только что с ассемблера соскочил.

    Jeyrico, 26 Августа 2014

    Комментарии (17)
  5. JavaScript / Говнокод #16433

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var id = $('#block1').attr('id');
    if( id == 'block1') {
        $('.right').hide();
    }else{
        $('.right').show();
    };

    Шедевр.

    HeyMeXa, 28 Июля 2014

    Комментарии (17)
  6. Haskell / Говнокод #16405

    −79

    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
    map_of_enemy :: [[Int]] -> [[Int]]
    map_of_enemy [] = []
    map_of_enemy list = (iniciar (0) (0) (list))
    
    iniciar :: Int -> Int -> [[Int]] -> [[Int]]
    iniciar a b list = if(a == (length list)-1) then [rango a 0 list]
                   else [rango a 0 list]++[(iniciar (a+1) 0 list)]
    
    rango :: Int -> Int -> [[Int]] -> [Int]
    rango a b list = if (b==(length list)-1 && (((list!!a!!0)==(list!!b!!0)) &&     ((list!!a!!1)==(list!!b!!1)) && ((list!!a!!2)==(list!!b!!2))))
                 then [0]
                 else if (b==(length list)-1 && (((list!!a!!0)/=(list!!b!!0)) || ((list!!a!!1)/=(list!!b!!1)) || ((list!!a!!2)/=(list!!b!!2))))
                 then (rango2 a (list!!b) list)
                 else if (((list!!a!!0)==(list!!b!!0)) && ((list!!a!!1)==(list!!b!!1)) && ((list!!a!!2)==(list!!b!!2)))
                 then [0]++(rango a (b+1) list)
                 else (rango2 a (list!!b) list)++(rango a (b+1) list)
    
    rango2 :: Int -> [Int] -> [[Int]] -> [Int]
    rango2 a b list = if ((verif [(list!!a!!0)+(list!!a!!2),(list!!a!!1)+(list!!a!!2)] [(list!!a!!0)-(list!!a!!2),(list!!a!!1)-(list!!a!!2)] (b))) then [1]
                  else [0]
    
    verif a b c = if (((c!!0) < (a!!0)) && ((c!!0) > (b!!0)) && ((c!!1) < (a!!1)) && ((c!!1) > (b!!1))) then True
              else if (((c!!0) < (a!!0)) && ((c!!0) == (b!!0)) && ((c!!1) < (a!!1)) && ((c!!1) == (b!!1))) then True
              else if (((c!!0) == (a!!0)) && ((c!!0) > (b!!0)) && ((c!!1) == (a!!1)) && ((c!!1) > (b!!1))) then True
              else False

    Haskell
    OMG mode on

    kegdan, 22 Июля 2014

    Комментарии (17)
  7. Java / Говнокод #16312

    +74

    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
    public final class TimeBasedRollingPolicy extends RollingPolicyBase 
    ...
    private int suffixLength = 0;
    ...
    
    public void  activateOptions() {
    ....
        if (lastFileName.endsWith(".gz")) {
          suffixLength = 3;
        } else if (lastFileName.endsWith(".zip")) {
          suffixLength = 4;
        }
    }
    
    public RolloverDescription  rollover(final String currentActiveFile) {
    ...
        if (suffixLength == 3) {
          compressAction =
            new GZCompressAction(
              new File(lastBaseName), new File(lastFileName), true);
        }
    
        if (suffixLength == 4) {
          compressAction =
            new ZipCompressAction(
              new File(lastBaseName), new File(lastFileName), true);
        }
    
    ...
    }
    
    }

    Log4j

    Alex512, 11 Июля 2014

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

    +166

    1. 1
    2. 2
    3. 3
    function array_min_recursive($arr, &$peaks = array(), $current_key = '') {
      return array_max_recursive($arr, $peaks, $current_key, true); // Неожиданно, правда?
    }

    DIX315, 05 Июля 2014

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

    +127

    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
    boolean loadPPOGroupCompleted(string customerRef, string competence, string marketArea) {
        int i = 0;
        table sceData = getPPOPODGroupSCEs(customerRef, competence, marketArea);
        table dceData = getPPOPODGroupDCEs(customerRef, competence, marketArea);
        table sbilData = getPPOPODGroupSbil(customerRef, competence, marketArea);
        while (i < tableRowCount(sceData)) {
            EventRec sce = convertStoredSCRtoEventRec(false, sceData, i, "", competence);
            if ((string)tableGet(sceData, i, "ACTION_TYPE") == ACTION_REP) {
                udrRoute(sce, "toSE_Agg_rer");
                isReplaceAction = true;
            } else {
                udrRoute(sce, "toSE_Agg_evt");
            }
            i = i+ 1;
        }
        i = 0;
        while (i < tableRowCount(dceData)) {
            EventRec dce = convertStoredDCRtoEventRec(false, dceData, i, "", competence);
            if ((string)tableGet(dceData, i, "ACTION_TYPE") == ACTION_REP) {
                udrRoute(dce, "toSE_Agg_rer");
                isReplaceAction = true;
            } else {
                udrRoute(dce, "toSE_Agg_evt");
            }
            i = i+ 1;
        }
        i = 0;
        while (i < tableRowCount(sbilData)) {
            EventRec sbilEvent = convertStoredSbiltoEventRec(sbilData, i, PPO_ZONALE, competence);
            if ((string)tableGet(sbilData, i, "ACTION_TYPE") == ACTION_REP) {
                udrRoute(sbilEvent, "toSE_Agg_rer");
                isReplaceAction = true;
            } else {
                udrRoute(sbilEvent, "toSE_Agg_evt");
            }
            i = i + 1;
        }
        return true;
    }
    
    boolean loadGroupCompleted(string customerRef, string competence, date minStartDate) {
        table sceData = getGroupSCEs(customerRef, competence);
        table dceData = getGroupDCEs(customerRef, competence);
        int i = 0;
        string extPODCode, hour_date, hour_value, eventDTM, hourlyConsumption, totalF0GroupConsumption, treatmentType, consumptionType, actionType, edmID;       
        while (i < tableRowCount(sceData)) {
            EventRec sce = convertStoredSCRtoEventRec(true, sceData, i, "", competence);
            if ((string)tableGet(sceData, i, "ACTION_TYPE") == ACTION_REP) {
                udrRoute(sce, "toSE_Agg_rer");
                isReplaceAction = true;
            } else {
                udrRoute(sce, "toSE_Agg_evt");
            }
            i = i + 1;
        }
        i = 0;
        while (i < tableRowCount(dceData)) {
            EventRec dce = convertStoredDCRtoEventRec(true, dceData, i, "", competence);
            if ((string)tableGet(dceData, i, "ACTION_TYPE") == ACTION_REP) {
                udrRoute(dce, "toSE_Agg_rer");
                isReplaceAction = true;
            } else {
                udrRoute(dce, "toSE_Agg_evt");
            }
            i = i + 1;
        }
        if (isGroupHasPPO(customerRef, minStartDate)) {
            table sbilData = getPPOGroupSbil(customerRef, competence);   
            i = 0;
            while (i < tableRowCount(sbilData)) {
                EventRec sbilEvent = convertStoredSbiltoEventRec(sbilData, i, PPO_ZONALE, competence);
                if ((string)tableGet(sbilData, i, "ACTION_TYPE") == ACTION_REP) {
                    udrRoute(sbilEvent, "toSE_Agg_rer");
                    isReplaceAction = true;
                } else {
                    udrRoute(sbilEvent, "toSE_Agg_evt");
                }
                i = i + 1;
            }   
        }
        return true;
    }

    ctrl+c, ctrl+v

    n924, 04 Июля 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    $exp_date=$item['expiration_date'];
    list($date,$time)=explode(' ',$exp_date);
    list($day,$month,$year)=explode('/',$date);
    echo $day.'.'.$month.'.'.$year.' '.$time;

    работа с датой
    преобразования из
    05/12/2013 11:12:00
    в
    05.12.2013 11:12:00

    icevic1, 30 Июня 2014

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

    −164

    1. 1
    2. 2
    3. 3
    Процедура глЗагрузитьЗаказы() Экспорт
    	ОткрытьФорму("Отчет",,"\\SQLDSTR\1C\ExtERT\InvoiceLoader.ert");
    КонецПроцедуры

    Встретил в самописке в клюшках. Если поменяется имя сервера или каталога - всё рухнет).

    zinkovskiy, 16 Июня 2014

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