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

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

    +159

    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
    function line( x0, y0, x, y, elmId ) {
    
    	var sx = x-x0, sy = y-y0, dir = (sx>sy), adir = (Math.abs(sx)>Math.abs(sy));
    
    	if ( (x0>x&&y0<=y&&adir)||(x0<=x&&y0>y&&!adir)||(x0>x&&y0>y) ) return line(x, y, x0, y0, elmId); // black magic!
    
    	var d1 = dir? x0:y0, d2 = dir? y0:x0, b1 = dir? sx:sy, b2 = dir? sy:sx, k = b2/b1;
    
    		for( var i=0; i<=b1;i++ ){
    
    			if ( dir ) plot( d1, Math.floor(d2), elmId );
    			else plot( Math.floor(d2), d1, elmId );
    
    			d1++;d2+=k;
    		}
    	return true;
    }
    /* ... */
    function plot(x, y, elmId) {
    
    	var div = document.createElement('div');
    	div.className = 'dot' + (!!elmId? ' dot-'+elmId:'' ) ;
    	div.style.left = x + 'px';
    	div.style.top = y + 'px';
    
    	document.getElementsByTagName('BODY')[0].appendChild(div);
    }

    Опачки...

    istem, 20 Апреля 2012

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

    +947

    1. 1
    2. 2
    3. 3
    xg = (int)Math.Round(40 + ye[0] * 360 / 12);
                    yg = (int)Math.Round(340 - ye[1] * (decimal)2.5);
                    cur = new PointF((float)xg, (float)yg);

    Отрисовка графика.

    cgbs, 20 Апреля 2012

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

    +1004

    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
    long base64::rlong (char * source)
    {
        long res = 0;
        for (int i = 0; i < 4; i++) ((char *) &res)[3 - i] = source[i];
        return res;
    }
    
    void base64::encode (char * source, char * dest)
    {
        char base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        int n = 0;
        for (int nd = 0; nd < ceil(4*((double)strlen(source))/3); nd++)
            dest[n++] = base[rlong(&source[((nd >> 2) << 2)*3 >> 2]) >> (26 - 6*(nd - ((nd >> 2) << 2))) & 0x3F]; 
        for (int i = 0; i < ((int) ceil(((double)n)/4) << 2) - n; i++) dest[n++] = '=';
        dest[n] = 0;
    }

    Ответ преподу по c++. Переводстроки в base64.

    antonymus, 14 Апреля 2012

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private static string GetShortDisciplineName(string longDsciplineName){
                string[] words = longDsciplineName.Split(' ');
                switch (words.Count()){
                    case 1:{
                        return longDsciplineName;
                        break;
                        }

    pm2t29jf47, 13 Апреля 2012

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    php_value register_globals 1
    php_flag register_globals on
    php_value magic_quotes 1
    php_flag magic_quotes on
    php_value magic_quotes_gpc 1
    php_flag magic_quotes_gpc on

    n/c

    miraage, 13 Апреля 2012

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

    +68

    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
    if (seriesOrder == SeriesRenderingOrder.REVERSE) {
                    //render series in reverse order
                    for (int pass = 0; pass < passCount; pass++) {
                        int seriesCount = dataset.getSeriesCount();
                        for (int series = seriesCount - 1; series >= 0; series--) {
                            int firstItem = 0;
                            int lastItem = dataset.getItemCount(series) - 1;
                            if (lastItem == -1) {
                                continue;
                            }
                            if (state.getProcessVisibleItemsOnly()) {
                                int[] itemBounds = RendererUtilities.findLiveItems(
                                        dataset, series, xAxis.getLowerBound(),
                                        xAxis.getUpperBound());
                                firstItem = Math.max(itemBounds[0] - 1, 0);
                                lastItem = Math.min(itemBounds[1] + 1, lastItem);
                            }
                            state.startSeriesPass(dataset, series, firstItem,
                                    lastItem, pass, passCount);
                            for (int item = firstItem; item <= lastItem; item++) {
                                renderer.drawItem(g2, state, dataArea, info,
                                        this, xAxis, yAxis, dataset, series, item,
                                        crosshairState, pass);
                            }
                            state.endSeriesPass(dataset, series, firstItem,
                                    lastItem, pass, passCount);
                        }
                    }
                }
                else {
                    //render series in forward order
                    for (int pass = 0; pass < passCount; pass++) {
                        int seriesCount = dataset.getSeriesCount();
                        for (int series = 0; series < seriesCount; series++) {
                            int firstItem = 0;
                            int lastItem = dataset.getItemCount(series) - 1;
                            if (state.getProcessVisibleItemsOnly()) {
                                int[] itemBounds = RendererUtilities.findLiveItems(
                                        dataset, series, xAxis.getLowerBound(),
                                        xAxis.getUpperBound());
                                firstItem = Math.max(itemBounds[0] - 1, 0);
                                lastItem = Math.min(itemBounds[1] + 1, lastItem);
                            }
                            state.startSeriesPass(dataset, series, firstItem,
                                    lastItem, pass, passCount);
                            for (int item = firstItem; item <= lastItem; item++) {
                                renderer.drawItem(g2, state, dataArea, info,
                                        this, xAxis, yAxis, dataset, series, item,
                                        crosshairState, pass);
                            }
                            state.endSeriesPass(dataset, series, firstItem,
                                    lastItem, pass, passCount);
                        }
                    }
                }

    нашел в jfreechart
    Обе ветки if-else идентичны, только в одной цикл идет от нуля, в другой в обратную сторону.
    Говнокод или нет?

    krige, 12 Апреля 2012

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public void saveDomain(DomainMetadata domainMetadata){
            domainStore.save(domainMetadata);
        }
    
    оттуда же
    
    public void saveMail(Mail mail){
            mailCollection.save(mail);
        }

    exciter, 11 Апреля 2012

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

    −116

    1. 1
    var rowIndex:Boolean = Number(isNaN(parseInt(nextCharacter)));

    Проверка строки на наличие чисел.
    Пикантность ситуации еще придает что parseInt ('буква') всегда равно нулю.

    kyzi007, 06 Апреля 2012

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

    +156

    1. 1
    2. 2
    bool addSomeValue;
    int percentage = 100 + addSomeValue ? 10 : 0;

    infog, 06 Апреля 2012

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

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (params[0].toLowerCase().equals("1"))
    {
    	TeleportService.teleportTo(admin, WorldMapType.POETA.getId(), 806, 1242, 119, 0);
    	PacketSendUtility.sendMessage(admin, "Teleported to Poeta.");
    }
    else if (params[0].toLowerCase().equals("2"))
    {
    	TeleportService.teleportTo(admin, 320070000, getInstanceId(320070000, admin), 246, 246, 125, 0);
    	PacketSendUtility.sendMessage(admin, "Teleported to 15-25 PvP arena.");
    }
    else
    PacketSendUtility.sendMessage(admin, "PvP zone not found");

    zomg, 02 Апреля 2012

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