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

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (tval.ToLower() == "true")
                                {
                                    if (!chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = true;
                                }
                                else if (tval.ToLower() == "false")
                                {
                                    if (chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = false;
                                }

    LOIC

    kasthack, 24 Января 2012

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    for (; itemList.Parent != null; {
            Item parent;
            itemList = parent.Parent;
        }
    )
    {
        parent = itemList.Parent.Parent.Parent;
        list.Add((object) parent);
    }

    Crazzy, 14 Декабря 2011

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // LockDepth IS enum type!
    if(LockDepth == DepthType.Infinity)
    	_depthElement.InnerText = this.__lockDepth.ToString();
    else
    	_depthElement.InnerText = (string) System.Enum.Parse(LockDepth.GetType(), LockDepth.ToString(), true);

    I got exception on line 5. The LockDepth is enum :)

    bugotrep, 06 Декабря 2011

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

    +120

    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
    /// <summary>
    /// Calculates and returns a hashcode based on this user's
    /// MarketName and default units. The hashcode should be
    /// unique for each different combination of MarketName and 
    /// units.
    /// </summary>
    /// <returns>An int that may be positive or negative.</returns>
    public override int GetHashCode()
    {
    // A function like this raises innumerable questions.  Why did they over ride the 
    // hash code function?  Why did they use an attribute that is not certain to be unique?
    // why did they not use the one that is going to be unique?  Why did they not cvheck to 
    // see if the thing they were hasing was not null?  When did my life go so far off the rails
    // that I have to deal with code like this?  How many places call this code? Why did they not 
    // include any meaningful comments? Why does it suddenly start breaking after the 3.5 upgrade?
    // in an effort to avoid thinking about those questions, I've justy changed the has to use the 
    // unique user id instead of the retarded defaultuserunits hash.
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append(this.MarketName);
    if (this.DefaultUserUnits != null)
    {
      sb.Append(Utility.StringUtility.GetJSObjectLiteral(this.DefaultUserUnits));
    }
    else
    {
      sb.Append(Utility.StringUtility.GetJSObjectLiteral(this.ID));
    }
      return sb.ToString().GetHashCode();
    }

    aprishchepov, 19 Ноября 2011

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

    +120

    1. 1
    if (ViewData["partialViewName"].ToString() == "" ||  ViewData["partialViewName"] == null)

    кратко и лаконично

    sergfreest, 09 Ноября 2011

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    protected bool RefreshRequired {
        get{
            return (
                (Request.QueryString["Saved"] == "true") ||
                (Request.QueryString["Recycled"] == "true") ||
                (Request.QueryString["Recalled"] == "true") ||
                (Request.QueryString["Restored"] == "true")
            );
        }
    }

    Eugene, 03 Октября 2011

    Комментарии (24)
  8. Pascal / Говнокод #7472

    +120

    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
    VAR
    m0:array[0..61,0..41]of byte;
    ma:array[1..60,1..40]of byte;
    I,J:byte;
    BEGIN
    randomize;
    for I:=0to 61do
    for J:=0to 41do
    if (I=0) or
       (I=61)or
       (J=0) or
       (J=61)
               then m0[I,J]:=0
               else m0[I,J]:=random(2);
    for I:=1to 60do
    for J:=1to 40do
    if m0[I,J]=1then ma[I,J]:=9
                else ma[I,J]:=m0[ I-1 , J-1  ] +
                                    m0[ I-1 , J     ] +
                                    m0[ I+1 , J+1 ]+
                                    m0[ I   , J+1  ]+
                                    m0[ I   , J-1   ]+
                                    m0[ I-1 , J+1 ]+
                                    m0[ I+1 , J-1 ]+
                                    m0[ I+1 , J    ];
    ... ... ... ... ... ... ... ... ... ... 
    ... ... ... ... ... ... ... ... ... ... 
    END.

    Начало игры САПЁР. Край массива заполняем нулями,
    середину - 0 или 1. В меньшем массиве складываем соседние
    клетки (выходит от 0 до 8), если мина - 9.

    dos, 06 Августа 2011

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

    +120

    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
    // Check if You need Administrator-level access to create a folder
    try
      mkdir(SDirectory + '\~TEST');
    except
      on E: exception do
      begin
        if E.message = 'File access denied' then
        begin
          MessageBox(self.Handle,
            'You need Administrator-level access to create this folder', '', MB_ICONERROR);
          exit;
        end;
      end;
    end;
    RmDir(SDirectory + '\~TEST');

    Мартышки плакали, кололись, но продолжали ронять UAC себе на лапки.

    bugmenot, 03 Августа 2011

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

    +120

    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
    var trimmedKey = Regex.Split(key, @"\.").Last();
                    if (_options.Any(o => o == ModelBinderOptions.ExpectUnderLineSymbolAsPrefixDelimiter))
                        trimmedKey = Regex.Split(trimmedKey, "_").Last();
    
                    if (_allRequiredParameters.Any(p => p.Key.ToLower() == trimmedKey.ToLower()))
                    {
                        var param = _allRequiredParameters.Single(p => p.Key.ToLower() == trimmedKey.ToLower());
    
                        try
                        {
                            if (param.Value != typeof(string))
                            {
                                if (Nullable.GetUnderlyingType(param.Value) != null)
                                {
                                    try
                                    {
                                        var parseMethod = Nullable.GetUnderlyingType(param.Value).GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                        var value = parseMethod.Invoke(null, new object[] { form[key] });
                                        formValues.Add(param.Key, value);
                                    }
                                    catch(Exception)
                                    {
                                        formValues.Add(param.Key, null);
                                    }
                                }
                                else
                                {
                                    var parseMethod = param.Value.GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                    var value = parseMethod.Invoke(null, new object[] { form[key] });
                                    formValues.Add(param.Key, value);
                                }
                                
                            }
                            else
                            {
                                formValues.Add(param.Key, form[key]);
                            }
                        }
                        catch (Exception)
                        {
                            // Если произошла ошибка парсинга - печально, но ничего не поделать
                        }
                    }

    Фееричный парсер

    dans, 21 Июня 2011

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    using System;
    
    class C
    {
        static void Main()
        {
            क्ष(0);
        }
    
        static void क्‍ष(int x) { Console.WriteLine(1); }
        static void क्ष(object x) { Console.WriteLine(2); }
    }

    Что будет напечатано ?


    Оч понравилось, нашел на простора интырнета (пардон если повтор)

    glilya, 28 Мая 2011

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