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

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

    +63

    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
    public class ExtendFSDirectoryProvider {
        // skipped
        @Override
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            }
            if (obj == null || !(obj instanceof FSDirectoryProvider)) {
                return false;
            }
    
            return indexName.equals(((ExtendFSDirectoryProvider) obj).indexName);
        }
    }

    Даже неважно, что автор делает лишнюю проверку на null - в instanceof указан другой класс! Копипаста детектед.

    victor-homyakov, 17 Апреля 2012

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

    +155

    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
    int main() {
        
        float a = 3.14;
        
        asm volatile (
                        "decl   %%esp"                      "\n\t"
                        "movb   $0, (%%esp)"                "\n\t"
                        "decl   %%esp"                      "\n\t"
                        "movb   $'\n', (%%esp)"             "\n\t"
                        "movl   $32, %%eax"                 "\n"
            "label0:"                                       "\n\t"
                        "shrl   %[A]"                       "\n\t"
                        "decl   %%esp"                      "\n\t"
                        "jc     label1"                     "\n\t"
                        "movb   $'0', (%%esp)"              "\n\t"
                        "jmp    label2"                     "\n"
            "label1:"                                       "\n\t"
                        "movb   $'1', (%%esp)"              "\n\t"
            "label2:"                                       "\n\t"
                        "decl   %%eax"                      "\n\t"
                        "cmpl   $0, %%eax"                  "\n\t"
                        "ja     label0"                     "\n\t"
                                                            "\n\t"
                        "pushl  %%esp"                      "\n\t"
                        "call   printf"                     "\n\t"
                                                            "\n\t"
                        "addl   $38, %%esp"                 "\n"
            
            : /* no output registers */
            : [A] "r" (a)
            : "%esp", "%eax"
        );
        
        return 0;
    }

    float > bin

    igoreknog, 16 Апреля 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (!$_GET['nocache']) {
      $use_caching=0; // use cache?
     } else {
      $use_caching=0;
     }

    ReckO, 14 Апреля 2012

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    for(int i = 0; i < fCount; i++)
    {
           result += Integer.parseInt(String.valueOf((fPart.charAt(i))), 10)*Math.pow(base, fCount-(i+1));	    			
    }

    brainy, 14 Апреля 2012

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

    −118

    1. 1
    2. 2
    3. 3
    4. 4
    - (int) getRandomValue {
        int rnd = 1000;
        return rnd;
    }

    И это было уже в предрелизе..

    mazder, 09 Апреля 2012

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

    +150

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    (получаем каждый $array из $all_arr){
    for ($i=0; $i<=7; $i++){
    switch("value".$i){
    case "value0":
    echo $array['value0'];
    break;
    case "value5":
    echo $array['value5'];
    break;
    }
    }
    }

    Имеем массив $all_arr, где каждый элемент имеет значение:
    $array = array(
    "value0" => "sometext0",
    "value1" => "sometext1",
    "value2" => "sometext2",
    "value3" => "sometext3",
    "value4" => "sometext4",
    "value5" => "sometext5"
    );
    Необходимо, вывести заданные значения из каждого элемента $all_arr.

    Спустя пару недель, пересматривая код, сократил.

    truedizzy, 09 Апреля 2012

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

    +83

    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
    /**
     * intended to be used for enums implementation
     */
    public interface NullValueHolder<T> {
        T getNullValue();
    }
    
    
    // в тесте
    enum TestEnum implements NullValueHolder<TestEnum> {
    TEST;
        public TestEnum getNullValue() {
            return null;
        }
    }

    Видимо, часть метафабрики для создания метапрограмм
    Может, я чего-то в этой жизни не понимаю?

    roman-kashitsyn, 06 Апреля 2012

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

    +116

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    protected void chxPeriodCostDeviationGreater_CheckedChanged(object sender, EventArgs e)
            {
                foreach (Pair lstPair in lstPairs)
                {
                    if (lstPair.First.Equals(sender))
                    {
                        (lstPair.Second as TextBox).Enabled = (lstPair.First as CheckBox).Checked;
                        return;
                    }
                }
            }

    задаем видимость контролов :)

    _vinka, 05 Апреля 2012

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

    +163

    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
    <!--/** Блог Алексея отключен
    
    
    <div class="rightadd"><a rel="dofollow" href="/blog_alex.html"><h3>Блог Алексея Сафиоллина</h3></a>
     <div class="txt">
    <?
            	foreach ($a_news_1 as $key => $val) {        	
            	?>
            	<div class="item">
    			<table width="100%" cellpadding="0" cellspacing="0" border="0">
    			<tr>
    				<td style="vertical-align:top;width:70px">
    				<div class="pic"><a rel="nofollow" href="<?=$val['url']?>"><img src="<?=$val['photo_70']?>" width="70" height="70" alt="" /></a></div>
    				</td>
    				<td style="vertical-align:top;">
                <a rel="nofollow" href="<?=$val['url']?>"><?=$val['cap']?></a> <?=util::getDotWord($val['s_body'], 110)?>       
    				</td>
    			</tr>
    			</table>   
    			</div>
                <?}?>
                  </div>
                </div> 
     */-->

    Отключили блог...
    P.S. И вот такое, люди называют "системой".

    nethak, 02 Апреля 2012

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

    +156

    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
    <?php if(isset($_GET["fullVersion"])) $_SESSION["fullVersion"]="on"; ?><?php if($_SESSION["fullVersion"]!='on' && (substr_count($_SERVER["HTTP_USER_AGENT"],'Android') || substr_count($_SERVER["HTTP_USER_AGENT"],'iPhone'))){
         header("Location: /m/redirects/?withjs");
         exit;
      }
      else if($_SESSION["fullVersion"]!='on' && substr_count($_SERVER["HTTP_USER_AGENT"],'Opera Mini')){
         header("Location: /m/redirects/?operamini");
         exit;
      }
      ?><?php if($_GET["ClockId"] && $_GET["str"] && $_GET["frompartnerka"]==1){ header("Location: http://vip-timeclub.ru/catalog/articul/?ClockId=".(int)$_GET["ClockId"]."&str=2");} ?>
    
    <?php if(function_exists('vtPrice')==false){
        function vtPrice($price=0,$sale=0,$priceGold=0){
          if($priceGold){
            $priceOld = $price;
            $price = $priceGold;
          }
          else if($sale){
            $priceOld = $price;
            $price = ceil(intval($priceOld)-((intval($priceOld)/100)*(intval($sale))));
          }
          else{
            $priceOld = 0;
          }
          return array('price'=>$price,'priceOld'=>$priceOld);
        }
      }if(function_exists('vtPriceGood')==false){
       function vtPriceGood($price){
          if(intval(substr($price,-1)) > 0 && intval(substr($price,-1)) < 5) 
                $price = intval($price) + (5-intval(substr($price,-1))); 
          else if(intval(substr($price,-1)) > 5 && intval(substr($price,-1)) <= 9) 
                $price = intval($price) + (10-intval(substr($price,-1)));
          return $price;
        }
      } ?>

    spam, club-viptime DOT RU

    111111, 01 Апреля 2012

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