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

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

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if (false == very_long_function(arg1, arg2, ...)) 
    {
        if (false == very_long_other_function(even_more_args) 
        {
            do_something();
        }
        else 
        {   
            do_something_else();
        }
    }

    И вот такими многоэтажками забит весь проект.

    codemonkey, 26 Апреля 2015

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

    +142

    1. 1
    return st1.empty() || st2.empty() ? st1.empty() && st2.empty() ? 0 : st1.empty() ? st2.gcd() : st1.gcd() : qwer::gcd(st1.gcd(), st2.gcd());

    Когда увлёкся условными конструкциями...

    AndreyZ, 18 Апреля 2015

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

    +138

    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
    if(argc > 6){
    	for(arg = argv[6]; strlen((char *)arg) >= 17 &&
    					isdigit(arg[0]) &&
    					isdigit(arg[1]) &&
    					isdigit(arg[3]) &&
    					isdigit(arg[4]) &&
    					isdigit(arg[6]) &&
    					isdigit(arg[7]) &&
    					isdigit(arg[9]) &&
    					isdigit(arg[10]) &&
    					isdigit(arg[12]) &&
    					isdigit(arg[13]) &&
    					isdigit(arg[15]) &&
    					isdigit(arg[16])
    					; arg+=18){
    
    		int t1, t2;
    		struct period *sp;
    
    		t1 = (arg[0] - '0') * 10 + (arg[1] - '0');
    		t1 = (t1 * 60) + (arg[3] - '0') * 10 + (arg[4] - '0');
    		t1 = (t1 * 60) + (arg[6] - '0') * 10 + (arg[7] - '0');
    		t2 = (arg[9] - '0') * 10 + (arg[10] - '0');
    		t2 = (t2 * 60) + (arg[12] - '0') * 10 + (arg[13] - '0');
    		t2 = (t2 * 60) + (arg[15] - '0') * 10 + (arg[16] - '0');
    		if(t2 < t1) break;
    		sp = myalloc(sizeof(struct period));
    		if(sp){
    			sp->fromtime = t1;
    			sp->totime = t2;
    			sp->next = acl->periods;
    			acl->periods = sp;
    		}
    		if(arg[17]!=',') break;
    	}
    }

    Получение временных диапазонов, из https://github.com/z3APA3A/3proxy/blob/devel/src/3proxy.c#L1470
    Основное говно в том, что нифига не проверяются входные данные т.е. секунд и минут может быть больше 59, а часов может быть больше 23. И проверку if(t2 < t1) лучше заменить на if(t2 <= t1)
    А еще там в том исходнике в качестве отступов используются и пробелы и табы. Вообще там очень много говнокода

    j123123, 12 Апреля 2015

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

    +160

    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
    class Claims
    {
        ...
        function ReadClaim(...)
        {
            ...
            
            if ($this) $this->claim = $claim;
            $instance = $this ? $this : Claims::getInstance($claim);
    
            ...
        }
        ...
    }

    3371, 03 Апреля 2015

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

    −403

    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
    if (indexPath.row == 0) {
            if (![centerViewController isKindOfClass:[T7DUserInfoViewController class]]) {
                T7DUserInfoViewController *userViewController = [[T7DUserInfoViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:userViewController animated:NO];
            }
        }
        if (indexPath.row == 1) {
            if (![centerViewController isKindOfClass:[T7DMapViewController class]]) {
                T7DMapViewController *mapViewController = [[T7DMapViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:mapViewController animated:NO];
            }
        }
        if (indexPath.row == 2) {
            if (![centerViewController isKindOfClass:[T7DOrderListViewController class]]) {
                T7DOrderListViewController *orderListViewController = [[T7DOrderListViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:orderListViewController animated:NO];
            }
        }
        if (indexPath.row == 3) {
            if (![centerViewController isKindOfClass:[T7DCurrentOrderViewController class]]) {
                T7DCurrentOrderViewController *orderViewController = [[T7DCurrentOrderViewController alloc] init];
                [orderViewController setOrderType:T7DOrderTypeCurrent];
                [orderViewController setOrder:[T7DOrder currentOrder]];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:orderViewController animated:NO];
            }
        }
        if (indexPath.row == 4) {
            if (![centerViewController isKindOfClass:[T7DMessagesViewController class]]) {
                T7DMessagesViewController *messagesViewConroller = [[T7DMessagesViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:messagesViewConroller animated:NO];
            }
        }
        if (indexPath.row == 5) {
            [self logout];
            return;
        }

    Мудаки.

    pr0gl, 31 Марта 2015

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

    +92

    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
    var
      HTML: TStringList;
      HTTP: THTTPSend;
    begin
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV4.exe'), SW_HIDE);
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV5.exe'), SW_HIDE);
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV6.exe'), SW_HIDE);
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV7.exe'), SW_HIDE);
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV8.exe'), SW_HIDE);
      WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV9.exe'), SW_HIDE);
      if FLogin.sEdit1.Text = '' then
        raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
      if FLogin.sEdit2.Text = '' then
        raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
      if FLogin.sEdit3.Text = '' then
        raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
      HTML := TStringList.Create;
      HTTP := THTTPSend.Create;
      HTTP.Protocol := '1.1';
      HTTP.Headers.Add('Accept: application/json, text/javascript, */*; q=0.0');
      HTTP.Headers.Add('X-Requested-With: XMLHttpRequest');
      HTTP.MimeType := 'application/x-www-form-urlencoded; charset=UTF-8';
      HTTP.UserAgent := 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)';
      if HTTP.HTTPMethod('Post', 'http://{тут_мог_быть_ваш_адресс}/testlicfile/Perm_License.txt') then
      begin
        HTML.LoadFromStream(HTTP.Document);
        if Pos((FLogin.sEdit1.Text + '_' + FLogin.sEdit2.text + '_' + FLogin.sEdit3.text + '_READY'), HTML.text) <> 0 then
        begin
          IniFile := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'ArcheAge.ini');
          IniFile.WriteString('LOGIN', 'SKYPE', FLogin.sEdit1.Text);
          IniFile.WriteString('LOGIN', 'HWID', FLogin.sEdit2.Text);
          IniFile.WriteString('LOGIN', 'KEYPS', FLogin.sEdit3.Text);
          IniFile.Free;
          Form2.Caption := 'Информация - [Лицензия: ' + FLogin.sEdit1.Text + ']';
          Form1.Show;
          FLogin.AlphaBlend := True;
          FLogin.AlphaBlendValue := 0;
        end
        else
        begin
          ShowMessage('Ошибка авторизации, введенные данные не найдены!');
        end;
        HTML.Free;
        HTTP.Free;
      end;
    end;

    Узрел тут такой шедевр на одном из форумов. Типа защита от взлома:)

    Cynicrus, 30 Марта 2015

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

    +161

    1. 1
    $reload_one_by_one = $folder = $datashow = $tagdelete = $ipdatauser = $design = $open_all = $catshow = $main = $daleeshow = $openshow = $number = $add = $size = $papki_numbers = $zagolovokin = $menu = $noli = $show_title = $random = $showlinks = $open_new_window = $shablon = $show_new_pages = $reload_link_show = $reload_link_time = $reload_link_on_start = $show_pages_from = $calendar_future = $calendar_years = $re_menu_type = $must_have_foto_adres = $papki_in_razdel_show = $papki_in_razdel_punkt = $papki_in_papki_show = $papki_in_papki_punkt = $papki_in_pages_show = $papki_in_pages_punkt = $type_menu_item = $razdel_menu_show = $tag_show = $sort_photo = $archive_type = $archive_sort = $another_css_link = $another_css_options = $another_css_font_1 = $another_css_font_2 = $another_css_color_1 = $another_css_color_2 = $another_css_noimages = $author_show = 0;

    Кажется найден «брат» говнокода http://govnokod.ru/17836

    volter9, 26 Марта 2015

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

    −82

    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
    Процедура ПередЗаписью(Отказ, РежимЗаписи, РежимПроведения)
    	
    	Если НЕ ВвестиСтроку(Комментарий, "Укажите комментарий к запрещению: ", 255) Тогда
    		ОбщегоНазначения.СообщитьОбОшибке("Не указан комментарий к запрещению!", Отказ, Заголовок);
    		Форма = ЭтотОбъект.ПолучитьФорму("ФормаДокумента");
    		Если Форма.Открыта() Тогда
    			Форма.Закрыть();	
    		КонецЕсли;
    		Возврат;
    	КонецЕсли;  
    	
    	Если СтрДлина(Комментарий) < 11 Тогда
    		ОбщегоНазначения.СообщитьОбОшибке("Комментарий слишком короткий!", Отказ, Заголовок);
    		Возврат;
    	КонецЕсли;
    
    КонецПроцедуры

    И пусть транзакция подождет. Дорогой, у тебя слишком короткий комментарий.

    safer_bwd, 24 Марта 2015

    Комментарии (5)
  10. Ruby / Говнокод #17827

    −289

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    def self.add_zeroes(string, stringSize, leftOrRight = true)
      while string.size < stringSize
        string = leftOrRight ? "0" + string : string + "0"
      end
      string
    end

    SDK, 20 Марта 2015

    Комментарии (5)
  11. Си / Говнокод #17821

    +135

    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
    #include "mono-math.h"
    
    #ifndef HAVE_SIGNBIT
    
    int
    mono_signbit_float (float x)
    {
    	union { float f; int i; } u;
    
    	u.f = x;
    
    	return u.i < 0;
    }
    
    int
    mono_signbit_double (double x)
    {
    	union { double d; int i[2]; } u;
    
    	u.d = x;
    
    #if G_BYTE_ORDER == G_LITTLE_ENDIAN
    	return u.i [1] < 0;
    #else
    	return u.i [0] < 0;
    #endif
    }
    
    #endif

    Говно тут в том, что int далеко не везде будет 32 бит.
    https://github.com/mono/mono/blob/master/mono/utils/mono-math.c оттуда

    j123123, 19 Марта 2015

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