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

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

    +135

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public int getFileRowsCount(string pathToFile)
    {
           System.IO.TextReader streamReader = new System.IO.StreamReader(pathToFile);
           int rowsCounter = 0;
           while ((streamReader.ReadLine()) != null)
           {
               rowsCounter++;
           }
           streamReader.Close();
           return rowsCounter;
    }

    Из http://habrahabr.ru/post/149877/
    И коммент афтора - "Здесь всё просто: пока не дойдём до пустой строки, прибавляем к счётчику строк единичку. Функция возвращает количество строк."

    phoenixx, 20 Августа 2012

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

    +122

    1. 1
    Console.WriteLine(Math.Sin(long.MaxValue));

    Выведет 9,22337203685478E+18

    koodeer, 26 Апреля 2012

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    THTTPServer::TDynamicResponse::~TDynamicResponse( void )
    {
    	if(typeid(*this)==typeid(TDynamicResponse))//Борьба с pure virtual function call.
    		this->flush();
    };

    Проект поменьше.

    Говногость, 28 Марта 2012

    Комментарии (62)
  5. Pascal / Говнокод #7225

    +126

    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
    uses
    crt;
    var
      chasov,
     minutov,
    sekundov :byte;
    tekushchiy_sekund:word;
    begin
    clrscr;
    write('   chasov ');
    read(     chasov);
    if chasov=9
               then
                   begin
                        clrscr;
                        halt;
                   end;
    write('  minutov ');
    read(    minutov);
    write(' sekundov ');
    read(   sekundov);
    clrscr;
    for tekushchiy_sekund:=1
    to sekundov+60*minutov+3600*chasov do
      begin
           if keypressed then
                             if readkey=#27
                                           then halt;
           delay(50000);
      end;
    sound(300);
    readkey;
    nosound;
    end.

    УГАДАЙТЕ

    dos, 11 Июля 2011

    Комментарии (62)
  6. JavaScript / Говнокод #6514

    +158

    1. 1
    if(typeof n!="number"&&(k==Number||!(n instanceof Number))||p.round(n)!=n||n==NaN||n==Infinity)return!1;

    http://www.google-analytics.com/ga.js
    Инженеры в Гугле знают толк в JavaScript'e.

    wvxvw, 29 Апреля 2011

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

    +167

    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
    String ExelCol(int col)
    {
      static const char c[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
      String str;
      if( !col ) return str;
      while( true )
      {
        str.Insert( c[(col-1) % sizeof(c)], 1 );
        if( ! ((col-1) / sizeof(c)) ) break;
        col /= sizeof(c);
      }
      return str;
    }

    ni3_inv, 26 Апреля 2011

    Комментарии (62)
  8. JavaScript / Говнокод #6397

    +151

    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
    $(".selection a").click(function(event){
    if(this==event.target) {
    $(this).toggleClass("m1active")
    
    sel1="0"; sel2="0"; sel3="0"; sel4="0"; sel5="0"; onb="0"; sel6="0"; sel7="0"; sel8="0"; sel9="0"; sel10="0"; sel11="0"; sel12="0"; 
    
    
    if($("#sel1").hasClass("m1active")) { sel1="1"; }
    if($("#sel2").hasClass("m1active")) { sel2="1"; }
    if($("#sel3").hasClass("m1active")) { sel3="1"; }
    if($("#sel4").hasClass("m1active")) { sel4="1"; }
    if($("#sel5").hasClass("m1active")) { sel5="1"; }
    if($("#sel6").hasClass("m1active")) { sel6="1"; }
    if($("#sel7").hasClass("m1active")) { sel7="1"; }
    if($("#sel8").hasClass("m1active")) { sel8="1"; }
    if($("#sel9").hasClass("m1active")) { sel9="1"; }
    if($("#sel10").hasClass("m1active")) { sel10="1"; }
    if($("#sel11").hasClass("m1active")) { sel11="1"; }
    if($("#sel12").hasClass("m1active")) { sel12="1"; }
    if($("#onb").hasClass("m1active")) { onb="1"; }
    
    
    
    // var txff="eddm.php?sel1=".sel1;
    $("#content-ajax").load("eddm.php",{ sel1: sel1, sel2: sel2, sel3: sel3, sel4: sel4, sel5: sel5, sel6: sel6, sel7: sel7, sel8: sel8, sel9: sel9, sel10: sel10, sel11: sel11, sel12: sel12, onb: onb }, function() { 
    $(".editus tr:nth-child(even)").css('background-color','#ffeedd');
    
    
     });

    Ребята, прошу покритиковать сайт web-school.su и предложить правильные решения

    Webschool, 19 Апреля 2011

    Комментарии (62)
  9. PHP / Говнокод #4909

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $cif = range(0, 9);
    $mal = range('a', 'z');
    $bol = range('A', 'Z');
    $ob = array_merge($cif, $mal, $bol);
    shuffle($ob);
    $ar = array_slice($ob,0, 5);
    $vivod = implode("", $ar);

    Очередной генератор капчи/пароля.
    Вдруг кому пригодится ;)

    Uchkuma, 12 Декабря 2010

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    char *ptr1;
    char *ptr2;
    //...
    try {
        throw ptr2 - ptr1;
      }
      catch (int e) {
        std::cout << "exception addr dif" << e << std::endl;
      }

    Говногость, 13 Июня 2010

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // Since styled-components allows you to use arbitrary input as interpolations, you must be careful to sanitize that input.
    // Using user input as styles can lead to any CSS being evaluated in the user's browser that an attacker can place in your application.
    
    // This example shows how bad user input can even lead to API endpoints being called on a user's behalf.
    
    // Oh no! The user has given us a bad URL!
    const userInput = '/api/withdraw-funds'
    
    const ArbitraryComponent = styled.div`
      background: url(${userInput});
      /* More styles here... */
    `

    в процессе многолетнего пересоздания ruby on rails с нуля фронтендеры умудрились accidentally a bottle of injections

    https://styled-components.com/docs/advanced#security

    Fike, 16 Марта 2021

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