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

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    class Model_Task extends Model_Base {
        const STATUS_CHECK = 0;
        const STATUS_REWORK = 1;
        const STATUS_COMPLETED = 2;
        const STATUS_INVALID = 99999;
    ...

    Видимо чтобы всегда последним был в случае чего...

    invision70, 20 Июня 2013

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

    +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
    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
    void SillyThread::run()
    {
        forever
        {
            // ... a test ...
        }
    }
    
    void CrazyThread::run()
    {
        forever
        {
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
    
            if(qrand() % 2 == 0)
            {
                // ... a test ...
            }
        }
    }

    не совсем говно, но имена и структука прикололи. из кода стресс-теста PDF библиотеки poppler.

    Dummy00001, 19 Июня 2013

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function unix_timestamp_to_human ($timestamp = "", $format = 'D d M Y - H:i:s')
    {
        if (empty($timestamp) || ! is_numeric($timestamp)) $timestamp = time();
        return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
    }
    
    $unix_time = "1251208071";
    
    echo unix_timestamp_to_human($unix_time); //Return: Tue 25 Aug 2009 - 14:47:51

    Я всё правильно понял, код воняет?

    denis90, 15 Июня 2013

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

    +130

    1. 1
    throw new GnuPGException(String.Format("An error occurred while trying to execute command {0}.", command, exp));

    startrack, 11 Июня 2013

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

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    /**
         * @return the timeout from the URL, in milliseconds
         */
        private static long timeout(Properties props)

    Из драйвера JDBC PostgreSQL.

    Lavir_the_Whiolet, 11 Июня 2013

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

    +131

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    foreach (var oi in order.Items)
                        {
                            if (oi.Offer.Name == "BRNCoreDigTrial" || oi.Offer.Name == "BRNCoreDig1Pay" || oi.Offer.Name == "BRNDigUpgrade5pay" || oi.Offer.Name == "BRNDigUpgrade1Pay"
                                || oi.Offer.Name == "BRN04StdDIG1Pay" || oi.Offer.Name == "BRN04StdDIG3Pay" || oi.Offer.Name == "BRNCoreDig1PayOld" || oi.Offer.Name == "BRNCoreDigTrialOld"
                                || oi.Offer.Name == "BRN04DlxDIG1Pay" || oi.Offer.Name == "BRN04DlxDIG3Pay" || oi.Offer.Name == "BRN04UltDIG1Pay" || oi.Offer.Name == "BRN04UltDIG3Pay")
                            {
                                isDigital = true;
                                break;
                            }
                        }

    startrack, 10 Июня 2013

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

    +8

    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
    void Cluster::CloseConnection()
    {
        m_Connection->close();
        if (!m_Connection->IsOK())
            throw ConnectionError(m_Connection->LastError());
    }
    
    void ClusterGroup::RemoveCluster(int iIndex)
    {
        Cluster *pSubCluster = m_SubClusters->At[i];
        pSubCluster->CloseConnection();
        delete pSubCluster;
        m_SubClusters->SetAt(i, NULL);
    }

    И потекло...

    Lavir_the_Whiolet, 06 Июня 2013

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

    +118

    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
    <div class="is-element-border-top">
              <div class="is-element-border-right">
                <div class="is-element-border-bottom">
                  <div class="is-element-border-left">
                    <div class="is-element-corner-top-left">
                      <div class="is-element-corner-top-right">
                        <div class="is-element-corner-bottom-right">
                          <div class="is-element-corner-bottom-left">
                            <span class="curr_show ">
                              5 days                        </span>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

    Каскадная таблица стилей, ёпта.

    bot-minurast, 01 Июня 2013

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

    +69

    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
    public class Tree {
        
        ...
    
        public static int treeDepth;
    
        ...
    
        public static void runDepthTree(Node start, String method) {
    //        System.out.println("looking at " + start);
            ++treeDepth;
            Statement statement = buildStatement(start, method);
            try {
                statement.execute();
            }
            catch (Exception e) { 
                String msg = start + " ERROR at tree depth= " + treeDepth;
                
                System.out.println(); 
            }
            Node[] nodes = start.getChildren();
            if (nodes != null) {
                int count = start.getComponentCount();
                for (int i = 0; i<count; i++)  {
                    runDepthTree((Node)nodes[i], method); // recurse
                }
            }
            --treeDepth;
        }
    
        ...
    
    }

    Я бы не точно догадался

    myzone, 23 Мая 2013

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    
    ...
    
    if( preg_match( "#\.#is", $current_rating ) )
    {
    	list( $n1, $n2 ) = explode( ".", $current_rating );
    	$current_rating = floatval( $n1.".".substr( $n2, 0, 2 ) );
    }

    round?

    faiwer, 22 Мая 2013

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