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

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

    +55.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while (true)
      {
        m_CurrentDevice += delta;
    
        if (m_CurrentDevice < 0)
          m_CurrentDevice = devices[DEV_PLATE]-1;
    
        if (m_CurrentDevice > devices[DEV_PLATE]-1)
          m_CurrentDevice = 0;
    
        break;
      }

    Это конечно написано не специально - в результат целой кучи итераций и переделок. но результата это не отменяет

    TObject, 21 Сентября 2009

    Комментарии (6)
  3. ActionScript / Говнокод #1861

    −90.9

    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
    function getActiveRoot():int
    {
    	for(var c:int=0;c<i;c++) if(r_arr[c].isActive) return c;
    	return -1;
    }
    
    
    
    
    
    public function addEntry():void
    {
    	if(getActiveRoot()<0)
    	{
    		r_arr.push(new Roots(i,in_txt.text,""));
    		r_arr[i].addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
    		r_arr[i].addEventListener(MouseEvent.MOUSE_UP, upHandler);
    				
    		addChild(r_arr[i++]);
    	}
    	else
    	{
    	        r_arr[getActiveRoot()].w_arr.push(new Words(getActiveRoot(),r_arr[getActiveRoot()].wi,in_txt.text,""));
    		r_arr[getActiveRoot()].w_arr[r_arr[getActiveRoot()].wi].addEventListener(MouseEvent.MOUSE_DOWN, WdownHandler);
    		r_arr[getActiveRoot()].w_arr[r_arr[getActiveRoot()].wi].addEventListener(MouseEvent.MOUSE_UP, WupHandler);
    				
    		var ls:Shape=new Shape();
    		ls.graphics.lineStyle(1, 0xFF0000,0.2);
    		ls.graphics.moveTo(r_arr[getActiveRoot()].x,r_arr[getActiveRoot()].y);
    	        ls.graphics.lineTo(r_arr[getActiveRoot()].w_arr[r_arr[getActiveRoot()].wi].x,r_arr[getActiveRoot()].w_arr[r_arr[getActiveRoot()].wi].y);
    		addChildAt(ls,++wd);
    		addChildAt(r_arr[getActiveRoot()].w_arr[r_arr[getActiveRoot()].wi++],++wd);
    	}
    }

    Ой. А давайте проц погоняем! Чтоб не скучал. Отовсюду будем запускать getActiveRoot() чтобы узнать индекс! Ха-ха-ха..

    t8apb, 17 Сентября 2009

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

    +59.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void someMethod(const std::string& name,  std::autp_ptr<SomeClass> p);
    
    {
        ...
        std::auto_ptr<SomeClass> p(new SomeClass());
        someMethod(p->GetName(), p);
        ...
    }

    Самое забавное, что при определенных условиях оно может работать.

    Lexey, 17 Сентября 2009

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

    +52.3

    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
    void GAMEPLAYER::cCar::abandonCar(GAMEPLAYER::cPlayer* player){
    	for(unsigned int i=0;i<size();++i){
    		cBaseAnimManager * bam = get(i);
    		if(!bam->isCarRider())
    			continue;
    		cCarRider* rdr = (cCarRider*)bam;
    		if(rdr->gScript()==player->gScript()){
    			delete rdr;
    			storage.erase(i);
    			--i;
    		}
    	}
    }

    НЕ time-critical код из некоторой игры
    Наблюдаем:
    1) непониманием того, зачем нужно наследование
    2) плохо пахнущие имена переменных

    generalgda, 16 Сентября 2009

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

    +147.7

    1. 1
    $this->view->isAdmin = ($auth->getIdentity()->role_id == 1) ? true : false;

    Называется: "заработался".
    Написал и только потом дошло.

    oldfornit, 16 Сентября 2009

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

    +157.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    ....
    $str = str_replace(',', ' ', $this->searchString);
    $str = str_replace(';', ' ', $str);
    $str = str_replace('.', ' ', $str);
    $str = str_replace(':', ' ', $str);
    $str = str_replace('+', ' ', $str);
    $str = str_replace('-', ' ', $str);
    $str = str_replace('"', ' ', $str);
    $str = str_replace("'", ' ', $str);
    		
    $str = trim(preg_replace('!\s{2,}!', ' ', $str));
    .....

    вот что я наклал как-то

    paranoid, 11 Сентября 2009

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

    +154.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function get_($what)
    	{
    		global $parser;
    		$lang = $parser->lang;
    		$lang = $this->$lang;
    		return $lang[$what];
    	}

    random2, 09 Сентября 2009

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

    +166.8

    1. 1
    unset($keys[count($keys)-1][count($keys[count($keys)-1])-1]);

    stepushyn, 07 Сентября 2009

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

    +75.3

    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
    public static ru.project.subpackage.PersonDTO convertOshPersonDtoToPersonDto(OshPersonDTO person){
            ru.project.subpackage.PersonDTO dto = new ru.project.subpackage.PersonDTO();
            dto.setPersonid(person.getPersonid().longValue());
            dto.setNamelast(person.getNamelast());
            dto.setNamefirst            (person.getNamefirst            ());
            dto.setNamesec              (person.getNamesec              ());
            dto.setInitials             (person.getInitials             ());
            dto.setSex                  (convertSkVocValue(person.getSex()));
            dto.setReason               (person.getReason               ());
            dto.setWorkphone            (person.getWorkphone            ());
            dto.setWorkphonedigit       (person.getWorkphonedigit       ());
            dto.setLocalphone           (person.getLocalphone           ());
            dto.setLocalphonedigit      (person.getLocalphonedigit      ());
            dto.setHomephone            (person.getHomephone            ());
            dto.setHomephonedigit       (person.getHomephonedigit       ());
            dto.setMobilephone          (person.getMobilephone          ());
            dto.setMobilephonedigit     (person.getMobilephonedigit     ());
            dto.setFax                  (person.getFax                  ());
            dto.setFaxdigit             (person.getFaxdigit             ());
            dto.setPager                (person.getPager                ());
            dto.setEmail                (person.getEmail                ());
            dto.setWeb                  (person.getWeb                  ());
            dto.setNamelastdative       (person.getNamelastdative       ());
            dto.setNamefirstdative      (person.getNamefirstdative      ());
            dto.setNamesecdative        (person.getNamesecdative        ());
            dto.setNamelastaccusative   (person.getNamelastaccusative   ());
            dto.setNamefirstaccusative  (person.getNamefirstaccusative  ());
            dto.setNamesecaccusative    (person.getNamesecaccusative    ());
            dto.setNamelastgenitive     (person.getNamelastgenitive     ());
            dto.setNamefirstgenitive    (person.getNamefirstgenitive    ());
            dto.setNamesecgenitive      (person.getNamesecgenitive      ());
            dto.setNamelastinstrumental (person.getNamelastinstrumental ());
            dto.setNamefirstinstrumental(person.getNamefirstinstrumental());
            dto.setNamesecinstrumental  (person.getNamesecinstrumental  ());
            dto.setNamelastprepositional(person.getNamelastprepositional());
            dto.setNamefirstprepositional(person.getNamefirstprepositional());
            dto.setNamesecprepositional (person.getNamesecprepositional ());
            return dto;
        }

    И так далее еще несколько сотен строк. А главное переупаковка из одних объектов в другие и обратно бессмысленна, т.к. можно использовать исходные (они доступны в приложении)

    johnsoft, 07 Сентября 2009

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

    +127

    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
    /// <summary>
        ///  Retrieve currency rates from an external site to be sure they are up to date.
        /// In this case just checking the one currency (Australian Dollar) so no need to dynamically parse the site.
        /// </summary>
        /// <returns>currency rates or msg indicating an error</returns>
        private String getCurrencyRates()
        {
            string strURL = @"http://www.x-rates.com/d/JPY/table.html";
            HttpWebRequest txtRequest = (HttpWebRequest)WebRequest.Create(strURL);
    
            txtRequest.Method = "GET";
            txtRequest.ContentType = "application/x-www-form-urlencoded";
            string response;
            using (StreamReader streamReader = new StreamReader(txtRequest.GetResponse().GetResponseStream()))
            {
                response = streamReader.ReadToEnd();
                if (response.IndexOf("Australian Dollar") > 0)
                {
                    //parse the returned page for the two values of the currency rate based on the existing design
                    int ind_jpy = (response.IndexOf("/d/AUD/JPY/graph120.html") + 39);
                    int ind_aud = (response.IndexOf("/d/JPY/AUD/graph120.html") + 39);
                    String jpy_aud = response.Substring(ind_jpy, (response.IndexOf("</a>",ind_jpy) - ind_jpy) );
                    String aud_jpy = response.Substring(ind_aud, (response.IndexOf("</a>", ind_aud) - ind_aud));
                    Session["curr_rate"] = "set";
                    Session["JPY"] = jpy_aud;
                    Session["AUD"] = aud_jpy;
                    return aud_jpy + " / " + jpy_aud;
                }
                //else present msg to user that unable to obtain currency rates
            }
            return "";
        }

    Еще один кандидат

    OlgaWolga, 07 Сентября 2009

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