1. C++ / Говнокод #18380

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    float SGammaUIPanel::OnGetGamma() const
    {
      float DisplayGamma = GEngine->DisplayGamma;
      return GEngine ? DisplayGamma : 2.2f;
    }

    Этот и другие прелести из UE в статье https://www.unrealengine.com/blog/how-pvs-studio-team-improved-unreal-engines-code

    makc3d, 22 Июня 2015

    Комментарии (0)
  2. Куча / Говнокод #18379

    +124

    1. 1
    http://m.habrahabr.ru/post/249637/

    LispGovno, 21 Июня 2015

    Комментарии (13)
  3. Куча / Говнокод #18378

    −24

    1. 1
    2. 2
    3. 3
    Оффтоп #2
    
    Первая часть: http://govnokod.ru/18142

    3_14dar, 21 Июня 2015

    Комментарии (1153)
  4. Java / Говнокод #18377

    +67

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public class Client extends Thread {
        private final static Logger LOG = Logger.getLogger(Client.class);
    
        @Override
        public void run() {
            System.out.println("Client " + name + " comes to restaurant " + restaurant.getName());
            this.cashDesk = chooseCashDesk();
            System.out.println("Client " + getClientName() + " choosed the cashDesk#"+ cashDesk.getNumber());
           //...остальное говно
       }
    }

    Что такое логгер ? ХЗ. Требуют - значит должно быть!

    argamidon, 21 Июня 2015

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

    +145

    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
    #define pb push_back
    #define ll long long#define forit(it, r) for (auto it = r.begin(); it != r.end(); it++)
    #define forn(i, n) for (int i = 0; i < n; ++i)
    #define forn1(i, n) for (int i = 1; i < n; ++i)
    #define FOR(i, m, n) for (int i = m; i < n; ++i)
    #define ROF(i, m, n) for (int i = m; i >= n; --i)
    #define fori(n) for (int i = 0; i < n; ++i)
    #define forj(n) for (int j = 0; j < n; ++j)
    
    
    // ...
    
        string s;
        int k;
        while (i >= base)
            k = i % base,
            s.pb(k > 9 ? k + 'A' - 10 : k + 48),
            i /= base;
        k = i % base;
        s.pb(k > 9 ? k + 'A' - 10 : k + 48);
    
    // ...
    
        fori(s.size())
            if (i < s.size() - 1 && s[i] == '\\' && (s[i + 1] == 'n' || s[i + 1] == -47))
            {
                ret.append("%0A");
                i += 1 + (s[i + 1] == -47);//-47 -- russian t, because has the same place with n (\n == \t_russian)
            }
            else
                ret.append("%" + itoa((s[i] + 256) % 256, 16));

    Олимпиадники... Олимпиадники повсюду...

    Little-Horny, 21 Июня 2015

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

    +142

    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
    #define ADD_TYPE(type, tname, plname) \
    	int Get ## tname ## LocByName(string name) const\
    	{\
    		assert(MyInterface!=null);\
    		auto index=MyInterface.data->get_id_by_name(name);\
    		assert(index==-1 || MyInterface.data->Structure.Declarations[index].Type==ValueType::tname);\
    		return index;\
    	}\
    	ShaderParameters& Set ## tname (int loc, type val)\
    	{\
    		return Set ## plname (loc, &val, 0, 1);\
    	}\
    	ShaderParameters& Set ## tname (string name, type val)\
    	{\
    		return Set ## tname (Get ## tname ## LocByName(name), val);\
    	}\
    	ShaderParameters& Set ## plname (int loc, const type* vals, ushort first, ushort count)\
    	{\
    		if(loc==-1) return *this;\
    		assert(MyInterface!=null);\
    		update_id=++MyInterface.data->num_updates;\
    		values.Set(loc, vals, first, count);\
    		return *this;\
    	}\
    	ShaderParameters& Set ## plname (string name, const type* vals, ushort first, ushort count)\
    	{\
    		return Set ## plname (Get ## tname ## LocByName(name), vals, first, count);\
    	}\
    	type Get ## tname (int loc, ushort i=0) const\
    	{\
    		if(loc==-1) return type();\
    		return values.Get<type>(loc, i);\
    	}\
    	type Get ## tname (string name, ushort i=0) const\
    	{\
    		return Get ## tname (Get ## tname ## LocByName(name), i);\
    	}
    
    	ADD_TYPE(float, Float, Floats);
    	ADD_TYPE(Math::vec2, Vec2, Vecs2);
    	ADD_TYPE(Math::vec3, Vec3, Vecs3);
    	ADD_TYPE(Math::vec4, Vec4, Vecs4);
    	ADD_TYPE(int, Int, Ints);
    	ADD_TYPE(Math::ivec2, IVec2, IVecs2);
    	ADD_TYPE(Math::ivec3, IVec3, IVecs3);
    	ADD_TYPE(Math::ivec4, IVec4, IVecs4);
    	ADD_TYPE(Math::mat3, Mat3, Mats3);
    	ADD_TYPE(Math::mat4, Mat4, Mats4);
    
    #undef ADD_TYPE

    Вот так в моём движке идёт работа с параметрами шейдеров. Макросы делал, чтобы избежать копипаста. Выглядит ужасно, отлаживать неудобно, но зато использовать удобно. Буду думать, как красиво перевести это на шаблоны, чтобы не потерять удобство использования.

    gammaker, 20 Июня 2015

    Комментарии (0)
  7. JavaScript / Говнокод #18374

    +144

    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
    var me = this;            
    if (me.profile.carveoutSettings) {
        me.profile.carveoutSettings.truncationMethod = fields.truncationMethod;
        me.profile.carveoutSettings.truncationMode = fields.truncationMode;
        me.profile.carveoutSettings.applyTruncation = fields.applyTruncation;
        me.profile.carveoutSettings.truncationValue = fields.truncationValue;
        me.profile.carveoutSettings.applyExclusion = fields.applyExclusion;
        me.profile.carveoutSettings.serviceTypes = me.getSelected(me.getServiceTypeSelector().getStore(), 'ServiceSubCategoryID');
        me.profile.carveoutSettings.placeOfServices = me.getSelected(me.getPlaceOfServiceSelector().getStore(), 'code');
        me.profile.carveoutSettings.chronicConditions = me.getSelected(me.getChronicConditionSelector().getStore(), 'column');
    } else {
        this.profile.carveoutSettings = {
            truncationMethod: fields.truncationMethod,
            truncationMode: fields.truncationMode,
            applyTruncation: fields.applyTruncation,
            truncationValue: fields.truncationValue,
            applyExclusion: fields.applyExclusion,
            serviceTypes: me.getSelected(me.getServiceTypeSelector().getStore(), 'ServiceSubCategoryID'),
            placeOfServices: me.getSelected(me.getPlaceOfServiceSelector().getStore(), 'code'),
            chronicConditions: me.getSelected(me.getChronicConditionSelector().getStore(), 'column')
        }
    }

    Суслика видишь? а он есть ...

    expert, 20 Июня 2015

    Комментарии (0)
  8. Куча / Говнокод #18373

    −54

    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
    * g o a t s e x * g o a t s e x * g o a t s e x *
    g                                               g  
    o /     \             \            /    \       o
    a|       |             \          |      |      a
    t|       `.             |         |       :     t
    s`        |             |        \|       |     s
    e \       | /       /  \\\   --__ \\       :    e
    x  \      \/   _--~~          ~--__| \     |    x  
    *   \      \_-~                    ~-_\    |    *
    g    \_     \        _.--------.______\|   |    g
    o      \     \______// _ ___ _ (_(__>  \   |    o
    a       \   .  C ___)  ______ (_(____>  |  /    a
    t       /\ |   C ____)/      \ (_____>  |_/     t
    s      / /\|   C_____)       |  (___>   /  \    s
    e     |   (   _C_____)\______/  // _/ /     \   e
    x     |    \  |__   \\_________// (__/       |  x
    *    | \    \____)   `----   --'             |  *
    g    |  \_          ___\       /_          _/ | g
    o   |              /    |     |  \            | o
    a   |             |    /       \  \           | a
    t   |          / /    |         |  \           |t
    s   |         / /      \__/\___/    |          |s
    e  |           /        |    |       |         |e
    x  |          |         |    |       |         |x
    * g o a t s e x * g o a t s e x * g o a t s e x *

    https://searchcode.com/?q=goatse
    https://code.openhub.net/search?s=goatse

    3_14dar, 20 Июня 2015

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

    +142

    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
    template<class T> 
    void KillGorynich()
    {
    	T counter = 1;
    
    	while (true)
    	{
    		T newCount = counter + counter;
    
    		if (newCount > counter)
    		{
    			std::cout << "Отрубил Илья Муромец змею горынчу " << counter << " голов, а на их месте " << newCount << " выросло\n";
    			counter = newCount;
    		}
    		else
    		{
    			std::cout << "Отрубил Илья Муромец змею горынчу " << counter << " голов, и умер змей горыныч\n";
    			char * bits = "";
    
    			switch (sizeof(T) * 8)
    			{
    			case 8:
    				printf("Потому что восьмибитный был\n");
    				break;
    			case 16:
    				printf("Потому что шестнадцатибитный был\n");
    				break;
    			case 32:
    				printf("Потому что тридцатидвухбитный был\n");
    				break;
    			case 64:
    				printf("Потому что шестидесятичетырехбитный был\n");
    				break;
    			}
    
    			break;
    		}
    	}
    }
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	setlocale(LC_ALL, "russian");	
     	//KillGorynich<unsigned short>();
     	KillGorynich<unsigned int>();
     	//KillGorynich<unsigned long long>(); 
     	//KillGorynich<long double>();
    	
    	while (!_kbhit());
    	return 0;
    }

    Шаблонизм головного мозга.

    CrazyRussian, 19 Июня 2015

    Комментарии (1)
  10. PHP / Говнокод #18371

    +141

    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
    private function StrToFloat($str){
    		$str = trim($str);
    		$i=0;$k=1;
    		for($j=0;$j<=strlen($str);$j++){
    			if($str[$j]>='0' && $str[$j]<='9') {
    				$i = $i + $str[$j]*$k;
    				if($k>1) $k=$k*10;
    				else $k = $k*0.1;
    		    } else { 
    				if($str[$j]=='.' && $str[$j]==',')  $k = 0.1;
    				else if($str[$j]<=' ') {}   
    			}
    		}
    		return $i;
    	}

    heyzea1, 19 Июня 2015

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