1. Список говнокодов пользователя Eugene

    Всего: 11

  2. C# / Говнокод #13229

    +133

    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
    private bool IsSubscriptionFree()
    {
        try
        {
            if (AccountManager.CurrentManager.CurrentSubscription != null)
            {
                if (AccountManager.CurrentManager.CurrentSubscription.IsValid)
                {
                    if (AccountManager.CurrentManager.CurrentSubscription.Name.ToLower().Contains("free") ||
                        AccountManager.CurrentManager.CurrentSubscription.Name.ToLower().Contains("trial")
                    )
                    {
                        return true;
                    }
                }
                return false;
            }
            return false;
        }
        catch (Exception)
        {
            return false;
        }
    }

    Eugene, 25 Июня 2013

    Комментарии (31)
  3. JavaScript / Говнокод #12541

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function renderLayout(layout, column, colidx, restrictions) {
            //...
            if (!colidx) {
                    var flag = 1 << 0 | 1 << 1 | layout.title.type << 3;
                    if (layout.title.split) flag |= 1 << 2;
            }
            //...
    }

    Магические преобразования... или как стать незаменимым сотрудником!

    Eugene, 05 Февраля 2013

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

    +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
    37. 37
    private static T GetElementValue<T>(this XmlElement elm, string elementName, T defaultValue = default(T), bool throwIfError = false, bool throwIfMissing = false)
    			where T : IConvertible
    {
    	string val = GetElementValue(elm, elementName);
    	if (string.IsNullOrEmpty(val) == false)
    	{
    		if (typeof(T) == typeof(string))
    		{
    			return (T)(object)val;
    		}
    
    		if (typeof(T) == typeof(bool))
    		{
    			return (T)(object)(val == "1");
    		}
    
    		try
    		{
    			if (typeof(T) == typeof(DateTime))
    			{
    				return (T)(object)DateTime.Parse(val, System.Globalization.CultureInfo.InvariantCulture); ;
    			}
    
    
    			return (T)Convert.ChangeType(val, typeof(T), CultureInfo.InvariantCulture);
    		}
    		catch (Exception exc)
    		{
    			if (throwIfError)
    				throw exc;
    		}
    	}
    	if (throwIfMissing)
    		throw new ArgumentNullException("The parameter '" + elementName + "' is missing");
    
    	return defaultValue;
    }

    Используем Generics по-фэншую!

    Eugene, 05 Октября 2012

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

    +104

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    283: public static IList<Service> MultithreadHostCheckImplementation(string userName, string userPassword, string clientName, string serviceName, int iImplType, string samsungAccessToken,
    			bool checkSamsungAccountInCustomProps,string clientSoftware,string decryptedInstallKey,
    			out Guid userRefId, out string subscriptionId, out bool isIPhoneUser, out string serviceHostHeader)
             {
                 //....
    783: }

    Русский код. Ровно 500 строк отборного!

    Eugene, 05 Октября 2012

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

    +146

    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
    public ActionResult RenderDesigner()
    {
        // Get the received text
        var received = string.Empty;
        using(var reader = new StreamReader(Request.InputStream))
        {
            received = reader.ReadToEnd();
        }
    
        // Possible texts received
        var xml = "";
        var id = "";
        var moveId = "";
        int distance = 0;
        
        // Get all string from received
        var keys = received.Split('&');
        for (var i = 0; i < keys.Length; i++)
        {
            // XML
            if(keys[i].StartsWith("xml="))
            {
                xml = Server.UrlDecode(keys[i].Split('=')[1]);
            }
    
            // ID
            else if (keys[i].StartsWith("id="))
            {
                id = keys[i].Split('=')[1];
            }
            // Position
            else if (keys[i].StartsWith("distance="))
            {
                distance = int.Parse(keys[i].Split('=')[1]);
            }
    
            // Move ID
            else if (keys[i].StartsWith("moveId="))
            {
                moveId = keys[i].Split('=')[1];
            }
        }
    }

    разбор параметров POST запроса в стиле MVC

    Eugene, 15 Декабря 2011

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

    +128

    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
    public class BusinessUnitDetail
    {
        public string Description { get; set; }
    }
    
    ...
    
    [TestMethod]
    public void DescriptionTest()
    {
        BusinessUnitDetail target = new BusinessUnitDetail(); 
        string expected = "test test test\n test"; 
        string actual;
        target.Description = expected;
        actual = target.Description;
        Assert.AreEqual(expected, actual);
    }

    беспощадная проверка всего и вся

    Eugene, 25 Октября 2011

    Комментарии (26)
  8. 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)
  9. C# / Говнокод #7712

    +965

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    string[] val = ...;
    if (val.Length > 0)
    {
        return val[1];
    }
    else
        return string.Empty;

    IndexOutOfRangeException

    Eugene, 31 Августа 2011

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

    +126

    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
    public bool NewOrder {
        get {
            if( !string.IsNullOrEmpty( Request.QueryString[ "NewOrder" ] ) ) {
                ViewState[ "NewOrder" ] = Request.QueryString[ "NewOrder" ] == "true" ? true : false;
            } else {
                if( ViewState[ "NewOrder" ] != null )
                    return ( bool ) ViewState[ "NewOrder" ];
                else
                    ViewState[ "NewOrder" ] = true;
                }
            return ( bool ) ViewState[ "NewOrder" ];
        }
        set { ViewState[ "NewOrder" ] = value; }
    }

    Eugene, 05 Августа 2011

    Комментарии (2)
  11. JavaScript / Говнокод #6701

    +175

    1. 1
    2. 2
    // The blank option to make sure the DropDownList keeps its width
    var BlankOption = new Option('             ', 0);

    Eugene, 18 Мая 2011

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