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

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static bool ProductGT10(Point p)
        {
            if (p.X * p.Y > 100000)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    Классический пример из MSDN
    http://msdn.microsoft.com/ru-ru/library/bfcke1bz.aspx

    kegdan, 10 Июля 2013

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

    +121

    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
    public int sum(final Type type, final int increment) {
    	switch(type) {
    	case REDOS: 
    		return redos += increment;
    	case ONCE: 
    		return onceRedoneOrders += increment;
    	case TWICE: 
    		return twiceRedoneOrders += increment;
    	case THRICE: 
    		return thriceRedoneOrders += increment;
    	case MORE: 
    		return moreRedoneOrders += increment;
    	default:
    		break;
    	}
    	
    	throw new RuntimeException();
    }

    Осталось в наследство. Даже не знаю, что хотел изобразить предыдущий оратор...

    someone, 06 Июня 2013

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public class DefaultQueryEngine implements QueryEngine {
    
        private static volatile QueryEngine DEFAULT;
        
        public static QueryEngine getDefault() {
            if (DEFAULT == null) {
                DEFAULT = new DefaultQueryEngine(new DefaultEvaluatorFactory(CollQueryTemplates.DEFAULT));
            }
            return DEFAULT;
        }

    https://github.com/mysema/querydsl/blob/master/querydsl-collections/src/main/java/com/mysema/query/collections/DefaultQueryEngine.java

    Ехал дефолт через дефолт...

    someone, 15 Февраля 2013

    Комментарии (9)
  5. Куча / Говнокод #12439

    +121

    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
    #Creates an array with the frequencies from C2 to C5, 37 notes in all
    for j from 1 to 37
    	if j = 1 
    	notes [j] = 65.41 # лёгкие пути не нужны
    	endif
    	if j = 2
    	notes [j] = 69.30
    	endif
    # ...дальше понятно...
    endfor
    
    # <...>
    
    #Determining whether or not the scale contains C
    #This determines how many notes of the 37 possible must be included.
    noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
    noCList [2] = 5
    noCList [3] = 7
    noCList [4] = 10
    noCList [5] = 12
    noC = 0
    for n from 1 to 5
    	if 'starter' = noCList['n']
    		noC = 1
    	endif
    endfor
    #If there is a C...
    if noC = 0
    #The for loop mathematically selects the scale notes to use
    for m from 1 to 22
    	if 'm' = 1
    		noteind = 'starter'
    	endif
    	if 'm' = 2
    		noteind = 'starter' + 2
    		if 'noteind' > 37
    			noteind = 'noteind' - 36
    		endif
    	endif
    # ...ага-ага...
    	scalenotes ['m'] = notes['noteind']
    endfor
    #If there is not a C...
    else
    for m from 1 to 21
    	if 'm' = 1
    		noteind = 'starter'
    	endif
    	if 'm' = 2
    		noteind = 'starter' + 2
    		if 'noteind' > 37
    			noteind = 'noteind' - 36
    		endif
    	endif
    # ...так точно...
    	scalenotes ['m'] = notes['noteind']
    endfor
    endif
    
    # <...>
    
    #Add new pitch information
    #For each point, we move the freq to the closest scale note
    for q from 1 to 'numPoints'
    	#The original freq of pitch
    	currentfreq = pitches['q']
    	#A starting threhold for difference between original and a musical note
    	diff = 50
    	#If there is C in the scale, making 22 possible notes to tune to...
    	if 'noC' = 0
    	#For loop finds the lowest difference between original pitch and a musical note
    	for c from 1 to 22
    		diff2 = abs('currentfreq' - scalenotes['c'])
    		if 'diff2' < 'diff'
    			diff = 'diff2'
    			noteindex = 'c'
    		endif
    	endfor
    	#Otherwise if there is not a C...
    	else
    	for c from 1 to 21
    		diff2 = abs('currentfreq' - scalenotes['c'])
    		if 'diff2' < 'diff'
    			diff = 'diff2'
    			noteindex = 'c'
    		endif
    	endfor
    	endif
    	#Add point at the original time with the new pitch
    	Add point... times['q'] scalenotes['noteindex']
    endfor

    http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
    Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.

    telnet, 17 Января 2013

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

    +121

    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
    This awesome yet simple and pragmatic PHP library performs an addition of two numbers.
    
    In early stages of Internet, developers were forced to work with poor, dry, functional, horrific languages. Everything had to be done through austere functions and operators. There was no objects. No interfaces. No dependency injection.
    
    For example, to make something as simple as an addition, our dads had to write: 1+1. Yeah, really.
    
    Hopefuly now, we have PHP 5.3 and its solid OOP implementation. SimplePHPEasyPlus lets you make this addition in a more fashionable way, using real OOP. It is fast, simple, flexible and tested. To add 1 to 1, all you have to do is:
    
    use SimplePHPEasyPlus\Number\NumberCollection;
    use SimplePHPEasyPlus\Number\SimpleNumber;
    use SimplePHPEasyPlus\Number\CollectionItemNumberProxy;
    use SimplePHPEasyPlus\Parser\SimpleNumberStringParser;
    use SimplePHPEasyPlus\Iterator\CallbackIterator;
    use SimplePHPEasyPlus\Operator\AdditionOperator;
    use SimplePHPEasyPlus\Operation\ArithmeticOperation;
    use SimplePHPEasyPlus\Operation\OperationStream;
    use SimplePHPEasyPlus\Engine;
    use SimplePHPEasyPlus\Calcul\Calcul;
    use SimplePHPEasyPlus\Calcul\CalculRunner;
    
    
    $numberCollection = new NumberCollection();
    
    $numberParser = new SimpleNumberStringParser();
    
    $firstParsedNumber = $numberParser->parse('1');
    $firstNumber = new SimpleNumber($firstParsedNumber);
    $firstNumberProxy = new CollectionItemNumberProxy($firstNumber);
    
    $numberCollection->add($firstNumberProxy);
    
    $secondParsedNumber = $numberParser->parse('1');
    $secondNumber = new SimpleNumber($secondParsedNumber);
    $secondNumberProxy = new CollectionItemNumberProxy($secondNumber);
    
    $numberCollection->add($secondNumberProxy);
    
    $addition = new AdditionOperator('SimplePHPEasyPlus\Number\SimpleNumber');
    
    $operation = new ArithmeticOperation($addition);
    
    $engine = new Engine($operation);
    
    $calcul = new Calcul($engine, $numberCollection);
    
    $runner = new CalculRunner();
    
    $runner->run($calcul);
    
    $result = $calcul->getResult();
    $numericResult = $result->getValue(); // 2
    This library is now available for production purposes. Enjoy!

    [КО]Складывает 2 числа[/КО]

    Vasiliy, 01 Декабря 2012

    Комментарии (8)
  7. Куча / Говнокод #12113

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Поздравляю, дамы и господа, крупнейшая электронная библиотека русских книг lib.rus.ec попала в России под запрет.
    
        Искомый ip адрес внесен в реестр
        Дата основания для внесения в реестр 05.11.2012
        Номер основания для внесения в реестр 2/2/16482
        Орган, принявший решение о внесении в реестр ФСКН
        Дата внесения в реестр 11.11.2012

    zapret-gov.ru

    Fatal error: Cannot redeclare get_web_page() (previously declared in /home/u749066976/public_html/parser.php:7) in /home/u749066976/public_html/parser.php on line 35

    bot, 13 Ноября 2012

    Комментарии (32)
  8. Куча / Говнокод #11700

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    ignore(MainForm.g.Items.Add
    			(
    				if(! $['A'..'Z'].Concat($['а'..'я']).Concat($['А'..'Я']).Concat($['a'..'z']).Contains(tok[0])) $"#$code" else tok
    			));

    LispGovno, 04 Сентября 2012

    Комментарии (35)
  9. Java / Говнокод #11682

    +121

    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
    try {
    	repository.saveAll(entities);
    } catch (final ConstraintViolationException e) {
    	throw new SettingsServiceException(ErrorFormatter.formatValidationErrors(
    			"Errors have been detected when saving", e));
    } catch (final PersistenceException e) {
    	for (val t: Throwables.getCausalChain(e)) {
    		if (t instanceof EntityExistsException) {
    			val failedObject = (IEntity) ((ExceptionInfo) t).getFailedObject();
    			
    			// failedObject is returned with the state in which it is in the database.
    			// Let's find the version that we tried to save, instead.
    			for (val entity: entities) {
    				if (entity.getId() != null && entity.getId().equals(failedObject.getId())) {
    					throw new SettingsServiceException("Attempted to save duplicate value: " + entity);
    				}
    			}
    		}
    	}
    	
    	throw e;
    }

    Попытка вернуть пользователю человеко-читаемое сообщение о том, где, собственно, дубликат.

    Костыли вы мои, костыли...

    someone, 31 Августа 2012

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

    +121

    1. 1
    2. 2
    (set 'b (read))
    (eval b)

    http://ideone.com/3ImB9

    LispGovno, 28 Августа 2012

    Комментарии (92)
  11. Куча / Говнокод #11423

    +121

    1. 1
    (reverse (butlast ...))

    Родное :)

    wvxvw, 16 Июля 2012

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