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

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

    +141

    1. 1
    //А почему PHP кода на этом сайте больше всего?

    dreesto, 01 Февраля 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    jQuery('.favoriteStar'+json.id).each(function(){
        var src = jQuery(this).attr('src');
        if (json.status != 1) {
            src = src.replace('ico_heart.png','ico_heart_grey.png');
        } else {
            src = src.replace('ico_heart_grey.png','ico_heart.png');
        }
        jQuery(this).attr('src',src);
    });

    Установка элемента как favorite

    khaletskiy, 30 Января 2012

    Комментарии (4)
  4. JavaScript / Говнокод #9242

    +156

    1. 1
    2. 2
    3. 3
    a=5; l=0;
    .....
    l= (l>a) ? 0 : l++;

    Писал вчера свою задумку и были там вот эти строки... Я долго не мог вкурить, почему же у меня l все время рвано 0 ...)

    engine-r, 28 Января 2012

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

    +117

    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
    [TestInitialize]
            public void Init()
            {
                relashions = new List<PersonRelationship>();
                relashions.Add( new PersonRelationship()
                {
                    PersonId = 1,
                    RalationshipPersonId = 2,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
    
                relashions.Add(new PersonRelationship()
                {
                    PersonId = 1,
                    RalationshipPersonId = 2,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
                
                relashions.Add(new PersonRelationship()
                {
                    PersonId = 2,
                    RalationshipPersonId = 1,
                    RelationshipTypeId = (int)DAL.Dictionaries.RelationshipType.Friend
                });
            }
    
    [TestMethod()]
            public void GetMyFriends_Get_Success()
            {
                long personId = 1;
    
                var relationService = new Mock<IRelationService>();
                relationService.Setup(c => c.GetMyFriends(personId)).Returns
                    (
                        from rl in relashions.Where(r => r.PersonId == personId && r.RelationshipTypeId == (int)DAL.Dictionaries.RelationshipType.Friend)
                        select new PersonShortDescriptionViewModel()
                        {
                            FirstName = personId.ToString(),
                            LastName = personId.ToString(),
                        }
                     );
    
                var friends = relationService.Object.GetMyFriends(personId);
                Assert.IsNotNull(friends);
            }

    Найден правильный метод написания тестов!

    Hych, 24 Января 2012

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

    −107

    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
    GraphicsWindow.Width = 640
    GraphicsWindow.Height = 480
    
    GraphicsWindow.PenColor = "Yellow" 
    For i = 0 To 250
      GraphicsWindow.DrawLine(0 + i, 480 - i, 640 - i, 480 - i )
    EndFor
    
    GraphicsWindow.PenColor = "Orange"
    For i = 0 To 250 Step 10
      GraphicsWindow.DrawLine(0 + i, 480 - i, 640 - i, 480 - i)
    EndFor
    
    GraphicsWindow.BrushColor = "SteelBlue"
    GraphicsWindow.FillRectangle (0,0, 640 , 230)
    GraphicsWindow.BrushColor = "lightGreen"
    GraphicsWindow.FillTriangle(0, 480, 0, 230, 250, 230)
    GraphicsWindow.FillTriangle(640, 480, 640, 230, 390, 230)
    
    GraphicsWindow.BrushColor = "Orange"
    GraphicsWindow.FillEllipse (10, 30, 50, 50)  
    
    GraphicsWindow.PenColor = "Yellow"
    Turtle.Show()
    y = 0
    For i = 0 To 360 Step 30
    Turtle.X =35
    Turtle.Y = 55
    Turtle.Angle = i
    Turtle.PenUp()
    Turtle.Move(25)
    Turtle.PenDown()
    If y = 1 Then
      Turtle.Move(10)
      y = 0
    else  
      Turtle.Move(20)
      y = 1
    endif
    endfor

    KotoFey1ch, 23 Января 2012

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($element_id===false)
            {
            	//этот  код не должен работать
                $sql = 'SELECT `countmessage` FROM `mes_topic` WHERE `id`='.(int)$board_id;
            }else{
                ....
            }

    А зачем его писать?!

    admincheg, 23 Января 2012

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

    +154

    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
    public function invokeMethod($method, $params = array()) {
                    switch (count($params)) {
                            case 0:
                                    return $this->{$method}();
                            case 1:
                                    return $this->{$method}($params[0]);
                            case 2:
                                    return $this->{$method}($params[0], $params[1]);
                            case 3:
                                    return $this->{$method}($params[0], $params[1], $params[2]);
                            case 4:
                                    return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
                            case 5:
                                    return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
                            default:
                                    return call_user_func_array(array(&$this, $method), $params);
                    }
            }

    Из сорцов Lithium

    asfalanaft, 23 Января 2012

    Комментарии (4)
  9. Java / Говнокод #9187

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static List<Character> englishAlphabet;
    
        public static final Integer ENGLISH_ALPHABET_LENGTH = 26;
    
        static {
            englishAlphabet = new ArrayList<Character>();
            englishAlphabet.add('#');
            for (int i = 0; i < ENGLISH_ALPHABET_LENGTH; i++) {
                englishAlphabet.add((char) ('A' + i));
            }
        }

    Товарищ уже уволился :)

    jekyll, 20 Января 2012

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

    +111

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while (true)
                    {
                        if (sec > 10)
                        {
                            sec = 0;
                            // Вызор функции
                        }
                        else
                            sec++;
    
                        Thread.Sleep(1000);
                    }

    Боевой код, который допиливаю(

    yorikim, 20 Января 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    if (!isset($pmas_table[0][3])) $pmas_table[0][3]='';
    if (!isset($pmas_table[0][5])) $pmas_table[0][5]='';
    if (!isset($pmas_table[0][6])) $pmas_table[0][6]='';
    if (!isset($pmas_table[0][7])) $pmas_table[0][7]='';

    UserSide v2.48 again. Так как там каждая строчка имеет право быть на этом сайте, выкладываю The best of the best =)

    Neka, 18 Января 2012

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