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

    В номинации:
    За время:
  2. Куча / Говнокод #13271

    +107

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Jenkins Auto-Updater added a comment - Today 00:35
    
    UNSTABLE: Integrated in contoso #223
    
    Create unit test for CN-858; Currently fails

    someone, 30 Июня 2013

    Комментарии (127)
  3. Pascal / Говнокод #13215

    +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
    function FindPathInPath(path1: string; path2: string): Boolean;
    var
      lst: TStringlist;
      i, l: integer;
    begin
      lst := TStringlist.Create;
      // ----------------------------------------------
      path1 := stringreplaceall(path1, '/', '\');
      path1 := stringreplaceall(path1, '\\', '\');
      // ----------------------------------------------
       path2 := stringreplaceall(path2, '\', '');
       path2 := stringreplaceall(path2, '/', '');
       path2 := stringreplaceall(path2, '"', '');
       path2 := stringreplaceall(path2, '<', '');
       path2 := stringreplaceall(path2, '>', '');
       path2 := stringreplaceall(path2, '?', '');
       path2 := stringreplaceall(path2, '|', '');
       path2 := stringreplaceall(path2, ':', '');
       path2 := stringreplaceall(path2, '*', '');
      // ----------------------------------------------
      for i := 2 to CountString(path1, '\') + 1 do
      begin
        lst.Add(StringField(path1, '\', i));
      end;
      for l := 0 to lst.Count - 1 do
      begin
        if lstrcmpi(pchar(lst[l]), pchar(path2)) = 0 then
        begin
          FindPathInPath := True;
          break;
      end;
      end;
      lst.Free;
      FindPathInPath := false;
      exit;
    end;

    Функция для поиска названий подпапок в файловых путях.
    Трудно судить г..нокод ли это, но так как я все же использовал более изящное решение, то быть посему...

    Stertor, 23 Июня 2013

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

    +107

    1. 1
    2. 2
    while (!jHove.WaitForExit(2000)) { }
            Thread.Sleep(2000); // just for case

    комментарий убил

    taburetka, 31 Января 2013

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

    +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
    //  define types
    const int FB2 = 0;
    const int TXT = 1;
    
    // private
    private int Type;
    …
    
    //  class methods
    public CVBook(string path, string type) {
        switch(type)
        {
            case "fb2":
                {
                    Type = 0;
                }
                break;
            case "txt":
                {
                    Type = 1;
                }
                break;
            default:
                {
                    throw new Exception("Unknown Book Format");
                }
        }
        …
        switch (Type) {
            case FB2: { … }
            case TXT: { … }
            default:
                {
                    throw new Exception("Unknown Book Format");
                }
            }
        }
    }

    Парсер книг, все в одном методе.

    ArtFeel, 30 Ноября 2012

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

    +107

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (_appliesTo.Contains("CH"))
    {
        depElig &= true;
    }
    else
    {
        depElig &= false;
    }

    Вроде такого boolshit тут ещё не было.

    roman-kashitsyn, 30 Августа 2012

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

    +107

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    public Quote[] ParseQuotesFromFile(string p){
                HtmlDocument d = new HtmlDocument();
                d.Load(p, new UTF8Encoding());
    #if !DEBUG
                return
    #endif
    #if DEBUG
                var v1 =
    #endif
     d.GetElementbyId("body")//main div
    #if DEBUG
    ; var v2 = v1
    #endif
    .ChildNodes//subnodes
    #if DEBUG
    ; var v3 = v2
    #endif
    .Where(a => a.Attributes.Contains("class"))//nodes with classes
    #if DEBUG
    ; var v4 = v3
    #endif
    .Where(a => a.Attributes["class"].Value == "quote")//quotes
    #if DEBUG
    ; var v5 = v4
    #endif
    .Where(a => a.ChildNodes.Any(b => b.Attributes.Contains("class")))//only real quotes
    #if DEBUG
    ; var v6 = v5
    #endif
    .Select(a => a.ChildNodes.Where(b => b.Attributes.Contains("class")).ToArray())//only usable
    #if DEBUG
    ; var v7 = v6
    #endif
    .Where(a => a.Length == 2)//drop ads
    #if DEBUG
    ; var v8 = v7
    #endif
    .Select(a => new Quote()
    {
        Text = conv.HtmlSpecialCharsDecode(a.First(b => b.Attributes["class"].Value == "text").InnerHtml.Replace("<br>", "\r\n"),StringTools.ReplaceType.Both),
        ID=BadParse(GetIdString(a)),
        Score=BadParse(GetScoreString(a))})
    #if DEBUG
    ; var v9 = v8
    #endif
    .ToArray();
    #if DEBUG
                return v9;
    #endif
            } private static string GetScoreString(HtmlNode[] a){
    #if !DEBUG
                return
    #endif
    #if DEBUG
                var v1 =
    #endif
     a.First(b => b.Attributes["class"].Value == "actions")
    #if DEBUG
    ; var v2 = v1
    #endif
    .ChildNodes.Where(b => b.Name != "#text")
    #if DEBUG
    ; var v3 = v2
    #endif
    .First(b => b.Attributes["class"].Value == "rating-o")
    #if DEBUG
    ; var v4 = v3
    #endif
    .FirstChild
    #if DEBUG
    ; var v5 = v4
    #endif
    .InnerText;
    #if DEBUG
                return v5;
    #endif
            } private static string GetIdString(HtmlNode[] a) {
    #if !DEBUG
                return
    #endif
    #if DEBUG
                var v1=
    #endif
                a.First(b => b.Attributes["class"].Value == "actions")
    #if DEBUG
    ; var v2 = v1
    #endif
    .ChildNodes.Where(b => b.Name != "#text")
    #if DEBUG
    ; var v3 = v2
    #endif
    .First(b => b.Attributes["class"].Value == "id")
    #if DEBUG
    ; var v4 = v3
    #endif
                    .InnerText.Replace("#", "");
    #if DEBUG
                return v4;
    #endif
    }

    Это должен был быть парсер bash.org.ru
    Самоое странное, что код даже работает

    kasthack, 12 Августа 2012

    Комментарии (18)
  8. C# / Говнокод #11503

    +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
    if (curMenu != null)
     {
     depth = curMenu.Depth;
     Menu menuG = null;
     if (depth == 1)
     {
     menuG = curMenu;
     }
     if (depth == 2)
     {
     menuG = curMenu.Menu2;
     }
     if (depth == 3)
     {
     menuG = curMenu.Menu2.Menu2;
     }
     if (depth == 4)
     {
     menuG = curMenu.Menu2.Menu2.Menu2;
     }

    Меню "неограниченной" вложенности

    Mihard, 31 Июля 2012

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

    +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
    @Inject
    protected MainWindowController(
    		final SessionController session,
    		final QueueController queueController,
    		final MachineController machineController,
    		final PrintController printController,
    		final MainWindow window,
    		final UIHandler uiHandler,
    		final ImageCache imageCache,
    		final EventBus bus,
    		final ActiveOrderHolder orderHolder,
    		final ApiClientAsync apiClient,
    		final ReferenceDataCache dataCache,
    		@SvnRevision final int svnRevision) throws IOException {

    someone, 20 Июля 2012

    Комментарии (17)
  10. Pascal / Говнокод #10066

    +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
    function Ns(ds: char; var vs: byte): boolean;
    begin
       case ds of
    'Q': vs:= 81;
    'W': vs:= 87;
    'E': vs:= 69;
    'R': vs:= 82;
    'T': vs:= 84;
    'Y': vs:= 89;
    'U': vs:= 85;
    'I': vs:= 73;
    'O': vs:= 79;
    'P': vs:= 80;
    'A': vs:= 65;
    'S': vs:= 83;
    'D': vs:= 68;
    'F': vs:= 70;
    'G': vs:= 71;
    'H': vs:= 72;
    'J': vs:= 74;
    'K': vs:= 75;
    'L': vs:= 76;
    'Z': vs:= 90;
    'X': vs:= 88;
    'C': vs:= 67;
    'V': vs:= 86;
    'B': vs:= 66;
    'N': vs:= 78;
    'M': vs:= 77;
    else vs:= 0;
      end;
     if vs = 0 then Result:= false else Result:= true;
     end;

    Определение кода виртуальных клавиш, вот что бывает, когда кто-то не знает матчасть, вся эта белиберда легко заменяется на :

    function Ns(ds: char; var vs: byte): boolean;
    begin
    case ds of
    'A'..'Z': vs:= byte(ds);
    else vs:= 0;
    end;
    if vs = 0 then Result:= false else Result:= true;
    end;

    И не лень же было клаву мучить!

    Alegun, 27 Апреля 2012

    Комментарии (14)
  11. Pascal / Говнокод #9180

    +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
    begin
    writeln('Enter 1st number');
    readln(a);
    writeln('Enter 2st number');
    readln(b);
    writeln('Enter 3st number');
    readln(c);
    
    if a = b then if a = c then if b = c then       ;
    writeln('numbers are');
    
    if a > b then if a = c then if b < c then
    writeln('a Equally c and it is more b')         ;
    
    if a = b then if a > c then if b > c then
    writeln('a Equally b and it is more c')         ;
    
    if a < b then if a < c then if b = c then
    writeln('b Equally c and it is more a')         ;
    
    if a > b then if a > c then if b > c then
    writeln('a it is more ')                        ;
    if a > b then if a > c then if b < c then
    writeln('a it is more ')                        ;
    if a > b then if a > c then if b = c then
    writeln('a it is more ')                        ;
    
    if a < b then if a = c then if b > c then
    writeln('b it is more ')                        ;
    if a < b then if a > c then if b > c then
    writeln('b it is more ')                        ;
    if a < b then if a < c then if b > c then
    writeln('b it is more ')                        ;
    
    if a = b then if a < c then if b < c then
    writeln('c it is more ')                        ;
    if a > b then if a < c then if b < c then
    writeln('c it is more ')                        ;
    if a < b then if a < c then if b < c then
    writeln('c it is more ')                        ;

    Такое выдал один из моих учеников в 10м классе после того, как отказался учится рисовать блок-схемы и сказал, что сразу сможет писать. Задание заключалось в том, чтобы программа выводила большее из 3х введенных пользователем чисел.

    Rage, 20 Января 2012

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