1. Java / Говнокод #16824

    +83

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    TextView v = (TextView)
                            ((RelativeLayout)
                                ((AbsoluteLayout)
                                    ((LinearLayout)
                                        ((RelativeLayout)(
                                            (LinearLayout)activty.findViewById(R.id.container)).getChildAt(1))
                                        .getChildAt(0))
                                    .getChildAt(element))
                                .getChildAt(0))
                            .getChildAt(0);

    (Android)

    когда нет idшников...

    danpetruk, 08 Октября 2014

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

    −405

    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
    float scaleFactor = param1/172;
            if (scaleFactor < -1)
            {
                scaleFactor = -1;
            }
            _releaseTheKraken.transform = CGAffineTransformMakeScale(-scaleFactor,-scaleFactor);
            float krakenPosition = param1/2.4571;
            
            if (param1<-172)
            {
                krakenPosition = -70 + 172 + param1;
                _activityIndicator.center = CGPointMake(25, param1+15);
            }
            _releaseTheKraken.center = CGPointMake(147.5, krakenPosition);
            if (param1<-100)
            {
                float param2 = (-param1 - 100)/7.5;
                int param3 = floor(param2);
                if (param3<10)
                {...

    soprof, 08 Октября 2014

    Комментарии (11)
  3. Си / Говнокод #16822

    +136

    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
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    DIR_STRUCT * fill_dir_struct(DIR_STRUCT * dir_stc, _ptr_by_val_(char *) base_dir_path, _ptr_by_val_(char *) offset_dir)
    {
    	DIR_STRUCT * 		sub_dir;
    	DIR * 				srcdir;
    	struct 				stat st;
    	char 				full_sub_dir_path[MAX_PATH_SIZE];
    	struct dirent * 	dent;
    
    	sprintf(full_sub_dir_path, "%s/%s", base_dir_path, offset_dir);
    	dbgprintln("Directory %s", full_sub_dir_path);
    
    	if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    	{
    		memset(dir_stc, 0x00, sizeof(DIR_STRUCT));
    		if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		{
    			if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				strcpy(dir_stc->dir_path, offset_dir);
    				for( ;(NULL != (dent = readdir(srcdir))); )
    				{
    					if((0 != strcmp(dent->d_name, ".")) &&
    					   (0 != strcmp(dent->d_name, "..")) &&
    					   (0 <= fstatat(dirfd(srcdir), dent->d_name, &st, 0)))
    					{
    						if (S_ISDIR(st.st_mode)) //Directory
    						{
    							if(NULL != (sub_dir = fill_dir_struct(sub_dir, full_sub_dir_path, dent->d_name)))
    							{
    								dir_stc->sub_dirs 		 	  = list_append_node(dir_stc->sub_dirs, sub_dir);
    								dir_stc->dir_files_size 	 += sub_dir->dir_files_size;
    								dir_stc->sub_dir_files_count += sub_dir->sub_dir_files_count;
    							}
    							else
    							{
    								dir_stc = destroy_dir_struct(dir_stc);
    								break;
    							}
    						}
    						else 					//File
    						{
    							dbgprintln("File %s, size %lu bytes", dent->d_name, st.st_size);
    							dir_stc->dir_files 		 	 = list_append_node(dir_stc->dir_files, allocate_and_copy_char_buffer(dent->d_name, strlen(dent->d_name) + 1));
    							dir_stc->dir_files_size 	+= st.st_size;
    							dir_stc->sub_dir_files_count++;
    						}
    					}
    				}//End of for(;NULL != (dent = readdir(srcdir)); )
    				closedir(srcdir);
    			}
    			else//End of if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				dir_stc = destroy_dir_struct(dir_stc);
    			}
    		}//End of if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		else
    		{
    			dir_stc = destroy_dir_struct(dir_stc);
    		}
    	}//End of if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    
    	return dir_stc;
    }

    Восьмикратный индент, Йода нотейшн, const *(x) const в аргументах. Есть подозрение, что велосипедисты не знали о scandir.

    Это кладезь говна.

    codemonkey, 08 Октября 2014

    Комментарии (33)
  4. Си / Говнокод #16821

    +138

    1. 1
    if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))

    А кому-то это говно меинтейнить надо будет...

    codemonkey, 08 Октября 2014

    Комментарии (9)
  5. Lua / Говнокод #16820

    −93

    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
    function SAEController:GetPointVariableValue(WayNet,CurPoint)
      local waypointVars = {};
      for i = 0, WayNet:GetPointsCount() - 1 do
         local Link = WayNet:GetPoint(i);
        local PlaySound1 = Link:GetVariableValue("PlaySound1");
        local PlaySound2 = Link:GetVariableValue("PlaySound2");
        local PlaySound3 = Link:GetVariableValue("PlaySound3");
        
        local Effect1 = Link:GetVariableValue("Effect1");
        local Effect2 = Link:GetVariableValue("Effect2");
        local Effect3 = Link:GetVariableValue("Effect3");
        
        if PlaySound1 and CurPoint == Link then
          waypointVars.PlaySound1 = PlaySound1;  
        end;
        if PlaySound2 and CurPoint == Link then
          waypointVars.PlaySound2 = PlaySound2;  
        end;
        if PlaySound3 and CurPoint == Link then
          waypointVars.PlaySound3 = PlaySound3;  
        end;
        
        if Effect1 and CurPoint == Link then
          waypointVars.Effect1 = Effect1;  
        end;
        if Effect2 and CurPoint == Link then
          waypointVars.Effect2 = Effect2;  
        end;
        if Effect3 and CurPoint == Link then
          waypointVars.Effect3 = Effect3;  
        end;
      end;
      return waypointVars;
    end;

    Кусок игровой логики на Lua. Функция проверяет значение переменных в текущей точке пути моба.
    Мы перебираем все точки пути и сравниваем с текущей точкой моба, но это не нужно, так как именно текущая точка в функцию и передаётся!

    hdkeeper, 08 Октября 2014

    Комментарии (2)
  6. SQL / Говнокод #16819

    −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
    CREATE TABLE `numbers` (
      `number` BIGINT(20) DEFAULT NULL
    ) ENGINE=InnoDB;
    
    CREATE TABLE `numbers_small` (
      `number` INT(11) DEFAULT NULL
    ) ENGINE=InnoDB;
    
     -- numbers
    
    INSERT INTO `numbers` (`number`) VALUES('0');
    INSERT INTO `numbers` (`number`) VALUES('1000');
    INSERT INTO `numbers` (`number`) VALUES('2000');
    INSERT INTO `numbers` (`number`) VALUES('3000');
    INSERT INTO `numbers` (`number`) VALUES('4000');
    INSERT INTO `numbers` (`number`) VALUES('5000');
    
    -- 10 000 lines of inserting numbers into table numbers
    -- ...
    INSERT INTO `numbers` (`number`) VALUES('5999');
    INSERT INTO `numbers` (`number`) VALUES('6999');
    INSERT INTO `numbers` (`number`) VALUES('7999');
    INSERT INTO `numbers` (`number`) VALUES('8999');
    INSERT INTO `numbers` (`number`) VALUES('9999');
    
    -- numbers small
    
    INSERT INTO `numbers_small` (`number`) VALUES('0');
    INSERT INTO `numbers_small` (`number`) VALUES('1');
    INSERT INTO `numbers_small` (`number`) VALUES('2');
    INSERT INTO `numbers_small` (`number`) VALUES('3');
    INSERT INTO `numbers_small` (`number`) VALUES('4');
    INSERT INTO `numbers_small` (`number`) VALUES('5');
    INSERT INTO `numbers_small` (`number`) VALUES('6');
    INSERT INTO `numbers_small` (`number`) VALUES('7');
    INSERT INTO `numbers_small` (`number`) VALUES('8');
    INSERT INTO `numbers_small` (`number`) VALUES('9');

    Сделали нам программу на java. Прислали скрипт для обновления базы данных DatabaseUpdateScript.sql на 874 KB.

    ftr, 08 Октября 2014

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

    +58

    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
    #include "internationalization.h"
    namespace internationalization
    {
     
    QString numToString(int num, CASE padezh)
    {
        switch ( padezh )
        {
        case NOMINATIVE:
            switch ( num )
            {
            case 0:     return "ноль";
            case 1:     return "один";
            case 2:     return "два";
            case 3:     return "три";
            case 4:     return "четыре";
            case 5:     return "пять";
            case 6:     return "шесть";
            case 7:     return "семь";
            case 8:     return "восемь";
            case 9:     return "девять";
            case 10:     return "десять";
            case 11:     return "одиннадцать";
            case 12:     return "двенадцать";
            case 13:     return "тринадцать";
            case 14:     return "четырнадцать";
            case 15:     return "пятнадцать";
            case 16:     return "шестнадцать";
            case 17:     return "семьнадцать";
            case 18:     return "восемьнадцать";
            case 19:     return "девятнадцать";
            case 20:     return "двадцать";
            case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29:    return numToString( num / 10 * 10 ) + " " + numToString( num % 10 );
            case 30:     return "традцать";
            case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39:    return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 40:    return "сорок";
            case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49:    return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 50:    return "пятьдесят";
            case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59:      return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 60:    return "шестьдесят";
            case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69:      return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 70:    return "семьдесят";
            case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79:      return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 80:    return "восемьдесят";
            case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89:      return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 90:    return "девяносто";
            case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99:      return numToString( num / 10 * 10 )  + " " +  numToString( num % 10 );
            case 100:   return "сто";
            case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109:   return numToString( (num / 100 % 10 ) * 100 )  + " " +  numToString( num % 10 );
            case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199:      return numToString( (num / 100 % 10 ) * 100 ) + " " +  numToString( (num / 10 % 10 ) * 10 )  + " " +  numToString( num % 10 );

    Такой код мне встретился в моем старом проекте... Мне кажется, или из меня вышел бы неплохой программист в Китае или Индии?
    И там не конец, весь файл сего перла здесь: http://pastebin.com/tpAd95fd

    Dart_Sergius, 07 Октября 2014

    Комментарии (33)
  8. Java / Говнокод #16817

    +66

    1. 1
    if(version.StartsWith("Windows 9")) { /* 95 and 98 */ } else {

    по слухам, именно из-за этого говна следующая windows будет 10ой
    https://issues.jenkins-ci.org/secure/attachment/18777/PlatformDetailsTask.java

    Lokich, 07 Октября 2014

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

    +133

    1. 1
    2. 2
    //str will destroy
    char* strdup_(char* str){

    wat?

    LispGovno, 07 Октября 2014

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

    +158

    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
    if ($('ul.menu>li>ul>ul>li>a.active-trail').length == 1) {
        $('ul.menu>li>ul>ul>li>a.active-trail').addClass('work-active');
        if ($('ul.menu>li>ul>ul>li>a.active-trail').parent('li.hide_li').length == 1) {
            $('li.active-trail').removeClass('active-trail');
        } else {
            $('.active-trail').removeClass('active-trail');
        }
        $('.work-active').addClass('active-trail');
        $('.menu>.first ul').show();
        $('li.first').addClass('activefirst');
        $('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "none");
    } else if ($('ul.menu>li>ul>li>a.active-trail').length == 1) {
        $('ul.menu>li>ul>li>a.active-trail').addClass('work-active');
        $('.active-trail').removeClass('active-trail');
        $('.work-active').addClass('active-trail');
        $('.menu>.first ul').show();
        $('li.first').addClass('activefirst');
        $('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "none");
    } else {
        $('#block-system-main-menu ul.menu>li.first a').css("border-bottom", "1px #E7E7E7 solid");
    }

    Грамотное удаление активных классов меню

    olegpro, 07 Октября 2014

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