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

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

    0

    1. 1
    https://pastebin.com/hC1Ux6kC

    По колено в коде... Код одной обезьяны, которая решилась дописать вакабу до ума... спойлер: судя по коду она обосралась, уберите от экрана детей и беременных женщин

    nariman_namazon, 10 Января 2020

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

    +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
    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
    SELECT SQL_NO_CACHE IT.itemCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.ean),",", 1) as ean,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.artCode),",", 1) as artCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.description),",", 1) as description,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.siteName),",", 1) as siteName,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.familyName),",", 1) as familyName,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.familyCode),",", 1) as familyCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.SSfamilyCode),",", 1) as SSfamilyCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.SSfamilyName),",", 1) as SSfamilyName,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.sectorCode),",", 1) as sectorCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.sectorName),",", 1) as sectorName,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.radiusCode),",", 1) as radiusCode,
                                    SUBSTRING_INDEX(GROUP_CONCAT(IT.radiusName),",", 1) as radiusName,
                                    FI.areaName,
                                    FI.areaCode,
                                    ROUND(SUM(IT.price), 2) as price,
                                    SUM(IT.quantity) as theoreticalQty,
                                    IFNULL(FI.countedQty, 0) as countedQty,
                                    ROUND(SUM(IT.quantity) * ROUND(SUM(IT.price), 2), 2) as theoreticalQtyValue,
                                    ROUND(IFNULL(FI.countedQty, 0) * ROUND(SUM(IT.price), 2), 2) as countedQtyValue,
                                    IFNULL(FI.countedQty, 0) - SUM(IT.quantity) as stockGapQty,
                                    ROUND((IFNULL(FI.countedQty, 0) - SUM(IT.quantity)) * SUM(IT.price), 2) as stockGapValue,
                                    DATE_FORMAT(ST.lastImport, "%d-%m-%Y %H:%i:%s") as dateOfLastImport,
                                    DATE_FORMAT(NOW(), "%d-%m-%Y %H:%i:%s") as dateOfExport
                            FROM Items as IT
                            LEFT JOIN ( 
                                SELECT MIN(FI.ean) as ean, SUM(FI.quantity) as countedQty, IT.itemCode,
                                GROUP_CONCAT(DISTINCT AR.name) as areaName,
                                GROUP_CONCAT(DISTINCT AR.code) as areaCode
                                FROM FoundItems as FI
                                INNER JOIN Items as IT ON FI.ean = IT.ean
                                LEFT JOIN Areas as AR ON AR.id = FI.areaId
                                
                                INNER JOIN Stores as ST ON ST.id = IT.storeId
                                
                                WHERE eventId = ${args.eventId}
                                AND IT.storeId = (SELECT storeId FROM Events WHERE id = ${args.eventId})
                                GROUP BY IT.itemCode
                            ) as FI ON IT.itemCode = FI.itemCode
                            INNER JOIN Stores as ST ON ST.id = IT.storeId
                            WHERE IT.storeId = (SELECT storeId FROM Events WHERE id = ${args.eventId})
                            GROUP BY IT.itemCode, FI.areaName, FI.areaCode, FI.countedQty, dateOfLastImport

    а що ця конструкція вміє, а ета що, про та ще й ето потрібно впихнути сюди

    silverreve23, 09 Января 2020

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

    +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
    // reflection.h
    template <class T>
    QStringList getPropertyList(T)
    {
      const QMetaObject& metaObject = T::staticMetaObject;
      ...
      return properties;
    }
    
    // Copy-pasted, the parameter now is T*
    template <class T>
    QStringList getPropertyList(T*)
    {
      const QMetaObject& metaObject = T::staticMetaObject;
      ...
      return properties;
    }
    
    // In other headers
    class IMessage
    {
    public:
      virtual ~IMessage();
      ...
    };
    
    class File
      : public IMessage
    {
      ...
    };
    
    class Text
      : public IMessage
    {
      ...
    };
    
    // Usage of all this
    QStringList p;
    p << getPropertyList(File());
    p << getPropertyList(Text());
    p << getPropertyList(static_cast<IMessage*>(new File()));

    Работаю с шаблонами и теку

    salamon_style, 05 Ноября 2019

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

    +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
    // https://gcc.gnu.org/onlinedocs/cpp/Directives-Within-Macro-Arguments.html
    
    // Occasionally it is convenient to use preprocessor directives within the arguments
    // of a macro. The C and C++ standards declare that behavior in these cases is
    // undefined. GNU CPP processes arbitrary directives within macro arguments in
    // exactly the same way as it would have processed the directive were the
    // function-like macro invocation not present. 
    
    // If, within a macro invocation, that macro is redefined, then the new definition
    // takes effect in time for argument pre-expansion, but the original definition is
    // still used for argument replacement. Here is a pathological example:
    
    #define f(x) x x
    f (1
    #undef f
    #define f 2
    f)
    
    // which expands to
    
    // 1 2 1 2

    Ну и хуйня.

    j123123, 31 Октября 2019

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

    +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
    // https://godbolt.org/z/dMT7v3
    
    unsigned div_eq(unsigned a, unsigned b)
    {
      ALWAYS_TRUE(a == b);
      return a/b;
    }
    
    unsigned div(unsigned a, unsigned b)
    {
      return a/b;
    }
    
    
    int test_array(unsigned char a[10])
    {
      for (int i = 1; i < 10; i++)
      {
        ALWAYS_TRUE(a[i-1] <= a[i]);
      }
      return a[0] <= a[2];
    }

    Refinement type
    Можно этой хуйней ассерты позаменять попробовать, и компилятор возможно что-то сможет за счет этого соптимизировать

    j123123, 26 Октября 2019

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    ВЫРАЗИТЬ(ВЫРАЗИТЬ(РасчетыСКлиентамиОстатки.ЗаказКлиента КАК Документ.РеализацияТоваровУслуг).ЗаказКлиента КАК Документ.ЗаказКлиента) КАК ЗаказКлиента
    
    Типично
    Конфигурация 1С ERP Украина.

    ChoaNyan, 11 Сентября 2019

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

    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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    // где-то в классе MyTable
    
    public next() {
      if (this.firstVisibleRow + this.currentRow < this.sortedData.length) {
        this.firstVisibleRow = this.firstVisibleRow + this.currentRow;
      }
      this.sortTable();
    }
    
    public prev() {
      if (this.firstVisibleRow - this.currentRow > 0) {
        this.firstVisibleRow = this.firstVisibleRow - this.currentRow;
      } else {
        this.firstVisibleRow = 0;
      }
      this.sortTable();
    }
    
    public sortTable() {
      this.sortedData.forEach((item, index) => {
        for (let i = this.firstVisibleRow; i < (this.firstVisibleRow + this.currentRow); i++) {
          if (i === index) {
            this.visiblilityList[index] = true;
    
            return;
          }
        }
        this.visiblilityList[index] = false;
      });
    }

    Коллега не прекращает удивлять )
    Код компонента Таблица для Vue.
    Кажется, в этом коде прекрасно всё.
    Обратите внимание, как красиво выполняется метод sortTable.
    Здесь visiblilityList используется для определения какие ряды в таблице нужно рисовать при пагинации. Про существование переменных page и rowsPerPage не слышал.
    Удивительно, но это говно работает!
    Планируем нашему коллеге по итогам года подарить грамоту "Качественный говнокод года" )

    igpo, 09 Августа 2019

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

    −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
    SELECT country, QTY, MIN(launched)
    FROM (SELECT country, launched, COUNT(name) QTY
     FROM Classes c JOIN 
     Ships s ON c.class = s.class
     GROUP BY country,launched
     HAVING COUNT(name) = (SELECT MAX(qty) 
     FROM (SELECT country,launched,COUNT(name) qty
     FROM Classes c1 JOIN 
     Ships s1 ON c1.class = s1.class
     WHERE country = c.country
     GROUP BY country,launched
     )e
     )
     )T
    GROUP BY t.qty, t.country;

    -2 sql ex rating
    я так понял необходимо ещё как-то добавить проверку на NULL?

    5252mmr, 20 Мая 2019

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

    +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
    <?php 
    $css_fold = 'css/';
    $js_fold = 'js/';
    $css_files= scandir($css_fold);
    $js_files= scandir($js_fold);
    
    foreach ($js_files as $js_file) {
    	if(preg_match('/\.(js)/', $js_file)){
    		if (substr($js_file, -3)==".js") {
    			echo'<script src="js/'.$js_file.'"></script>'.PHP_EOL;
    		}
    	}
    }
    
    foreach ($css_files as $css_file) {
    	if(preg_match('/\.(css)/', $css_file)){
    		if (substr($css_file, -4)==".css") {
    			echo'<link rel="stylesheet" type="text/css" href="css/'.$css_file.'">'.PHP_EOL;
    		}
    	}
    }
    ?>

    Подтягиваем все из css и js

    ZombiePm, 17 Мая 2019

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

    0

    1. 1
    2. 2
    3. 3
    https://habr.com/ru/post/448810/
    Уж слишком анскильно )))
    Не удивлюсь, если сам Юра - автор статьи.

    AHCKuJlbHblu_nemyx, 20 Апреля 2019

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