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

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

    −2

    1. 1
    Пидарашки, приведите реальный пример говнокода.

    Antifriz_otrabotanyi, 05 Декабря 2019

    Комментарии (88)
  3. Go / Говнокод #25839

    −2

    1. 1
    TOCTOU race condition in Docker allows root access to the filesystem of the host platform.[4]

    6a6yuH, 15 Сентября 2019

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

    +2

    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
    <?
    global $DB,$APPLICATION,$USE,$USER_FIELD_MANAGER,$CACHE_MANAGER;
    /* @var $DB CDatabase */
    /* @var $GLOBALS['DB'] CDatabase */
    /* @var $GLOBALS["DB"] CDatabase */
    $DB = $GLOBALS['DB'] = $GLOBALS["DB"] = new CDatabase();
    /* @var $APPLICATION CMain */
    /* @var $GLOBALS['APPLICATION'] CMain */
    /* @var $GLOBALS["APPLICATION"] CMain */
    $APPLICATION = $GLOBALS['APPLICATION'] = $GLOBALS["APPLICATION"] = new CMain();
    /* @var $USER CUser */
    /* @var $GLOBALS['USER'] CUser */
    /* @var $GLOBALS["USER"] CUser */
    $USER = $GLOBALS['USER'] = $GLOBALS["USER"] = new CUser();
    /* @var $USER_FIELD_MANAGER CUserTypeManager */
    /* @var $GLOBALS['USER_FIELD_MANAGER'] CUserTypeManager */
    /* @var $GLOBALS["USER_FIELD_MANAGER"] CUserTypeManager */
    $USER_FIELD_MANAGER = $GLOBALS['USER_FIELD_MANAGER'] = $GLOBALS["USER_FIELD_MANAGER"] = new CUserTypeManager;
    /* @var $CACHE_MANAGER CCacheManager */
    /* @var $GLOBALS['CACHE_MANAGER'] CCacheManager */
    /* @var $GLOBALS["CACHE_MANAGER"] CCacheManager */
    $CACHE_MANAGER = $GLOBALS['CACHE_MANAGER'] = $GLOBALS["CACHE_MANAGER"] = new CCacheManager;
    ?>

    Есть тут петухи, которые шарят в "PHP" ? Какие скобки лучше ординарные или двойные ?

    phpBidlokoder2, 23 Августа 2019

    Комментарии (88)
  5. JavaScript / Говнокод #25689

    +4

    1. 1
    this.checkArrayErrors() ? (this.canSend = true) : (this.canSend = false);

    Код разраба, который не прошел испытательный срок и сказал что к нему придираются.

    UnQu1et, 28 Июня 2019

    Комментарии (88)
  6. JavaScript / Говнокод #25653

    +1

    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
    <script>
            window["flags"] = {
            "purcTOFlag": "true" == "true" ? true : false,
            "ENBL_CANCEL_POLICY": "true" == "true" ? true : false,
            "ENBL_BACKUP_CHECK_OLD_DEVICES": "false" == "true" ? true : false,
            "ENBL_DIRECT_ACCESS_LINKS": "true" == "true" ? true : false,
            "ENBL_NEW_ABG_URL": "true" == "true" ? true : false,
            "cr_9839666": "true" == "true" ? true : false,
            "cubaCRFlag": "true" == "true" ? true : false,
            "cubaMultiCityCRFlag": "true" == "true" ? true : false,
            "youthCRFlag": "true" == "true" ? true : false,
            "ENABLE_AFOP_MODE": "true" == "true" ? true : false,
            "SHARE_ITINERARY_ON_FACEBOOK": "false" == "true" ? true : false,
            "cr_11668201": "true" == "true" ? true : false,
            "hotelCRFlag": "true" == "true" ? true : false,
            "cr_adoshareitinerary": "false" == "true" ? true : false,
            "ROUNDOFF_AMOUNT_FOR_US_EDITION": "true" == "true" ? true : false,
            "hideSeatPromotionalBanner": "true" == "true" ? true : false,
            "enablePremiumRougeCR": "true" == "true" ? true : false,
            "availFareSplit": "true" == "true" ? true : false,
            "improvedMixedCabin": "true" == "true" ? true : false,
            "adoPassengerPrepopulate": "true" == "true" ? true : false,
            "adoIataInformation": "true" == "true" ? true : false,
            "premiumRougeSeatSelection": "true" == "true" ? true : false,
            "displayIntlTerminal": "true" == "true" ? true : false,
            "continueDisabledLightboxIsEnabled": "true" == "true" ? true : false,
            "createAeroplanFromConf": "true" == "true" ? true : false,
            "contOnAvailPage": "true" == "true" ? true : false,
            "alpiSpecialAssistanceCRFlag": "true" == "true" ? true : false,
            "removePaxTitle": "false" == "true" ? true : false,
            "perDiemInsurance": "true" == "true" ? true : false,
            "isVisaCheckoutEnabled": "true" == "true" ? true : false,
            "isCashRewardEnabled": "true" == "true" ? true : false,
            "masterPassCRFlag": "true" == "true" ? true : false,
            "masterPassAllowedEdition": "CA\-en:CA\-fr:CA\-zh",
            "youthphase2CRFlag": "true" == "true" ? true : false,
            "isCitylistPerfEnabled": "true" == "true" ? true : false,
            "isSingleTravelOptionEnabled": "false" == "true" ? true : false,
            "retainPaymentInformation": "true" == "true" ? true : false,
            "hotelChildAgeCR": "true" == "true" ? true : false,
            "displayGeoFirst": "true" == "true" ? true : false,
            "displayDiscAvail": "true" == "true" ? true : false,
            "premiumRougeUpsell": "true" == "true" ? true : false,
            "enableReplaceOpinionLabs": "true" == "true" ? true : false,
            "displayOalRef": "true" == "true" ? true : false,
            "newTravelOptionsLayoutFlag": "true" == "true" ? true : false,
            "hotelWidgetAPI": "true" == "true" ? true : false,
            "enableCombinedPhoneNo": "true" == "true" ? true : false,
            "hideTripSummaryForMobile": "true" == "true" ? true : false,
            "enableSecureAttribute": "true" == "true" ? true : false,
            "enhancedPreviewSeatMap": "true" == "true" ? true : false,
            "enhancedSeatMap": "true" == "true" ? true : false,
            "firstClassCabinCR": "true" == "true" ? true : false,
             .
             .
    }

    Taken from aircanada.com. Enjoy!

    devfromhell, 31 Мая 2019

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

    0

    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
    #include <iostream>
    
    int main()
    {
    setlocale(LC_ALL, "Russian");
    long long int num;
    long long int divider = 1;
    int max = 0;
    int min = 9;
    std::cout.unsetf(std::ostream::unitbuf);
    std::cout « "Введите число: ";
    std::cin » num;
    while(num>=divider)
    {
    if(num/divider%10>max) max = num/divider%10;
    if(num/divider%10<min) min = num/divider%10;
    divider = divider * 10;
    }
    std::cout « max « " - большая цифра" « '\n';
    std::cout « min « " - меньшая цифра";
    return 0;
    }

    BelCodeMonkey, 14 Января 2019

    Комментарии (88)
  8. bash / Говнокод #24074

    −3

    1. 1
    Бомбёж по поводу Wine и Mono

    Все говорят, что Wine не может с 1993 года запускать программы под винду. И всё почему? Потому что не могут господа вся опенсорса и линуксии нормально реимплементить программы с нешвабодки. Содержимое бутылки похоже на винду настолько отдалённо, как борманд на кегдана. И причём тут Mono? Притом, что в вайн засунули моно, который кривой как руки создателя 1C. И самое страшное, что ни вайн, ни моно никто не хочет сделать на 100% идентичным оригиналу. Ведь если они не будут похожи, то они просто становятся бесполезны.

    dm_fomenok, 04 Апреля 2018

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

    +1

    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
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    #include <experimental/coroutine>
    #include <iostream>
    #include <optional>
    #include <utility>
    
    template<typename T>
    class Maybe
    {
        std::shared_ptr<std::optional<T>> m_maybe = std::make_shared<std::optional<T>>();
    public:
        Maybe() = default;
        
        Maybe(const T& t)
        : m_maybe { std::make_shared<std::optional<T>>(t) }
        {
        }
    
        explicit operator bool() const { return static_cast<bool>(*m_maybe); }
        T& operator* () { return **m_maybe; }
        const T& operator*() const { return **m_maybe; }
        
        void reset() { m_maybe->reset(); }
        
        template<typename U>
        void emplace(U&& u) { m_maybe->emplace(std::forward<U>(u)); }
    };
    
    template<typename T>
    void printMaybe(const Maybe<T>& opt)
    {
        if (opt)
            std::cout << *opt << std::endl;
        else
            std::cout << "<empty>" << std::endl;
    }
    
    template<typename T, typename... Args>
    struct std::experimental::coroutine_traits<Maybe<T>, Args...>
    {
        struct promise_type
        {
            Maybe<T> m_maybe;
            
            auto get_return_object() { return m_maybe; }
            
            std::experimental::suspend_never initial_suspend() { return {}; }
            std::experimental::suspend_never final_suspend() { return {}; }
            
            void unhandled_exception() { m_maybe.reset(); }
            
            template<typename U>
            void return_value(U&& u) { m_maybe.emplace(std::forward<U>(u)); }
        };
    };
    
    template<typename T>
    auto operator co_await(const Maybe<T>& maybe)
    {
        struct Awaiter
        {
            const Maybe<T>& input;
    
            bool await_ready() { return static_cast<bool>(input); }
            auto await_resume() { return *input; }
            void await_suspend(std::experimental::coroutine_handle<> coro) { coro.destroy(); }
        };
    
        return Awaiter { maybe };
    }
    
    Maybe<int> maybeAdd(const Maybe<int>& maybeA, const Maybe<int>& maybeB)
    {
        auto a = co_await maybeA;
        auto b = co_await maybeB;
        co_return a + b;
    }
    
    int main()
    {
      /*
        printMaybe(maybeAdd({ 1 }, { 2 }));
        printMaybe(maybeAdd({}, { 2 }));
        printMaybe(maybeAdd({ 1 }, {}));
        */
        const auto res = maybeAdd({ 1 }, { 2 });
        return res ? *res : 0;
    }

    do-нотация в плюсах

    j123123, 07 Декабря 2017

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

    −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
    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
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    namespace raytracing
    {
        struct Scene::Implementation
        {
            std::vector<std::unique_ptr<RenderObject>> renderObjects;
            std::vector<Light> lights;
            Camera camera;
        };
    }
    
    Scene::Scene() :
        implementation{std::make_unique<Implementation>()}
    {
    }
    
    void Scene::insertObject(RenderObject* renderObject) noexcept
    {
        implementation->renderObjects.push_back(std::unique_ptr<RenderObject>{renderObject});
    }
    
    const RenderObject* Scene::getIntersectedObject(Ray ray, vec3f* intersectionPoint) const noexcept
    {
        const auto& renderObjects = implementation->renderObjects;
    
        if (renderObjects.empty())
            return nullptr;
    
        struct IntersectionData
        {
            const RenderObject* renderObject;
            float t;
            bool isIntersect;
            vec3f intersectionPoint;
        } temp{};
    
        for (decltype(implementation->renderObjects)::const_iterator iter = renderObjects.cbegin();
                iter != renderObjects.cend(); ++iter)
        {
            IntersectionData intersectionData;
    
            intersectionData.renderObject = (*iter).get();
            intersectionData.isIntersect = (*iter)->isIntersect(ray, intersectionData.t,
                    &intersectionData.intersectionPoint);
    
            if (intersectionData.isIntersect)
            {
                if (temp.isIntersect)
                {
                    if (temp.t > intersectionData.t)
                        temp   = intersectionData;
                }
                else
                    temp = intersectionData;
            }
        }
    
        if (intersectionPoint)
            *intersectionPoint = temp.intersectionPoint;
    
        return temp.renderObject;
    }
    
    namespace raytracing
    {
        struct Renderer::Implementation
        {
            vec3f trace(const Scene& scene, Ray ray) const noexcept
            {
                vec3f intersectionPoint;
                const RenderObject* const renderObject = scene.getIntersectedObject(ray, &intersectionPoint);
    
                vec3f color{};
    
                if (!renderObject)
                    return color;
    
                for (Light l : scene.getLights())
                {
                    const Ray lightRay{intersectionPoint, (l.position - intersectionPoint).normalize()};
    
                    float brightness = renderObject->getNormal(intersectionPoint).dot(lightRay.direction);
                    if (brightness < 0.0F)
                        brightness = 0.0F;
    
                    color += renderObject->getColor(intersectionPoint) * 255.0F * brightness;
                }
    
                return color;
            }
        }
    }

    Сумеете ли вы найти ошибку?

    jangolare, 18 Апреля 2016

    Комментарии (88)
  11. Куча / Говнокод #18015

    −288

    1. 1
    http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx

    Что за хрень? С каких пор \ в виндовой консоли эксейпит кавычки? Эскейпящий символ же ^?

    3_14dar, 17 Апреля 2015

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