1. PHP / Говнокод #12919

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    // autoload.php generated by Composer
    require_once __DIR__ . '/composer' . '/autoload_real.php';
    return ComposerAutoloaderInite3f5acf96d9ae66df74c4805c906a9e2::getLoader();

    Господа, что-то вот не пойму, можно ли ругаться в таких случаях, когда код генерированный. Можно ли писать всякое говно в код, если при этом говорить: "ты не должен туда смотреть, это скрипт, написанный скриптом для скрипта." Я тут вижу говноконкатенацию строковой константы со строковой константой оператором '.' и говноимя, класса в последней строке. Лично моё мнение, что если бы я написал код, в котором вынужден был бы генерировать такие имена, я бы констатировал серьёзную ошибку проектирования на более ранних стадиях.

    zasedanie, 19 Апреля 2013

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

    +137

    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
    if (curMenu != null)
    {
      depth = curMenu.Depth;
      Menu menuG = null;
      if (depth == 1)
      {
        menuG = curMenu;
      }
      if (depth == 2)
      {
        menuG = curMenu.Menu2;
      }
      if (depth == 3)
      {
        menuG = curMenu.Menu2.Menu2;
      }
      if (depth == 4)
      {
        menuG = curMenu.Menu2.Menu2.Menu2;
      }
      if (depth == 5)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 6)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 7)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
      if (depth == 8)
      {
        menuG = curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2;
      }
    }

    Nested set для петухов!

    validol, 19 Апреля 2013

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

    +132

    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
    72. 72
    73. 73
    74. 74
    75. 75
    <div class="breadcrumbs">
      <ul>
        <li>
          @if (curMenu != null)
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            if (depth == 1)
            {
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 2)
            {
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a> <span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 3)
            {
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 4)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 5)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 6)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 7)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 8)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }                                  
          }
          else if (ViewBag.Title != null && url!="/")
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            <span>@ViewBag.Title</span>
          }
        </li>
      </ul>
    </div>

    Хлебные крошки в каталоге "неограниченной" вложенности.

    validol, 19 Апреля 2013

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

    +159

    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
    $("#menu44").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").show();
      $("#menu555").hide();
      $("#menu666").hide();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    $("#menu55").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").show();
      $("#menu666").hide();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    
    $("#menu66").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").hide();
      $("#menu666").show();
      $("#menu777").hide();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });
    
    $("#menu77").click(function () {
      $("#menu111").hide();
      $("#menu222").hide();
      $("#menu333").hide();
      $("#menu444").hide();
      $("#menu555").hide();
      $("#menu666").hide();
      $("#menu777").show();
      $(".selMenu_group").removeClass("selMenu_group");
      $(this).children().addClass("selMenu_group");
    });

    Творение самого коммерчески эффективного разработчика студии.

    validol, 19 Апреля 2013

    Комментарии (3)
  5. Java / Говнокод #12915

    +70

    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
    private String formatString(String input, int lenght){
            String result = "";
            int len = lenght - input.length();
            int left = Math.round(len/2);
            int right = len - left;
            for(int i=0; i<left; i++){
                result = " " + result;
            }
            result = result + input;
            for(int i=0; i<right; i++){
                result = result + " ";
            }
            return result;
        }

    выравнивание текста в центре пустой строки фиксированной ширины.

    nafania217518, 19 Апреля 2013

    Комментарии (17)
  6. Pascal / Говнокод #12914

    +100

    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
    procedure print(RTK_select:boolean; RLK_select:boolen;MOLK_select:boolean)
    begin
         if (RTK_select and not RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК';
    
         if (not RTK_select and RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК';
    
         if (not RTK_select and not RLK_select and MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'МОЛК';
    
         if (RTK_select and RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК';
    
         if (not RTK_select and RLK_select and MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РЛК,МОЛК';
    
         if (RTK_select and not RLK_select and  MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,МОЛК';
    
         if (RTK_select and RLK_select and  MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := 'РТК,РЛК,МОЛК';
    
         if (not RTK_select and not RLK_select and not MOLK_select) then
             Excel.ActiveWorkBook.WorkSheets[1].Range['B4'] := '';
    end

    Обнаружено в недрах старинного проекта. Запись строчки по флажкам.

    astamir, 19 Апреля 2013

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // проверка при дополнительных надстройках
    		if (
    				$this->struct[$num][$v]['changes'] &&		 // если значение было изменено
    				array_key_exists($v, $this->values) &&		// и существуют альтернативно назначенные тип поля (select или radio)
    				isset( $this->values[$v]['vals'] ) &&			 // и также существуют для них значения для значений...
    				!isset( $this->values[$v]['vals'][ $this->struct[$num][$v]['value'] ] )		// НО, пришедшее значение НЕ СООТВЕТСТВУЕТ
    			) {
    
    					$this->struct[$num][$v]['error'] = 'Неправильно указано значение';
    		}

    Ёжкин кот. Вот чего он хотел этим сказать? И что мне теперь с этим делать теперь?

    DoctorHouse, 19 Апреля 2013

    Комментарии (37)
  8. Си / Говнокод #12912

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void ps(const char *a)
    {/*means putstring*/
    	for(; '\0' != *a; a++)
    		putchar(' ' != *a ? *a : (putchar('\n'),'\t'));
    }

    Как-то ночью, в час унылый, в голове собрав все силы,
    Разум темный, как могила, начал свой хромой закон.
    Начиная выражаться, а точнее проявляться,
    В мир безбрежный и зеленый, зло построило свой ход:
    Пальцы тонкие и злые, подчиняясь темной силе,
    Выхватив перо в чернилах, вывели сей говногод.

    ntfshard, 18 Апреля 2013

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

    +13

    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
    void CMainWindow::OnTimer(UINT_PTR id){
    	switch(id){
    	case IDT_TIMER1:
    		CClientDC dc(this);
    		dc.SetMapMode(MM_ISOTROPIC);
    		GetClientRect(&rcClient);
    		dc.SetWindowExt(CONSTANT,CONSTANT);
    		dc.SetViewportExt(rcClient.right,rcClient.bottom);
    		dc.SelectObject(GetStockObject(NULL_BRUSH));
    		dc.SetROP2(R2_NOTXORPEN);
    		wsprintf(buff,L"Score: %d       ", score);
    		dc.TextOut(5,5,buff,15);
    		if(!won || resized)dc.Ellipse(ptsBegin0.x-RAD,ptsBegin0.y-RAD,ptsBegin0.x+RAD,ptsBegin0.y+RAD);
    		ptsBegin0.x = rand() % (CONSTANT-RAD) + RAD;
    		ptsBegin0.y = rand() % (CONSTANT -RAD)+ RAD;
    		dc.DPtoLP(&ptsBegin0,1);
    		dc.Ellipse(ptsBegin0.x-RAD,ptsBegin0.y-RAD,ptsBegin0.x+RAD,ptsBegin0.y+RAD);
    		if(!won || resized)dc.Ellipse(ptsEnd0.x-RAD,ptsEnd0.y-RAD,ptsEnd0.x+RAD,ptsEnd0.y+RAD);
    		ptsEnd0.x = rand() % (CONSTANT - RAD) + RAD;
    		ptsEnd0.y = rand() % (CONSTANT - RAD) + RAD;
    		dc.DPtoLP(&ptsEnd0,1);
    		dc.Ellipse(ptsEnd0.x-RAD,ptsEnd0.y-RAD,ptsEnd0.x+RAD,ptsEnd0.y+RAD);
    		won = resized = false;
    	}
    }

    Abbath, 18 Апреля 2013

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

    +152

    1. 1
    $language = json_decode(JFactory::getUser()->getProperties()['params'])->language;

    Посоны, это нормально или у меня диагноз Чехова?

    nonamez, 18 Апреля 2013

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