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

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

    +78

    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
    /*
             * Для операций UPDATE идентификаторы объектов должны быть уникальными.
             */
            HashMap<Long,Boolean> filterUniqueChangeObjects = new HashMap<Long, Boolean>();
            for (RepositoryObject repositoryObject : resultRepositiry) {
    			if(repositoryObject.getOperationType()  == OperationType.UPDATE) {
    				if(filterUniqueChangeObjects.containsKey(repositoryObject.getObjectId())) {
    					log.warn("Объект с идентификатором уже присутствует в обработке UPDATE " + repositoryObject.getObjectId());
    				} else {
    					resultUniqueRepositiry.add(repositoryObject);
    					filterUniqueChangeObjects.put(repositoryObject.getObjectId(), true);
    				}
    			}
    		}

    al_open, 21 Октября 2011

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

    +80

    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
    public class Context {
        public int countSuccess;
        public int countFailed;
        // ....
        public void markSuccess() {
            countSuccess++;
            countFailed--;
        }
    
        public void markSuccessAll() {
            countSuccess += countFailed;
            countFailed = 0;
        }   
        // ....
    }

    Вот такая вот супер-абстракция. Пример клиентского кода:

    public void processRequest(Context ctx) {
    // ...
    ctx.countFailed = elems.size();
    for (String elem : elems) {
    boolean success = doSomething(elem);
    if (success) {
    ctx.markSuccess();
    }
    }
    }

    roman-kashitsyn, 12 Октября 2011

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $day = date("d"); 
    $month = date("m"); 
    $year = date("Y");
    $hour = date("H")+2;
    if($hour=='24'){$hour='0';}
    if($hour=='25'){$hour='1';}
    $minute = date("i");
    
    $data = ''.$day.'.'.$month.'.'.$year.', '.$hour.':'.$minute.'';

    Красота!

    OJA, 08 Октября 2011

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

    +176

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?php
    
    $login = 'XXXXX';
    $pass  = 'XXXXXXXX';
    
    if (@$_COOKIE['login'] != $login) {
        setcookie('login',$login,time()+60*60*24,'/');
    }
    if (@$_COOKIE['password'] != $pass) {
        setcookie('password',$pass,time()+60*60*24,'/');
    }

    Вот такая интересная проверка на авторизацию.

    airrussia, 06 Октября 2011

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

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    if ((properties.ListItem["LocationTaxID"].ToString() != string.Empty) || (properties.ListItem["LocationTaxID"] != null))
    {
    
    }

    Норвеги писаки-проверяки.

    jenik15, 05 Октября 2011

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

    +145

    1. 1
    2. 2
    Ошибка компиляции комментария:
    csrf verification error

    Первый раз на говнокоде выкладывают говнокод Страйкера.

    CPPGovno, 01 Октября 2011

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

    +169

    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
    /*
    =====================================================
     Данный код защищен авторскими правами
    =====================================================
     Файл: index.php
     -----------------------------------------------------
     Версия: 1
    -----------------------------------------------------
     Назначение: минимальные необходимые настройки
    =====================================================
    */
    
    if(!defined('SIGELENGINE')){die();}
    
    #[cache configuration flag]
    
    final class _config
    {
             private         $config         = array();
    
             function __construct()
             {
                     $this->set();
             }
    
             private function set()
             {
                     $this->config['db']['use_buffer']                       = 0;
                     $this->config['db']['show_errors']                      = 1;
                     $this->config['db']['host']                                     = "...";
                     $this->config['db']['port']                                     = "...";
                     $this->config['db']['name']                                     = "...";
                     $this->config['db']['user']                                     = "...";
                     $this->config['db']['pass']                                     = "...";
    
                     $this->config['mail']['mailbox']                        = array("...", "...", "...");
    
                     $this->config['defaults']['mod']                        = "controller";
                     $this->config['defaults']['skin']                       = "index";
                     $this->config['defaults']['debug']                      = 0;
    
                     #[dynamic configuration]
             }
    
             function get()
             {
                     return $this->config;
             }
    }

    com1, 27 Сентября 2011

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

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    XmlNodeList list = xdoc.GetElementsByTagName("Customer");
    for (int i = 0; i < list.Count; i++)
    {
    XmlElement cl = (XmlElement)xdoc.GetElementsByTagName("Customer")[i];

    Написано расовым индусом.
    http://www.c-sharpcorner.com/UploadFile/vimalkandasamy/Xml03032009055848AM/Xml.aspx - чисто индусский бложик. Там много подобного.

    koodeer, 26 Сентября 2011

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

    +164

    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
    <?php 
    include "dbconfig.php"; 
    $db = mysql_connect("$dbhost","$dbuser","$dbpass");
    mysql_select_db("$dbname",$db);
    
    
    $mysqlsite = mysql_query("SELECT * FROM site WHERE id='1'");
    $site = mysql_fetch_array($mysqlsite);
    
    $titlesite = $site['title'];
    $titlesite = iconv("CP1251", "UTF-8", "$titlesite");
    
    $descriptionsite = $site['description'];
    $descriptionsite = iconv("CP1251", "UTF-8", "$descriptionsite");
    
    $keywordssite = $site['keywords'];
    $keywordssite = iconv("CP1251", "UTF-8", "$keywordssite");
    
    
    $contsite = $site['cont'];
    $contsite = iconv("CP1251", "UTF-8", "$contsite");
    ?>

    "CMS" Хостинг провайдера ultrahost.com.ua D

    SaNcHeS, 24 Сентября 2011

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

    +103

    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
    ...
    var count: integer;
          summ: integer;
    begin
     try
      case count of
        1: summ:=StrToInt(EditBox1.Text);
        2: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text);
        3: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text);
        4: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text);
        5: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text);
        6: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text)+StrToInt(EditBox6.Text);
        7: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text)+StrToInt(EditBox6.Text)++StrToInt(EditBox7.Text);
        8: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text)+StrToInt(EditBox6.Text)++StrToInt(EditBox7.Text)++StrToInt(EditBox8.Text);
        9: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text)+StrToInt(EditBox6.Text)++StrToInt(EditBox7.Text)++StrToInt(EditBox8.Text)+StrToInt(EditBox9.Text);
        10: summ:=StrToInt(EditBox1.Text)+StrToInt(EditBox2.Text)+StrToInt(EditBox3.Text)+StrToInt(EditBox4.Text)+StrToInt(EditBox5.Text)+StrToInt(EditBox6.Text)++StrToInt(EditBox7.Text)++StrToInt(EditBox8.Text)+StrToInt(EditBox9.Text)+StrToInt(EditBox9.Text);
        0: summ:= 0;
      end;
     except
       ShowMessage('Error');
     end;
    end;

    Сегодня увидал у однокурсника в универе.
    Самый оптимальные метод подсчета суммы элементов EditBox, не правдали???

    alexprey, 20 Сентября 2011

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