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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // Since C++20
    
    struct A {
      int&& r;
    };
    A a1{7}; // OK, lifetime is extended
    A a2(7); // well-formed, but dangling reference

    Удачной отладки!

    PolinaAksenova, 06 Мая 2021

    Комментарии (57)
  3. Kotlin / Говнокод #27030

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    object Cорок {
        infix fun тысяч(b: String) = this
        infix fun в(a: String) = this
        infix fun сунули(a: String) = this
    }
    
    fun main() {
        Cорок тысяч "обезъян" в "жопу" сунули "банан"
    }

    DypHuu_niBEHb, 15 Октября 2020

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

    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
    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
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    <script>
    			if (!window.BX && top.BX)
    				window.BX = top.BX;
    
    			<?CMedialib::AppendLangMessages();?>
    			window.<?= $arConfig['event']?> = function(bLoadJS)
    			{
    				if (window.oBXMedialib && window.oBXMedialib.bOpened)
    					return false;
    
    				<?if(!CMedialib::CanDoOperation('medialib_view_collection', 0)):?>
    					return alert(ML_MESS.AccessDenied);
    				<?else:?>
    
    				if (!window.BXMediaLib)
    				{
    					if (bLoadJS !== false)
    					{
    						// Append CSS
    						BX.loadCSS("/bitrix/js/fileman/medialib/medialib.css");
    
    						var arJS = [];
    						if (!window.jsAjaxUtil)
    							arJS.push("/bitrix/js/main/ajax.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT"].'/bitrix/js/main/ajax.js')?>");
    						if (!window.jsUtils)
    							arJS.push("/bitrix/js/main/utils.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT"].'/bitrix/js/main/utils.js')?>");
    						if (!window.CHttpRequest)
    							arJS.push("/bitrix/js/main/admin_tools.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT"].'/bitrix/js/main/admin_tools.js')?>");
    
    						arJS.push("/bitrix/js/fileman/medialib/common.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT"].'/bitrix/js/fileman/medialib/common.js')?>");
    						arJS.push("/bitrix/js/fileman/medialib/core.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT"].'/bitrix/js/fileman/medialib/core.js')?>");
    						BX.loadScript(arJS);
    					}
    					return setTimeout(function(){<?=$arConfig['event']?>(false)}, 50);
    				}
    
    				<?CMedialib::ShowJS()?>
    				<?
    					$arSet = explode(',' , CUserOptions::GetOption("fileman", "medialib_user_set", '600,450,0'));
    					$width = $arSet[0] ? intVal($arSet[0]) : 600;
    					$height = $arSet[1] ? intVal($arSet[1]) : 450;
    					$coll_id = $arSet[2] ? intVal($arSet[2]) : 0;
    				?>
    				window._mlUserSettings = window._mlUserSettings || {width: <?=$width?>, height: <?=$height?>, coll_id: <?=$coll_id?>}
    
    				var oConfig =
    				{
    					sessid: "<?=bitrix_sessid()?>",
    					thumbWidth : <?= COption::GetOptionInt('fileman', "ml_thumb_width", 140)?>,
    					thumbHeight : <?= COption::GetOptionInt('fileman', "ml_thumb_height", 105) ?>,
    					userSettings : window._mlUserSettings,
    					resType: "<?= $resultDest?>",
    					Types : <?= CUtil::PhpToJSObject(CMedialib::GetTypes($arConfig['types']))?>,
    					arResultDest : <?= CUtil::PhpToJSObject($arConfig['arResultDest'])?>,
    					rootAccess: {
    						new_col: '<?= CMedialib::CanDoOperation('medialib_new_collection', 0)?>',
    						edit: '<?= CMedialib::CanDoOperation('medialib_edit_collection', 0)?>',
    						del: '<?= CMedialib::CanDoOperation('medialib_del_collection', 0)?>',
    						new_item: '<?= CMedialib::CanDoOperation('medialib_new_item', 0)?>',
    						edit_item: '<?= CMedialib::CanDoOperation('medialib_edit_item', 0)?>',
    						del_item: '<?= CMedialib::CanDoOperation('medialib_del_item', 0)?>',
    						access: '<?= CMedialib::CanDoOperation('medialib_access', 0)?>'
    					},
    					bCanUpload: <?= $USER->CanDoOperation('fileman_upload_files') ? 'true' : 'false'?>,
    					bCanViewStructure: <?= $USER->CanDoOperation('fileman_view_file_structure') ? 'true' : 'false'?>,
    					strExt : "<?= CUtil::JSEscape(CMedialib::GetMediaExtentions())?>",
    					lang : "<?= $arConfig['lang']?>",
    					description_id : '<?= CUtil::JSEscape($arConfig['description_id'])?>'
    				};
    
    				window.oBXMedialib = new BXMediaLib(oConfig);
    				oBXMedialib.Open();
    				<?endif;?>
    			};
    			</script>

    phpBidlokoder2, 20 Марта 2020

    Комментарии (57)
  5. Assembler / Говнокод #25370

    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
    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
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    format pe console 5.0
    
    entry start
    
    include 'win32ax.inc'
    
    SLEEP=1000
    
    section '.data' data readable
    
      _hello db 'Hello "https://www.govnokod.ru/"!',13,10,0
      _conout db 'CONOUT$',0
      align 8
      _conoutnt du '\??\CONOUT$',0
    
    section '.data?' data readable writeable
    
      bytes_write dd ?
      houtput dd ?
      length dd ?
    
    section '.text' code readable executable
    
    start:
      call _novice
      invoke Sleep,SLEEP
      call _advanced
      invoke Sleep,SLEEP
      call _psycho
      invoke Sleep,SLEEP
      invoke ExitProcess,0
    
    _novice:
      invoke GetStdHandle,STD_OUTPUT_HANDLE
      mov [houtput],eax
      invoke lstrlen,_hello
      mov [length],eax
      invoke WriteConsole,[houtput],_hello,[length],bytes_write,0
      ret
    
    _advanced:
      invoke CreateFileA,_conout,GENERIC_WRITE,0,0,OPEN_EXISTING,0,0
      mov [houtput],eax
      invoke lstrlen,_hello
      mov [length],eax
      invoke WriteFile,[houtput],_hello,[length],bytes_write,0
      invoke CloseHandle,[houtput]
      ret
    
    _psycho:
      push ebx
      sub esp,40
      mov ebx,esp
      mov word[ebx+24],22
      mov word[ebx+26],24
      mov dword[ebx+28],_conoutnt
      mov dword[ebx+0],24
      mov dword[ebx+4],0
      lea eax,[ebx+24]
      mov dword[ebx+8],eax
      mov dword[ebx+12],$00000040
      mov dword[ebx+16],0
      mov dword[ebx+20],0
      lea eax,[ebx+32]
      invoke NtCreateFile,houtput,$40100080,ebx,eax,0,0,0,1,$60,0,0
      invoke lstrlen,_hello
      mov [length],eax
      lea eax,[ebx+32]
      invoke NtWriteFile,[houtput],0,0,0,eax,_hello,[length],0,0
      invoke NtClose,[houtput]
      add esp,40
      pop ebx
      ret
    
    section '.import' data import readable
    
      library\
        ntdll,'ntdll.dll',\
        kernel32,'kernel32.dll'
    
      import ntdll,\
        NtClose,'NtClose',\
        NtCreateFile,'NtCreateFile',\
        NtWriteFile,'NtWriteFile'
    
      include 'api\kernel32.inc'
    
    section '.reloc' fixups data readable discardable

    Интересно какой из методов (_novice, _advanced, _psycho) вывода в консоль является говнокодом?

    chiacorp, 10 Февраля 2019

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

    +1

    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
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    
    string pswdGen(int quantity) {
        srand(time(0));
        char chars[] = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890@\#\$\%\&\-\+\!\/\_"; // Символы, из которых будет состоять пароль 
        string password;
        for(int i = 0; i < quantity; i++) {
            password += chars[rand() % (sizeof(chars)/sizeof(*chars))]; // Добавить рандомный символ из списка в пароль
        }
        return password;
    }
    int main() {
        int charNo;
        cout << "How many characters do you want in the password?" << endl;
        cin >> charNo;
        cout << "Your new password is: " << pswdGen(charNo) << endl;
        return 0;
    }

    Генерит произвольные пароли. Говно?

    shite, 05 Августа 2018

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

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Object oriented style
    string mysqli::escape_string ( string $escapestr )
    string mysqli::real_escape_string ( string $escapestr )
    
    
    Procedural style
    string mysqli_real_escape_string ( mysqli $link , string $escapestr )
    
    
    http://php.net/manual/en/mysqli.real-escape-string.php

    roskomgovno, 20 Июля 2018

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

    +5

    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
    <?php
     
    class Govno
    {
    	function __toString()
    	{
    		return 'govno';
    	}
    }
     
    ${'<?php'}   = 42;
    ${M_PI}      = 43;
    ${new Govno} = 44;
    ${"\0"}      = 45;
    ${''}        = 46;
    ${null}      = 47;
     
    ${create_function('', 'return null;')} = 444;
    ob_start();
    phpinfo();
    ${ob_get_clean()} = 9000;
     
     
    var_dump(get_defined_vars());

    В ПХП возможно всё, если делать это через жопу.
    https://ideone.com/svS2sO

    Stallman, 16 Ноября 2017

    Комментарии (57)
  9. Pascal / Говнокод #22991

    −1414

    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
    function Unescape(const s: AnsiString): widestring;
    var
      i: Integer;
      j: Integer;
      c: Integer;
    begin
      // Make result at least large enough. This prevents too many reallocs
      SetLength(Result, Length(s));
      i := 1;
      j := 1;
      while i <= Length(s) do begin
        if s[i] = '\' then begin
          if i < Length(s) then begin
            // escaped backslash?
            if s[i + 1] = '\' then begin
              Result[j] := '\';
              inc(i, 2);
            end
            // convert hex number to WideChar
            else if (s[i + 1] = 'u') and (i + 1 + 4 <= Length(s))
                    and TryStrToInt('$' + string(Copy(s, i + 2, 4)), c) then begin
              inc(i, 6);
              Result[j] := WideChar(c);
            end else begin
              raise Exception.CreateFmt('Invalid code at position %d', [i]);
            end;
          end else begin
            raise Exception.Create('Unexpected end of string');
          end;
        end else begin
          Result[j] := WideChar(s[i]);
          inc(i);
        end;
        inc(j);
      end;
    
      // Trim result in case we reserved too much space
      SetLength(Result, j - 1);
    end;

    Это не вирус. Просто в Delphi 7 не завезли JSon.

    doctor_stertor, 07 Мая 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    CharT getline(std::istream& i, string& s, const CharT* delim) {
    ...
        if (!i.operator void*()) 
            break;
    ...
    }

    Библиотека Apache UIMA-CPP.
    Что могло заставить написать так, вместо обычного if (i)? Какой-то древний компилятор, который не использует каст к указателю в условии?
    Ну и, разумеется, в C++11 ios::operator void*() заменили на explicit ios::operator bool(), так что работать перестало.

    Bobik, 29 Мая 2016

    Комментарии (57)
  11. C# / Говнокод #18936

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public TD GetColumn(int i) {
                try {
                    return this.Columns[i];
                } catch {
                    return this.Columns[i - 1];
                }
            }

    в продолжение парсера

    Lokich, 29 Октября 2015

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