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

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

    +154

    1. 1
    2. 2
    3. 3
    function isEmptyStr(val) {
        return val == null || val === "";
    }

    glprizes, 01 Августа 2012

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

    +154

    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
    function reNumberAreas(parent)
    {
     for (i=0;i<parent.childNodes.length;i++)
     {
      try
      {
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.id = cutNumber(parent.childNodes[0].firstChild.firstChild.firstChild.firstChild.id) + i;
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.id = parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.id + "_text";
       parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.src = parent.childNodes[i].firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.src.replace(/index=\d+/g,"index=" + i);
      }
      catch (e)
      {
      }
     }
    }

    Форматирование кода сохранено для придания драматичности.

    Areks, 30 Июля 2012

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    checkParent: function () {
                var p = this.el.parent().length > 0 ? this.el.parent()[0] : this.el.parent(),
                    tp = this.parent && this.parent.length > 0 ? this.parent[0] : this.parent;
    
                return p !== tp;
            }

    wtf?

    nur, 31 Мая 2012

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

    +154

    1. 1
    2. 2
    this.ie = (name=="ie" && this.v>=4)
    this.activeX = ( this.ie ) ? true : false;

    Кусочек шедевра
    https://github.com/miketaylr/Snort/blob/master/snort.yml

    kindofbear, 30 Апреля 2012

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $fld_insurance_estimate_sales = $proformadetail[0]['fld_insurance_estimate_sales'];
    $fld_insurance_estimate_cost = $proformadetail[0]['fld_insurance_estimate_cost'];
    $fld_oceanfright_sales = $proformadetail[0]['fld_oceanfright_sales'];
    $fld_oceanfright_cost = $proformadetail[0]['fld_oceanfright_cost'];
    $fld_adjustment_oceanfright_sales = $proformadetail[0]['fld_adjustment_oceanfright_sales'];
    $fld_adjustment_oceanfright_cost = $proformadetail[0]['fld_adjustment_oceanfright_cost'];

    Не, ну extract($proformadetail[0]) просто никак нельзя сделать :)

    miraage, 20 Апреля 2012

    Комментарии (33)
  7. JavaScript / Говнокод #9950

    +154

    1. 1
    2. 2
    3. 3
    escape = function(string) {
        return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
      };

    Ваше мнение?

    __proto__, 14 Апреля 2012

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

    +154

    1. 1
    $explodeSize = explode( '-', str_replace( "\x20", '', trim( $sizes[0] ) ) );

    Не, ну надо было додуматься еще и str_replace туда запихать)

    psycho-coder, 12 Апреля 2012

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

    +154

    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
    #include "stdafx.h"
    #include "expression.h"
    #include <vector>
    
    int _tmain(int argc, _TCHAR* argv[]) {
    //Инициализация
    	std::vector<expression> arrayOfExpressions;
    	std::string inputString;
    //Ввод количества выражений
    	printf( "Enter expressions count: " );
    	int countOfExpressions = 0;
    	scanf( "%d", &countOfExpressions );
    //Ввод самих выражений
    	for ( int i = 1; i <= countOfExpressions; i++ ) {
    		printf( "Enter expression: " );
    		scanf( "%s", inputString );
    		arrayOfExpressions.push_back( expression( inputString ) );
    	}
    //Подсчёт операторов
    	int total = 0;
    	for (int i = 0; i < arrayOfExpressions.size(); i++)
    		total += arrayOfExpressions.at(i).operatorsCount();
    	printf( "Total operators = %d", total );
    //Освобождение памяти
    	arrayOfExpressions.erase(arrayOfExpressions.begin(),arrayOfExpressions.end());
    	return 0;
    }

    Один из уже известных вам студентов написал вот это. Вроде получше.

    Fai, 11 Апреля 2012

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

    +154

    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
    #include <iostream>
    #include <stdio.h>
     
    void foo(const long) { std::cout << "long" << std::endl; }
     
    template<typename _type_>
    void omg()
    {
            short i = 0;
            foo(i);
    }
     
    void foo(const short) { std::cout << "short" << std::endl; }
     
    int main(int, char*[])
    {
      omg<int>();
     
      getchar();
      return 0;
    }

    код для гцц -> http://ideone.com/mifTV

    вопрос, что выдаст говностудия?

    связанно с тем, что говностудия не ищет независимые типы использованные в шаблоне на этапе определения. она их ищет только в точке конкретизации шаблона. гцц связывает независимые типы в шаблоне на этапе определения шаблона

    З.Ы. ответ на http://govnokod.ru/9885#comment134160

    Govnoeb, 09 Апреля 2012

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

    +154

    1. 1
    if (!empty($params[$fieldName.'_need_group']) ? true : false) $errors[$fieldName] = 2;

    Просто очень тщательная проверка, если true то true, а если false то false....

    nikll, 28 Марта 2012

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