- 1
isRegKeyRequired = distKey == null ? false : distKey.equals("yes") ? true : false;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−37.2
isRegKeyRequired = distKey == null ? false : distKey.equals("yes") ? true : false;
Уматный ХавнАкоД коллеги из Индии. Ну просто няйсь. Смотрится куда зло*буче чем желаемый вариант (isRegKeyRequired = "yes".equals(distKey));
+29.3
for ($i=0; $i < $this->acl_count; $i++)
{
$acl =& $this->acl[$i];
if (strcasecmp( $aco_section_value, $acl[0] ) == 0) {
if (strcasecmp( $aco_value, $acl[1] ) == 0) {
if (strcasecmp( $aro_section_value, $acl[2] ) == 0) {
if (strcasecmp( $aro_value, $acl[3] ) == 0) {
if ($axo_section_value && $acl[4]) {
if (strcasecmp( $axo_section_value, $acl[4] ) == 0) {
if (strcasecmp( $axo_value, $acl[5] ) == 0) {
$acl_result = @$acl[6] ? $acl[6] : 1;
break;
}
}
} else {
$acl_result = @$acl[6] ? $acl[6] : 1;
break;
}
}
}
}
}
}
из ядра Joomla
+28.9
$revutxt = ($result_good['description']!='') ? $result_good['description'] : '';
вот где безопасность! вот где проверка верных значений переменных!)
+42.9
extract($GLOBALS);
Анекдот в одну строчку
+6.1
do {
XLoop:
XNextEvent(dpy,&event);
switch(event.type) {
case ResizeRequest:
if (event.xresizerequest.window!=win_main)
goto XLoop;
resize_main:
xswa.event_mask&= ~ResizeRedirectMask;
XChangeWindowAttributes(dpy,win_main,CWEventMask, &xswa);
XSync(dpy,0); /* very important, otherwise we loop endlessly ! */
XResizeWindow(dpy, win_main,event.xresizerequest.width,event.xresizerequest.height);
XSync(dpy,0); /* very important, otherwise we loop endlessly ! */
xswa.event_mask|= ResizeRedirectMask;
XChangeWindowAttributes(dpy,win_main,CWEventMask, &xswa);
resize=1;
XSync(dpy,0); /* another one, just in case... */
goto redisplay;
case Expose:
if (event.xexpose.count|moving_button1|vmoving_button)
goto XLoop;
.....// и дальше такой же хрени типа нарисовать и goto XLoop; :)
Однако под X11 пишут и так:
+16.6
$temp69 = new dbQuery($sql69, $conn->connId) or die(mysql_error());
$i=""; while($i<=5) { $res69=$temp69->getArray(); $i++; }
$sql69="select * from dj_config";
$temp69= new dbQuery($sql69, $conn->connId) or die(mysql_error());
$i="";
while($i<=5){
$res69=$temp69->getArray();
$i++;
}
оригинал: http://blog.sjinks.org.ua/humour/76-programmers-russian-indian-chinese-canadian/
−11.9
void safecpy(char *str1, char *str2)
{
strncpy(str1, str2, strlen(str1));
str1[strlen[str1]] = 0;
}
...
void safecpy(char *str1, char *str2)
{
strncpy(str1, str2, sizeof(str1));
str1[sizeof(str1)] = 0;
}
Две примера функций \"безопасного\" копирования строк :-)
−58.5
//Вознашу хвалу тебе, о великий индуский бог программинга! Как ни странно, работает, но надо переписать на досуге.
$city_xml = $CityArray->GetXml("CityList");
foreach($city_xml as $tmp_array){
if(!is_string($tmp_array) && $tmp_array[0] != "" && $tmp_array[0] != "Success" ){
foreach($tmp_array as $second_array){
$ixml = new xml();
$ixml->Insert($second_array);
foreach($ixml as $country_array){
if(!is_string($country_array) && $country_array[0] != "" && $country_array[0] != "Success" ){
foreach($country_array as $rxml){
if(!is_string($rxml)){
foreach($rxml as $axml){
if(!is_string($axml) && $axml[0] && $axml[0] != "Position"){
foreach($axml as $bxml){
foreach($bxml as $cxml){
if(!is_string($cxml) && is_array($cxml) && $cxml["Name"]){
$cities[] = $cxml;
}
}
}
}
}
}
}
}
}
}
}
}
return $cities;
Парсинг xml
−62.7
if ( strchr ( $_POST["ship$i"], "+") || strchr($_POST["ship$i"], " ") || strchr($_POST["ship$i"], ",") || strchr($_POST["ship$i"], ".") || strchr($_POST["ship$i"], "-") || strchr($_POST["ship$i"], "_") || strchr($_POST["ship$i"], ";") || strchr($_POST["ship$i"], ":") ) {
message("You got owned by >>The_Revenge Anticheat Systems<<", "Anticheat");
}
if ( !strchr ( $_POST["ship$i"], "+") && !strchr($_POST["ship$i"], " ") && !strchr($_POST["ship$i"], ",") && !strchr($_POST["ship$i"], ".") && !strchr($_POST["ship$i"], "-") && !strchr($_POST["ship$i"], "_") && !strchr($_POST["ship$i"], ";") && !strchr($_POST["ship$i"], ":")) {
// код
}
Немец предложил такое решение для проверки, что в строке ship$i именно положительное целое число и ни что иное.
В другом месте попадается аналогичный момент, только там после каждого strchr для каждого спецсимвола идет 10 строк одного и того же кода с двумя запросами к БД и выдачей бана юзеру...
Проект XNova (ogame-like)
−32.7
public void updateAmountValues(List<TransactionResultItem> transactionResultItems) {
for (TransactionResultItem transaction : transactionResultItems) {
Account account = getAccountById(transaction.getAccountId());
if ((transaction.getMainTransaction()
&& ! transaction.getTransactionTypeId().equals(4)
&& ! transaction.getTransactionTypeId().equals(5)
&& ! transaction.getTransactionTypeId().equals(6))
||
(! transaction.getMainTransaction() &&
(transaction.getTransactionTypeId().equals(5) &&
((account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
transaction.getAmount() > 0)
|| (transaction.getAccountId().equals(getSalesTaxPayableAccountId()) && transaction.getAmount() > 0)
|| ((account.getAccountTypeId().equals(AccountType.EXPENSE_TYPE_ID) ||
account.getAccountTypeId().equals(AccountType.OTHER_EXPENSE_TYPE_ID)) && transaction.getAmount() < 0))
|| (transaction.getTransactionTypeId().equals(1) &&
(account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
transaction.getAmount() < 0)
|| (transaction.getTransactionTypeId().equals(2) &&
(account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
transaction.getAmount() > 0)
)) {
Double amount = transaction.getAmount();
transaction.setAmount(-amount);
}
}
}
Потрясающий по понятности код. Вызывался несколько раз в одном и том же методе.