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

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

    −293.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    If (g_manager.isVehicleArrived) Then
        ....
        g_data_layer.registerVehicle( new_vehicle )
    Else
        'Do Nothing
    End If
    
    'и Do Nothing еще в 20 блоках идущих подряд

    Кусок кода из одной очень серьезной системы, стоящей >2500$. Изменения несущественны, но суть говнокода не изменилась.

    guest, 10 Февраля 2009

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

    +108.8

    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
    ...
    IEnumerable<Status> Statuses;
    
    public Status GetCurrentStatus1() {
      var e = Statuses.GetEnumerator();
      e.MoveNext();
      return e.Current;
    }
    
    public Status GetCurrentStatus2() {
      foreach (var e in Statuses)
        return e;
      return null;
    }
    
    public Status GetCurrentStatus3() {
      return Statuses.FirstOrDefault();
    }

    Возник вопрос - что больший говнокод? Или есть вариант лучше? (3 вариант хорош, но только когда .NET 3 есть)

    guest, 01 Февраля 2009

    Комментарии (4)
  4. PHP / Говнокод #480

    +152.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (isset($this->handle) || !isset($this->handle) {
         echo "Не правильный тип ресурса... или не тип ресурса не известен..."
    }
    ...
    ...
    ...

    Проверим дескриптор :D

    guest, 30 Января 2009

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

    +148

    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
    <script type="text/javascript">
    $(document).ready(function(){
    
    $(".in").hover(
      function () {
      $(this).css("background-color","#EEE7C5");
      },
      function () {
      $(this).css("background-color","#97CAFF");
      }
    )
    });
    </script>
    
    
    
    
    
    <div onclick="location.href='feed2.png';" style="cursor: pointer;" class="in">
    Блог
    </div>

    guest, 28 Января 2009

    Комментарии (4)
  6. Python / Говнокод #471

    −346

    1. 1
    2. 2
    import time
    print time.ctime(1234567890)

    Перевод времени из Unix-time формата

    guest, 27 Января 2009

    Комментарии (4)
  7. PHP / Говнокод #461

    +142

    1. 1
    require_once ('../classes/class.partners.php');

    ГовнокодЛайт:: наверное все так, по непонятным причинам???

    Для чего в папке "classes" называть все файлы с "class."??

    guest, 27 Января 2009

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

    +89.9

    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
    static char DigitToChar(
        int _Digit
      )
    {
      switch (_Digit)
      {
        case 0: return '0';
        case 1: return '1';
        case 2: return '2';
        case 3: return '3';
        case 4: return '4';
        case 5: return '5';
        case 6: return '6';
        case 7: return '7';
        case 8: return '8';
        case 9: return '9';
        default: return ':';
      }
    }

    в результате долгих размышлений всетаки заменили на return '0' + _Digit;

    guest, 26 Января 2009

    Комментарии (4)
  9. PHP / Говнокод #441

    +11.6

    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
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    function SetFileAccessPermission($path, $arPermissions, $bOverWrite=true)
    	{
    		CMain::InitPathVars($site, $path);
    		$DOC_ROOT = CSite::GetSiteDocRoot($site);
    
    		if(strlen($path) <= 0)
    			$path="/";
    		if(($p = bxstrrpos($path, "/"))!==false)
    		{
    			$path_file = substr($path, $p+1);
    			$path_dir = substr($path, 0, $p);
    		}
    		else
    			return false;
    
    		if($path_file=="" && $path_dir=="")
    			$path_file = "/";
    
    		$PERM = Array();
    		if(file_exists($DOC_ROOT.$path_dir."/.access.php"))
    			@include($DOC_ROOT.$path_dir."/.access.php");
    		
    		$FILE_PERM = $PERM[$path_file];
    		if(!is_array($FILE_PERM))
    			$FILE_PERM=Array();
    
    		if(!$bOverWrite && count($FILE_PERM)>0)
    			return true;
    
    		$bDiff = false;
    
    		$str="<?\n";
    		foreach($arPermissions as $group=>$perm)
    		{
    			if(strlen($perm) > 0)
    				$str.="\$PERM[\"".$path_file."\"][\"".$group."\"]=\"".str_replace("\"", "\\\"", $perm)."\";\n";
    			if(!$bDiff && $FILE_PERM[$group]!=$perm)
    				$bDiff=true;
    		}
    
    		foreach($PERM as $file=>$arPerm)
    		{
    			if(strval($file) !==$path_file)
    				foreach($arPerm as $group=>$perm)
    					$str.="\$PERM[\"".$file."\"][\"".$group."\"]=\"".str_replace("\"", "\\\"", $perm)."\";\n";
    		}
    
    		if(!$bDiff)
    		{
    			foreach($FILE_PERM as $group=>$perm)
    				if($arPermissions[$group]!=$perm)
    				{
    					$bDiff==true;
    					break;
    				}
    		}
    
    		$str.="?".">";
    		
    		$this->SaveFileContent($DOC_ROOT.$path_dir."/.access.php", $str);
    		$GLOBALS["CACHE_MANAGER"]->CleanDir("menu");
    		unset($this->FILE_PERMISSION_CACHE[$site."|".$path_dir."/.access.php"]);
    		
    		if($bDiff)
    		{
    			$db_events = GetModuleEvents("main", "OnChangePermissions");
    			while($arEvent = $db_events->Fetch())
    				ExecuteModuleEvent($arEvent, Array($site, $path), $arPermissions);
    		}
    		return true;
    	}

    MegaLolnii bitrix
    самое смешное с 32 строчки

    guest, 23 Января 2009

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

    −55.5

    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
    for (ComplectationItemTO complectation : previewFullTO.getItemComplectations()) {
                for (Map.Entry entry : complectation.getInstances().entrySet()) {
                    if (entry.getKey().equals(SoundData.SOUND_COMPLECTATION_NAME)) {
    
                        SoundData soundData = getComplectationSoundData(complectation.getId(), previewFullTO);
                        soundsMap.put(complectation.getId(), soundData);
                    }
                }
            }
    
    
     private SoundData getComplectationSoundData(Long complectatiomId, PreviewFullTO previewFullTO) {
            for (ComplectationItemTO complectationSound : previewFullTO.getItemComplectations()) {
                if (complectationSound.getId().equals(complectatiomId)) {
                    for (Map.Entry entrySound : complectationSound.getInstances().entrySet()) {
                        if (entrySound.getKey().equals(SoundData.SOUND_LENGTH)) {
                            String soundLength = complectationSound.getInstances().get(SoundData.SOUND_LENGTH);
                            String soundData = complectationSound.getInstances().get(SoundData.SOUND_COMPLECTATION_NAME);
                            String productNumber = previewFullTO.getItemTO().getFeatureInstances().get("Product number");
                            String productRewritedName = previewFullTO.getItemTO().getProductTypeRewrited();
                            return new SoundData(soundData, productRewritedName, Long.valueOf(productNumber), soundLength);
                        }
                    }
                }
            }
            return null;
        }

    цикл в цикле и циклом погоняет

    guest, 20 Января 2009

    Комментарии (4)
  11. PHP / Говнокод #425

    +32.2

    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
    if ($content->num_of_subscribers == 1)
    	{
    		$icon_num = getExternalThemeFile("media/babble1-blue.png");
    	}
    	if ($content->num_of_subscribers == 2)
    	{
    		$icon_num = getExternalThemeFile("media/babble2-blue.png");
    	}
    	if ($content->num_of_subscribers == 3)
    	{
    		$icon_num = getExternalThemeFile("media/babble3-blue.png");
    	}
    	if ($content->num_of_subscribers == 4)
    	{
    		$icon_num = getExternalThemeFile("media/babble4-blue.png");
    	}
    	if ($content->num_of_subscribers == 5)
    	{
    		$icon_num = getExternalThemeFile("media/babble5-blue.png");
    	}
    	if ($content->num_of_subscribers == 6)
    	{
    		$icon_num = getExternalThemeFile("media/babble6-blue.png");
    	}
    	if ($content->num_of_subscribers == 7)
    	{
    		$icon_num = getExternalThemeFile("media/babble7-blue.png");
    	}
    	if ($content->num_of_subscribers == 8)
    	{
    		$icon_num = getExternalThemeFile("media/babble8-blue.png");
    	}
    	if ($content->num_of_subscribers == 9)
    	{
    		$icon_num = getExternalThemeFile("media/babble9-blue.png");
    	}
    	if ($content->num_of_subscribers == 10)
    	{
    		$icon_num = getExternalThemeFile("media/babble10-blue.png");
    	}
    	if ($content->num_of_subscribers > 10)
    	{
    		$icon_num = getExternalThemeFile("media/babble11-blue.png");
    	}

    И ведь не лень было копи-пэстить, а потом и цифорки менять :)

    guest, 19 Января 2009

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