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

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SDL_Rect sr = {
    		e->outputRect.x,
    		e->outputRect.y+e->lineHeight*line,
    		e->outputRect.w,
    		sr.y + e->lineHeight };

    laMer007, 06 Октября 2014

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static string GetString(string inpString, string defValue)
    {
    	if (inpString == null)
    		return defValue;
    	return inpString;
    }

    Этот метод заботливо лижит в файле с всякими вспомогательными функциями, мало ли где может понадобиться

    Smekalisty, 08 Сентября 2014

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

    +134

    1. 1
    2. 2
    if (paramList[i].GetType().Equals(typeof(String)))
    ...

    musuk, 04 Сентября 2014

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

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if ( cg_g2MarksAllModels == NULL )
    	{
    		cg_g2MarksAllModels = Cvar_Get( "cg_g2MarksAllModels", "0", 0 );
    	}
    
    	if (cg_g2MarksAllModels == NULL
    		|| !cg_g2MarksAllModels->integer )
    	{
    		firstModelOnly = qtrue;
    	}

    Cvar_Get возвращает ненулевой указатель в любом случае.

    gost, 31 Августа 2014

    Комментарии (7)
  6. Си / Говнокод #16608

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
        goto fail;
        goto fail;
    if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
        goto fail;

    https://www.imperialviolet.org/2014/02/22/applebug.html

    Понятно, что третий if не выполнится. Кстати, это был баг в Apple SSL/TLS, привёдший к уязвимости.

    Кстати, GCC с -Wall это не ловит. Ловит только Clang, и то только с -Wunreachable-code. Мораль: заключайте все тела ифов в блоки!

    someone, 28 Августа 2014

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

    +134

    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
    public static class GlobalFunc
    {
    	// bla-bla-bla ...
     
    	public static bool isDouble(string input)
    	{
    		Double dec;
    		return Double.TryParse(input, out dec);
    	}
    
    	public static bool isUShort(string input)
    	{
    		ushort dec;
    		return ushort.TryParse(input, out dec);
    	}
    
    	public static bool isShort(string input)
    	{
    		short dec;
    		return short.TryParse(input, out dec);
    	}
    
    	public static bool IsDate(string input)
    	{
    		DateTime date;
    		return DateTime.TryParse(input, out date);
    	}
    }

    face palm

    Smekalisty, 26 Августа 2014

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

    +134

    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
    String r_count = "";
                String r_cat = "";
                String r_pansion = "";
                for (Int32 ii = 0; ii < rows.Count; ii++)
                {
                    Int32 j = rows[ii].NNight;
                    DateTime d = rows[ii].DateBeg;
                    DateTime d_e = rows[ii].DateEnd;
                    Int32 type = rows[ii].MinLength > 0 ? 3 : 2;
                    j = (type == 3) ? -1 : j;
    
                    Int32 lengthMin = rows[ii].MinLength;
                    if (((d < date1 || d > date2) && type != 3))
                        continue;
                    else
                        if (!(d <= date1 && d_e >= date1 || d <= date2 && d_e >= date2) && date1 != DateTime.MinValue && date2 != DateTime.MaxValue && type == 3)
                            continue;
                    String _r_count = _Rooms[rows[ii].RoomId];
                    String _r_cat = _RoomCat[rows[ii].RoomCatId];
                    String _r_pansion = _Pansions[rows[ii].PansionId];
                    List<String> a = new List<string>();
                    if (_r_count != r_count || _r_cat != r_cat || _r_pansion != r_pansion)
                    {
                        if (!String.IsNullOrEmpty(r_count) && !String.IsNullOrEmpty(r_cat))
                        {
                            Pricing.RoomCat cat = new Pricing.RoomCat();
                            cat.RoomCount = r_count;
                            cat.RoomName = r_cat;
                            cat.PansionName = r_pansion;
    
                            p.rooms.Add(cat);
                        }
                        r_count = _r_count;
                        r_cat = _r_cat;
                        r_pansion = _r_pansion;
                    }

    Краху туроператоров способствовали также и собственные инженеры.

    tablecell, 20 Августа 2014

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

    +134

    1. 1
    2. 2
    3. 3
    class UnathorizedDevice : ArgumentException { public UnathorizedDevice() : base() { } }
    
    class LocalException : ArgumentException { public LocalException(string message) : base(message) { } }

    Говно или не говно? Мне кажется первое

    Smekalisty, 19 Августа 2014

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

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    for (var i = 0; i < numberPhone.Length; i++)
                    {
                        if (numberPhone[i] == ',')
                            return resultPhone;
                        if (Char.IsNumber(numberPhone[i]))
                        {
                            resultPhone += numberPhone[i];
                        }
                    }
                    return resultPhone;

    vladb9582, 14 Августа 2014

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

    +134

    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
    public virtual bool IsShown
        {
            get
            {
                if (obj && show && usePosition)
                {
                    return obj.transform.localPosition == show.localPosition;
                }
                if (obj && show && useScale)
                {
                    return obj.transform.localScale == show.localScale;
                }
    
                if (obj && show && useRotation)
                {
                    return obj.transform.localRotation == show.localRotation;
                }
    
                return false;
            }
        }
    
        public virtual bool IsHided
        {
            get
            {
                if (obj && hide && usePosition)
                {
                    return obj.transform.localPosition == hide.localPosition;
                }
                if (obj && hide && useScale)
                {
                    return obj.transform.localScale == hide.localScale;
                }
    
                if (obj && hide && useRotation)
                {
                    return obj.transform.localRotation == hide.localRotation;
                }
    
                return false;
            }

    Чувак с соседнего проекта много интересного рассказывал про хорошие практики кода. А потом он уволился, и коллеги стали изучать его творчество.

    golergka, 07 Августа 2014

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