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

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    public ActionResult Exception()
    {
      throw new Exception("You better not to execute this!");
    }

    нашел говнокод, оставленный прошлым архитектором)

    govnokoder1488, 28 Января 2016

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

    +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
    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
    switch (button.Tag.ToString()) {
                    case "Ezp":
                    {
                        if (nowLayer.OpenedFiles.Count == 0)
                        {
                            nowLayer.OpenedFiles = new List<ExemplarFile> { new ExemplarFile("") };
                        }
                        if (nowLayer.OpenedFiles[0].EdinZemleps == null)
                        {
                            nowLayer.OpenedFiles[0].EdinZemleps = new List<EdinZemlep>();
                        }
                        var strName = ":ЕЗ" + (nowLayer.OpenedFiles[0].EdinZemleps.Count + 1);
                        nowLayer.OpenedFiles[0].EdinZemleps.Add(new EdinZemlep(strName) { Status = StatusEnum.Образуемый });
                        _ezpListTreeView.Add(new EzpTreeView { NameEzp = strName, ContourList = new List<ContourTreeView>(), ParcelList = new List<PartZuTreeView>(), IsEzpVisible = true, IsSelectedEzp = false } );
                        _dictionaryEzpTreeViewFile.Add(_ezpListTreeView[_ezpListTreeView.Count - 1], nowLayer.OpenedFiles[0]);
                        _dictionaryEzpTreeViewEdinZemlep.Add(_ezpListTreeView[_ezpListTreeView.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[nowLayer.OpenedFiles[0].EdinZemleps.Count - 1]);
                        break;
                    }
                    case "ContourEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((button.Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        var strName = (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].CadNum != "" ? nowLayer.OpenedFiles[0].EdinZemleps[indexEz].CadNum : nowLayer.OpenedFiles[0].EdinZemleps[indexEz].LastName) + "(" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours.Count + 1) + ")";
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].AddContour(new Contour(strName) { Status = StatusEnum.Образуемый });
                        if (_ezpListTreeView[indexEz].ContourList == null)
                        {
                            _ezpListTreeView[indexEz].ContourList = new List<ContourTreeView>();
                        }
                        strName = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours.Last().Name;
                        _ezpListTreeView[indexEz].ContourList.Add(new ContourTreeView { NameContour = strName, IsContourVisible = true, IsSelectedContour = false } );
                        for (var i = 0; i < _ezpListTreeView[indexEz].ContourList.Count; i++)
                        {
                            _ezpListTreeView[indexEz].ContourList[i].NameContour = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours[i].Name;
                        }
                        break;
                    }
                    case "ZuEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((button.Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        var strName = ":ЗУ" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Count + 1);
                        if (_ezpListTreeView[indexEz].ParcelList == null)
                        {
                            _ezpListTreeView[indexEz].ParcelList = new List<PartZuTreeView>();
                        }
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Add(new Parcel(strName) { Status = StatusEnum.Образуемый });
                        _ezpListTreeView[indexEz].ParcelList.Add(new PartZuTreeView { NamePartZu = strName, ContourList = new List<ContourTreeView>(), PartList = new List<PartTreeView>(), IsPartZuVisible = true, IsSelectedPartZu = false });
                        _dictionaryPartZuTreeViewFile.Add(_ezpListTreeView[indexEz].ParcelList[_ezpListTreeView[indexEz].ParcelList.Count - 1], nowLayer.OpenedFiles[0]);
                        _dictionaryPartZuTreeViewParcel.Add(_ezpListTreeView[indexEz].ParcelList[_ezpListTreeView[indexEz].ParcelList.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Count - 1]);
                        break;
                    }              
                    case "PartZuEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        indexZu = ((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Children.IndexOf((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid));
                        var sbPrclName = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].LastName + "/чзу" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Count + 1);
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Add(new Subparcel(sbPrclName) { Status = StatusEnum.Образуемый });
                        if (_ezpListTreeView[indexEz].ParcelList[indexZu].PartList == null)
                        {
                            _ezpListTreeView[indexEz].ParcelList[indexZu].PartList = new List<PartTreeView>();
                        }
                        _ezpListTreeView[indexEz].ParcelList[indexZu].PartList.Add(new PartTreeView { NamePart = sbPrclName, ContourList = new List<ContourTreeView>(), IsPartVisible = true, IsSelectedPart = _ezpListTreeView[indexEz].ParcelList[indexZu].IsSelectedPartZu });
                        _dictionaryPartTreeViewSubparcel.Add(_ezpListTreeView[indexEz].ParcelList[indexZu].PartList[_ezpListTreeView[indexEz].ParcelList[indexZu].PartList.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels[nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Count - 1]);
                        break;
                    }

    и это продолжается, продолжается и продолжается....

    deathguard771, 27 Января 2016

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

    +1

    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    namespace SmalltalkPHP
    {
    	class Model
    	{
    		internal static void CreateClass(string className)
    		{
    			ClassObject = new Class(className);
    		}
    
    		public static Class ClassObject { get; set; }
    		public class Message
    		{
    			public class Arguments
    			{
    				private SortedList arguments = new SortedList();
    				public void Add(String key, String name)
    				{
    					this.arguments.Add(key, name);
    				}
    				public String AsPhp()
    				{
    					String[] sb = new String[arguments.Count];
    					int i = 0;
    					foreach (DictionaryEntry arg in arguments)
    					{
    						if ((String)(arg.Value) != "") sb[i] = "$" + arg.Value;
    						i++;
    					}
    					return String.Join(", ", sb);
    				}
    				public String MakeFunctionName()
    				{
    					String[] sb = new String[arguments.Count];
    					int i = 0;
    					foreach (DictionaryEntry arg in arguments)
    					{
    						if ((String)(arg.Key) != "") sb[i] = (String)arg.Key;
    						i++;
    					}
    					return String.Join("_", sb);
    				}
    			}
    			public class Generic
    			{
    				public virtual string AsPhp()
    				{
    					return "nya";
    				}
    			}
    			public class Unary : Generic
    			{
    				public Unary(String name, Boolean isStatic = false)
    				{
    					this.Name = name;
    					this.Arguments = new Arguments();
    					this.IsStatic = isStatic;
    				}
    				public string Name { get; set; }
    				public Arguments Arguments { get; set; }
    				public Boolean IsStatic { get; set; }
    				public string PhpHeader
    				{
    					get
    					{
    						return String.Format("public {0}function {1}()", IsStatic ? "static " : "", Name);
    					}
    				}
    
    				public override string AsPhp()
    				{
    					return PhpHeader;
    				}
    			}
    			public class Keyword : Generic
    			{
    				public Keyword(Boolean isStatic = false)
    				{
    					this.Arguments = new Arguments();
    					this.IsStatic = isStatic;
    				}
    				public string Name { get { return Arguments.MakeFunctionName(); } }
    				public Arguments Arguments { get; set; }
    				public Boolean IsStatic { get; set; }
    				public string PhpHeader
    				{
    					get
    					{
    						return String.Format("public {0}function {1}({2})", IsStatic ? "static " : "", Name, Arguments.AsPhp());
    					}
    				}
    
    				public override string AsPhp()
    				{
    					return PhpHeader;
    				}
    			}
    		}
    	}
    }

    Писал конвертер Smalltalk -> PHP
    Где-то еще валяется Smalltalk -> Erlang

    kgm-rj, 14 Января 2016

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

    −2

    1. 1
    2. 2
    3. 3
    var indexes = T.Select((item, index) => new { Item = item, Index = index })
                    .Where(nitem => n.Item == 0).Select(nindex => n.Index).ToArray();
    Console.WriteLine("Первый: {0}, последний: {1}", indexes.First(), indexes.Last());

    Не слишком много item index? index item?

    Govno_Coder, 14 Января 2016

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(user.pass = pass_to_hash(password)){
           return done(null, user);
    }else{
           return done('incorrect password');
    }

    Факир был пьян, и запер дверь, забыв ее закрыть)

    Darth, 15 Декабря 2015

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var cloths = {
      <?php foreach ($clothList as $cloth): ?>
        "<?=$cloth->id()?>": {
          "id": <?=$cloth->id()?>,
          "name": "<?=$cloth->name()?>",
          "public_name": "<?=str_replace('"', '\"', $cloth->public_name())?>"
        },
      <?php endforeach; ?>
      "dummy": {}
    };

    kgm-rj, 14 Декабря 2015

    Комментарии (3)
  8. PHP / Говнокод #19171

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    if (!$subscription) {
        return $this->redirect(['action' => 'cancel_success']);
        throw new BadRequestException();
    }

    epadqwbd, 11 Декабря 2015

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

    0

    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
    $(window).load(function () {
    
        $(".sidebar-list").mCustomScrollbar({
          // scrollButtons:{enable:true,scrollType:"stepped"},
          keyboard: {
            scrollType: "stepped"
          },
          mouseWheel: {
            scrollAmount: 188
          }, // theme:"rounded-dark",
          scrollbarPosition: "inside",
          autoExpandScrollbar: false,
          snapAmount: 188,
          snapOffset: 65
        });
        if ("onhashchange" in window && location.hash) {
          match = location.hash.match(/^[?#!]*(.*)$/)[1];
          scrollToPage(match);
        };
    
        if (!isMob.any() && isRoot) {
          // return false;
          var navM = $('.menu a');
          var section = $.map($(".section"), function (e) {
            var $e = $(e);
            var pos = $e.position();
            return {
              top: pos.top - 75,
              bottom: pos.top - 75 + $e.height(),
              hash: '#!' + $e.attr('id'),
              indx: $e.index()
            };
          });
          //Checking scroll 
          var top = null;
          var changed = false;
          var currentHash = null;
    
          $(window).scroll(function () {
            var newTop = $(document).scrollTop();
            changed = newTop != top;
            if (changed) {
              top = newTop;
              // step();
            }
          });
          function step() {
            if (!changed) {
              return setTimeout(step, 200);
            }
            var count = section.length;
            var p;
            while (p = section[--count]) {
              if (p.top >= top || p.bottom <= top) {
                continue;
              }
              if (currentHash == p.hash) {
                break;
              }
              var scrollTop = $(document).scrollTop();
              window.location.hash = currentHash = p.hash;
              $(document).scrollTop(scrollTop);
            }
            setTimeout(step, 200);
          }
          setTimeout(step, 200);
        }
      });

    Сей гениальный код должен управлять прокруткой и главным меню на сайте.

    moveax3, 10 Декабря 2015

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

    0

    1. 1
    2. 2
    3. 3
    if ((*entry_it)->flags & (kNoAntialiasRenderFlag == kNoAntialiasRenderFlag)) {
        ...
    }

    Fai, 02 Декабря 2015

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

    −94

    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
    ВыборкаПоПроектам = ВзаиморасчетыСКонтрагентами.ПолучитьЗаполженностьКонтрагентовНаДату(МассивОрганизаций, КонецДня(ДатаОтчета), Истина, Истина, Истина);
    	Если ВыборкаПоПроектам <> Неопределено Тогда
    		ТаблицаВзаиморасчетов = Новый ТаблицаЗначений;
    		ДополнитьТаблицуКолонками(ТаблицаВзаиморасчетов);
    		Пока ВыборкаПоПроектам.Следующий() Цикл  /// Проект
    			Если ВыборкаПоПроектам.СуммаОстаток <> 0 Тогда
    				ВыборкаПоКонтрагентам = ВыборкаПоПроектам.Выбрать(ОбходРезультатаЗапроса.ПоГруппировкам);
    				Пока ВыборкаПоКонтрагентам.Следующий() Цикл  /// Контрагент
    					
    					Если ВыборкаПоКонтрагентам.СуммаОстаток <> 0 Тогда
    						
    						ВыборкаПоПлательщикам = ВыборкаПоКонтрагентам.Выбрать(ОбходРезультатаЗапроса.ПоГруппировкам);
    						
    						Пока ВыборкаПоПлательщикам.Следующий() Цикл  // плательщик
    							
    							Если (ВыборкаПоПлательщикам.СуммаОстаток <> 0) Тогда
    								
    								ВыборкаПоДоговорам = ВыборкаПоПлательщикам.Выбрать(ОбходРезультатаЗапроса.ПоГруппировкам);
    								
    								Пока ВыборкаПоДоговорам.Следующий() Цикл   // договор
    									
    									Если ВыборкаПоДоговорам.СуммаОстаток <> 0 Тогда
    										
    										
    										ВыборкаПоДокументам = ВыборкаПоДоговорам.Выбрать();
    										Пока ВыборкаПоДокументам.Следующий() Цикл  // документ
    											
    											СтрокаВзаиморасчетов = ТаблицаВзаиморасчетов.Добавить();
    											ЗаполнитьЗначенияСвойств(СтрокаВзаиморасчетов, ВыборкаПоДокументам);

    А потом вот такая таблица помещается в СКД, на неё накладывается отбор... и даже по 1 контрагенту отчёт формируется минут 5. Научили дурака Богу молиться...

    levxxx, 30 Ноября 2015

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