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

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

    +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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    public float Ratio
    {
          get { return ratio; }
          set
          {
              float newValue = value;
    
              if (value < 0.002f)
              {
                  newValue = 0.002f;
              }
              else if (value > 0.983f)
              {
                  newValue = 0.983f;
              }
    
              if (ratio != newValue)
              {
                  ratio = value;
                  InvalidateMeasure();
              }
        }
    }

    Мой "любимый" телерик опять пишет говно. Хорошо, что я скачал исходники и теперь сам могу править баги, не дожидаясь реакции этих слоупоков, которые после отправки бага с гифом (!), воспроизводящими исходниками (!!) и, блядь, патчем (!!!) исправляли два месяца сраный NRE.
    Догадайтесь, что здесь не так. Про magic numbers уже молчу.

    kerman, 01 Августа 2016

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

    +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
    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
    $timeout(function(){
                    $rootScope.presentation_details = { 
                        "name" : $rootScope.presentationDetails.name,
                        "description" : $rootScope.presentationDetails.description,
                        "lastUpdatedView" : $rootScope.presentationDetails.lastUpdatedView,
                        "projectId" : $rootScope.presentationDetails.projectId,
                        "presentationId" : $rootScope.presentationDetails.presentationId,
                        "reimbursementRate" : $rootScope.presentationDetails.reimbursementRate,
                        "isTemplate" : $rootScope.presentationDetails.isTemplate,
                        "authorId" : $rootScope.presentationDetails.authorId,
                        "authorName" : $rootScope.presentationDetails.authorName,
                        "IsNewPresentation" : false,
                        "gDocsId" : $rootScope.presentationDetails.gDocsId,
                        "parameters" : {
                          "widgetURL" : $rootScope.presentationDetails.parameters.widgetURL,
                          "widgetIFrameUrl" : $rootScope.presentationDetails.parameters.widgetIFrameUrl,
                          "widgetTextareaContent": $rootScope.presentationDetails.parameters.widgetTextareaContent,
                          "widgetTotalEGinGasSaved" : $rootScope.presentationDetails.parameters.widgetTotalEGinGasSaved,
                          "widgetTotalEGinFewerVehicles" : $rootScope.presentationDetails.parameters.widgetTotalEGinFewerVehicles,
                          "widgetHowDoesSolarWorkStepFourDuration" : $rootScope.presentationDetails.parameters.widgetHowDoesSolarWorkStepFourDuration,
                          "widgetHowDoesSolarWorkOverallDuration" : $rootScope.presentationDetails.parameters.widgetHowDoesSolarWorkOverallDuration,
                          "widgetGraphWeather" : $rootScope.presentationDetails.parameters.widgetGraphWeather,
                          "wIdgetGraphTemperatureChartType" : $rootScope.presentationDetails.parameters.wIdgetGraphTemperatureChartType,
                          "widgetGraphTemperature" : $rootScope.presentationDetails.parameters.widgetGraphTemperature,                  
                          "widgetWeatherType" : $rootScope.presentationDetails.parameters.widgetWeatherType,
                          "transitionOut" : $rootScope.presentationDetails.parameters.transitionOut,
                          "transitionIn" : $rootScope.presentationDetails.parameters.transitionIn,
                          "parametersId" : $rootScope.presentationDetails.parameters.parametersId,
                          "subheaderFont" : {
                            "fontId" : $rootScope.presentationDetails.parameters.subheaderFont.fontId,
                            "size" : $rootScope.presentationDetails.parameters.subheaderFont.size,
                            "name" : $rootScope.presentationDetails.parameters.subheaderFont.name,
                            "color" : $rootScope.presentationDetails.parameters.subheaderFont.color,
                            "visible" : $rootScope.presentationDetails.parameters.subheaderFont.visible,
                            "label" : $rootScope.presentationDetails.parameters.subheaderFont.label,
                            "content" : $rootScope.presentationDetails.parameters.subheaderFont.content,
                          },
                          "normal2Font" : {
                            "fontId" : $rootScope.presentationDetails.parameters.normal2Font.fontId,
                            "size" : $rootScope.presentationDetails.parameters.normal2Font.size,
                            "name" : $rootScope.presentationDetails.parameters.normal2Font.name,
                            "color" : $rootScope.presentationDetails.parameters.normal2Font.color,
                            "visible" : $rootScope.presentationDetails.parameters.normal2Font.visible,
                            "label" : $rootScope.presentationDetails.parameters.normal2Font.label,
                          },
                          "backgroundImage" : $rootScope.presentationDetails.parameters.backgroundImage,
                          "backgroundImageVisible" : $rootScope.presentationDetails.parameters.backgroundImageVisible,
                          "backgroundImageLabel" : $rootScope.presentationDetails.parameters.backgroundImageLabel,
                          "backgroundColor" : $rootScope.presentationDetails.parameters.backgroundColor,
                          "backgroundColorVisible" : $rootScope.presentationDetails.parameters.backgroundColorVisible,
                          "backgroundColorLabel" : $rootScope.presentationDetails.parameters.backgroundColorLabel,
                          "widgetIndex" : $rootScope.presentationDetails.parameters.widgetIndex,
                          "rowPosition" : $rootScope.presentationDetails.parameters.rowPosition,
                          "colPosition" : $rootScope.presentationDetails.parameters.colPosition,
                          "rowCount" : $rootScope.presentationDetails.parameters.rowCount,
                          "colCount" : $rootScope.presentationDetails.parameters.colCount,
                          "duration" : $rootScope.presentationDetails.parameters.duration,
                          "startDate" : $rootScope.presentationDetails.parameters.startDate,
                          "endDate" : $rootScope.presentationDetails.parameters.endDate,
                        },
                    };
                }, 10);

    Заглянул в код текущего проекта... Зря тимлид не проводит кодревью... У кого есть идеи нахеряки?

    jenezis, 06 Августа 2014

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    typedef SmartPtr<CallRec> callptr;
    
    callptr *m_call;
    
    if (m_call && (*m_call) && (*m_call)->SomeMethod()) {
        // ...
    }

    GnuGK и смартпоинтеры.

    bormand, 06 Июня 2014

    Комментарии (75)
  5. Си / Говнокод #15510

    +143

    1. 1
    strlen(s + 5);

    "А чего это оно на 10 символов меньше чем надо возвращает?"

    bormand, 18 Марта 2014

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if mas[i-1,j-1]=true then begin neib[m]:=true; inc(m); end; //считаем соседей
    if mas[i-1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i-1,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j+1]=true then begin neib[m]:=true; inc(m); end;

    Знакомый человек реализовывал «Жизнь» на делфях...

    POPSuL, 15 Января 2014

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

    +23

    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
    //VS 2010 C++
    #include <Windows.h>
    #include <time.h>
    #include <queue>
    #pragma comment(lib, "winmm.lib")
    char shapeForms[7][4][5][6] = {{{{0,0,0,0,0},{0,0,1,0,0},{0,0,1,0,0},{0,0,1,0,0},{0,0,1,0,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0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0,0,0},{0,0,1,0,0},{0,0,1,0,0},{0,0,1,1,0}}},{{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,1,1},{0,0,1,1,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,1,0,0},{0,0,1,1,0},{0,0,0,1,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,1,1},{0,0,1,1,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,1,0,0},{0,0,1,1,0},{0,0,0,1,0}}},{{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,1,1,1},{0,0,0,0,1}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,1,1,0},{0,0,1,0,0},{0,0,1,0,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,1,0,0,0},{0,1,1,1,0}},{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,1,0},{0,0,0,1,0},{0,0,1,1,0}}}}, field[32][28] = {0}, shape[5], shape_r[5], modifiers[4][3] = {{0,-1,0},{0,1,0},{1,0,0},{0,0,64}}, keys[4] = {'A', 'D', 'W', 'S'}, keyPressed = -1, lk = 0; //shape - 1: shape state; 2: shape type; 3: y; 4: x;
    std::queue<std::pair<COORD, std::pair<char, char>>> paste;
    COORD t;
    unsigned int Score(0);
    void draw(COORD cd, char c) {if((cd.Y = cd.Y - 4)||true) if(cd.Y >= 0) {SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cd);
    printf("%c", c);}}
    bool next_frame(bool mode, bool isShapeFell) {for(char y(0); y != 5; ++y) {for(char x(0); x != 6; ++x) {t.X = shape[4]+x; t.Y = shape[3]+y; 
    			if(shapeForms[shape[2]][shape[1]][y][x] == 1) {if(field[t.Y][t.X] == 0) paste.push(std::make_pair(t, std::make_pair(-37, 1)));
    				if(field[t.Y][t.X] == 2 || field[t.Y][t.X] == 3) isShapeFell = true;}else if(field[t.Y][t.X] == 1) paste.push(std::make_pair(t, std::make_pair(32, 0)));}}
    	if(isShapeFell) {while(paste.size()) paste.pop();
    		if(mode) for(char i(0); i != 31; ++i) for(char j(0); j != 25; ++j) if(field[i][j] == 1) field[i][j] = 3;
    		return false;}else {for(paste; paste.size() != 0; paste.pop()) {draw(paste.front().first, paste.front().second.first);
    			field[paste.front().first.Y][paste.front().first.X] = paste.front().second.second;}}
    	return true;}
    bool clearFullLines() {for(char isLineExist(1); isLineExist == 1;) {isLineExist = 0;
    		for(char j(0), up(0), down(0), cnt(0); j != 31; (++j) && (cnt = 0)) {for(char i(3); i != 25; ++i) if(field[j][i] == 3) if(j < 5) return false; else cnt++;
    			if(cnt == 22) {if(isLineExist == 0 && (isLineExist = 1) && (down = j)) up = j;
    			else down = j;}else if(isLineExist == 1 && (Score = Score + down-up+1)) {for(char q = down, tmp(0); q >= char(4); (--q)) for(char p(3); p != 25; (++p) && (tmp = 0)) {for(t.X = p, t.Y = q; tmp == 0; tmp = 1);
    					field[q][p] = 0; draw(t, 32);
    					if(field[up+q-down-1][p] == 3) draw(t, -37);
    					t.Y = up+q-down-1;
    					field[q][p] = field[up+q-down-1][p];
    					field[up+q-down-1][p] = 0;}
    				goto next_search;}}
    	next_search:;}
    	return true;}
    int main() {timeBeginPeriod(2);
    	system("mode con cols=42 lines=28");
    	srand(clock()+time(NULL));
    	memset(field, 2, sizeof(field));
    	for(char i(0); i != 28; ++i) for(char j(0), q(0); j != 32; ++j && (q = 0)) for(t.X = i, t.Y = j; q == 0; q = 1) draw(t, -80);
    	for(char i(3); i != 25; ++i) for(char j(0), q(0); j != 30; ++j && (q = 0)) for(t.X = i, t.Y = j; q == 0; (q = 1) && (field[j][i] = 0)) draw(t, 32);
    	for(int tm = 100;true;) {next_turn: if(!clearFullLines() && printf("You fail!")) {system("pause");
    			return 0;}
    		for(t.X = 30, t.Y = 5; false;);  
    		SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), t);
    		printf("Score: %i ", Score);
    		shape[1] = rand()*4/(RAND_MAX+1); shape[2] = rand()*7/(RAND_MAX+1); shape[4] = rand()*20/(RAND_MAX+1)+3;
    		for(shape[3] = 0; true; shape[3]++) {for(char h(0); h != 5; ++h) {Sleep(tm); tm = 70;
    				for(char i(0); i != 4 && keyPressed == -1; ++i) if(GetKeyState(keys[i]) < 0) keyPressed = i;
    				if(keyPressed != -1 && !(lk == keyPressed && lk == 2)) {for(char j(0); j != 5; ++j) shape_r[j] = shape[j];
    					shape[4] += modifiers[keyPressed][1]; shape[1] = (shape[1] + modifiers[keyPressed][0])%4;
    					tm -= modifiers[keyPressed][2];
    					lk = keyPressed;
    					keyPressed = -1; 
    					if(!next_frame(false, false)) {for(char j(0); j != 5; ++j) shape[j] = shape_r[j];
    						if(!next_frame(true, false)) goto next_turn;}}else {if(!next_frame(true, false)) goto next_turn;
    					if(keyPressed == -1) lk = -1;
    					if(lk != 2) lk = 0;else keyPressed = -1;}}}}}

    Была задача за минимальное кол-во строк реализовать простой тетрис. Особого внимания заслуживает 6 строчка кода. Всё очень плохо?
    Управление WSAD.

    o0oflashero0o, 26 Декабря 2013

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

    +27

    1. 1
    cout<<!0&&0;

    Что вернет?
    1) 1||0&&0
    2) !0&&0
    3) Приоритет оператора "!" ?
    http://ideone.com/hHdZ1
    http://ideone.com/s8Cj0


    Сории за толстейший троллинг.

    LispGovno, 17 Октября 2012

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach(string s in File.ReadAllText(input_text).Replace('ё', 'е').ToLower().Split(new char[] { ',', ' ', '.', '\t', '\r', '\n', '-', '?', '!', '\\', '/', ':', ';', '<', '>', '\'', '\"', '(', ')' }, StringSplitOptions.RemoveEmptyEntries).
    AsParallel().Where<string>(s => (s.Length == 4)).GroupBy(x => x).Select(g => new { Value = g.Key, Count = g.Count() }). OrderByDescending(x => x.Count).Select(f => (f.Value + ' ' + f.Count.ToString())).ToArray())
    {
           Console.WriteLine(s);
    }

    Найдено в коде одного из участников олимпиады сосницких
    Я понимаю, LINQ - это круто, но зачем так издеваться над проверяющим?

    kasthack, 22 Января 2012

    Комментарии (75)
  10. Python / Говнокод #8627

    −88

    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
    # класс ЧегоТоТамПарсер(object):
    
        def _get_images(self, soup, basedomain):
            soup = soup.get_soup()
            fb_images = soup.findAll(name="meta", attrs={
                "property": lambda property: property and property.lower() == "og:image"})
            images = (soup.body or soup).findAll(name="img", src=True)
            get_source = lambda img: img.get("content") \
                                        if img.get("content", None) \
                                        else img.get("src") \
                                        if img.get("src").startswith("http://") \
                                        else "http://"+img.get("src").lstrip("/") \
                                        if img.get("src").startswith("//") \
                                        else urljoin("http://"+basedomain, img.get("src").lstrip("/"))
            return list(set(map(get_source, fb_images + images)))
    
        def get_images(self):
            try:
                if self.basedomain:
                    return self._get_images(self.soup, self.basedomain)
                return []
            except URLError:
                return []

    над этим работало коллективное бессознательное

    nelson, 23 Ноября 2011

    Комментарии (75)
  11. Pascal / Говнокод #8602

    +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
    function det5(var a:atab):double;
    {FUNKCIYA VYCHISLYAET OPREDELITEL MATRITSY 5-go PORYADKA a}
    begin
    det5:=
    +a[1,1]*a[2,2]*a[3,3]*a[4,4]*a[5,5]-a[1,2]*a[2,1]*a[3,3]*a[4,4]*a[5,5]
    +a[1,3]*a[2,1]*a[3,2]*a[4,4]*a[5,5]-a[1,1]*a[2,3]*a[3,2]*a[4,4]*a[5,5]
    -a[1,3]*a[2,2]*a[3,1]*a[4,4]*a[5,5]+a[1,2]*a[2,3]*a[3,1]*a[4,4]*a[5,5]
    -a[1,4]*a[2,1]*a[3,2]*a[4,3]*a[5,5]+a[1,1]*a[2,4]*a[3,2]*a[4,3]*a[5,5]
    -a[1,1]*a[2,2]*a[3,4]*a[4,3]*a[5,5]+a[1,4]*a[2,2]*a[3,1]*a[4,3]*a[5,5]
    -a[1,2]*a[2,4]*a[3,1]*a[4,3]*a[5,5]+a[1,2]*a[2,1]*a[3,4]*a[4,3]*a[5,5]
    -a[1,4]*a[2,3]*a[3,1]*a[4,2]*a[5,5]+a[1,3]*a[2,4]*a[3,1]*a[4,2]*a[5,5]
    .............................................
    end;

    http://bbi-math.narod.ru/rosenbrock/rosenbrock.html

    dotnetdeveloper, 22 Ноября 2011

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