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

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    tabs.add({title:'Items',foo:'items'});
            <c:if test="${(!empty foo&& fn:length(foo.emails)>0) || !empty foo.processed || foo.attentionNeeded || !fooView || (!empty foo && fn:length(foo.emails)>0)}">
            tabs.add({title:'Emails',contentEl:'emails'});
            </c:if>
            <c:if test="${(!empty foo&& fn:length(foo.licenseItems)>0) || !empty foo.processed}">
            tabs.add({title:'Licenses',contentEl:'licenses'});
            </c:if>

    foo -- что бы не палить контору.
    но идея генерации джаваскрита посредством шаблонизации JSP/JSTL -- это пять

    Анонимус, 04 Февраля 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    std::list< Candidate* >::iterator it = order_by_priority.begin();
    	while(  ( speed < (*it)->minspeed ) || ( speed > (*it)->maxspeed ) ){
    		++it;
    		if( it == order_by_priority.end() )
    			break;
    	}
    	if( it == order_by_priority.end() )
    		return NULL;
    	return *it;

    Про for забыли, по 2 раза проверяем...

    panter_dsd, 04 Февраля 2011

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static T FirstOrDefault<T>(IEnumerable<T> it)
    {
       foreach (T v in it)
         return v;
       return default(T);
    }

    Самодельный FirstOrDefault.

    Боюсь даже представить, как у автора будет выглядеть Single

    bober_maniac, 31 Января 2011

    Комментарии (3)
  5. ActionScript / Говнокод #5463

    −102

    1. 1
    2. 2
    3. 3
    4. 4
    if( !mainLoop() == true )
    {
        return null;
    }

    Красота, нашлось в проекте от прежних разработчиков

    Werdn, 31 Января 2011

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function __destruct() {
    		parent::__destruct();
    		if(!self::$_c--) {
    			session_write_close();
    		}
    	}

    прямичком из IDE

    Lure Of Chaos, 30 Января 2011

    Комментарии (3)
  7. VisualBasic / Говнокод #5434

    −81

    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
    Try
                RichTextBox1.Text = int.OpenURL(adress & TextBox1.Text & units)
                tmpStr = RichTextBox1.Text.Split(">")
    
                Header = tmpStr(4).Split("<")
    
                lblHeader.Text = Header(0)
                CityName = Trim(Mid$(Header(0), 17, Len(Header(0)) - 16))
    
                outCName = CityName
    
                Codemass = tmpStr(43).Split(Chr(34))
    
                CodeNum = CInt(Codemass(3))
    
    
                tMass = tmpStr(43).Split(Chr(34))
                WCmass = tmpStr(17).Split(Chr(34))
                ATmass = tmpStr(18).Split(Chr(34))
    
                outWindC = "W: " & WCmass(3) & "o," & WCmass(5) & unSpd
                'outWCode = WCondition(CodeNum)
    
    
                outWState = tMass(1) & ","
                outTemp = tMass(5)
                outTemp = outTemp & Mid(units, 4, 1)
    
                outDate = tMass(7)
                outHum = ATmass(1) & "%, " & ATmass(5) & unPre
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

    Мой старый парсер XML-погоды с Yahoo. System.Xml? Нет, не слышал.

    RaZeR, 28 Января 2011

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

    +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
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    function func()
    {
    	$func = array(
    		"*4164-4622-1270" => "Core::Exchange->dest1",
    		"*8273-7121-7643" => "Core::Exchange->dest2",
    		"*8710-4879-0216" => "Core::Exchange->dest3",
    		"*5566-0506-6230" => "Core::Exchange->dest4",
    		"*0635-1830-1345" => "Core::Exchange->dest5",
                           .....
    	);
    	return $func;
    }
    	
    function eF($id) 
    {
    	if ($id == 1) return "*4164-4622-1270";
    	if ($id == 2) return "*8273-7121-7643";
    	if ($id == 3) return "*8710-4879-0216";
    	if ($id == 4) return "*5566-0506-6230";
               if ($id == 5) return "*0635-1830-1345";
    	if ($id == 6) return "*3265-0565-4871";
                .....
    }

    Диспетчер функций с встроенной защитой от кулхацкеров. (dest1...dest5 - сохранены оригинальные имена)

    tyler, 28 Января 2011

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

    −143

    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
    if exists(
      select 1
      from PList
      where userId = @userId
      and opCode = 'SSDD' 
    ) 
    begin
       select @SSDD = ssValue
       from  PList 
              where userId = @userId
                and opCode = 'SSDD' 
       .................
    	<some code>
       .................
    end

    оптимальненько

    3.14159265, 25 Января 2011

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

    +160

    1. 1
    if ( $('.menu_center > ul > li:eq(6)').attr('id') != 'current' )

    Jquery в джумле:)

    moonie, 25 Января 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    .onePixBorder{
    zoom:1; 
    behavior:expression(!this.isInserted==true ? this.isInserted=(this.innerHTML = '<span style="background: url(/common/img/opb-tr.png) no-repeat 100% 0;height: 9px;display: block;margin: -11px -11px 2px -11px;"><img src="/common/img/opb-tl.png" alt="" /></span>' + this.innerHTML + '<span style="background: url(/common/img/opb-br.png) no-repeat 100% 0;height: 9px;display: block;margin:4px -11px -11px -11px;"><img src="/common/img/opb-bl.png" alt="" /></span>') : '');
    }

    в css файле, специально подкючаемый для ie6

    ilyamx, 25 Января 2011

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