1. Perl / Говнокод #23249

    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
    if ( $MonitorMode eq \">=\" )
    {
      if ( $NbrProcesses < $ProcNumber )
      {
        $Rule->Status(TRUE);
      }
    }
    elsif ( $MonitorMode eq \"<=\" )
    {
      if ( $NbrProcesses > $ProcNumber )
      {
        $Rule->Status(TRUE);
      }
    }
    else
    {
      if ( $NbrProcesses != $ProcNumber )
      {
        $Session->Value(\"PROCESSMODE\", \"\" );
        $Rule->Status(TRUE);
      }
    };

    Кровавый ентерпрайз. Кусок кода мейд бай ХулетПакард

    rjhdby, 09 Августа 2017

    Комментарии (37)
  2. PHP / Говнокод #23248

    +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
    switch (DAEMONS_ENV) {
                case "development": {
                    break;
                }
    
                case "staging": {
                    break;
                }
    
                case "production": {
                    break;
                }
    
                default: {
                    break;
                }
            }

    hack3p, 09 Августа 2017

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

    0

    1. 1
    2. 2
    3. 3
    catch (Exception e) {
        System.err.println("!!");
    }

    Fike, 08 Августа 2017

    Комментарии (1)
  4. Си / Говнокод #23246

    +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
    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
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char *concat(char *a, char *b)
    {
      char *ptr = malloc(strlen(a)+strlen(b)+6);
      if (ptr == NULL)
      {
        fprintf(stderr, "da ty ohuel!\n");
        exit(-1);
      }
      sprintf(ptr, "(%s)*(%s)", a, b);
      return ptr;
    }
    
    char *govno[255] = {"a"};
    
    void printfshit(const size_t pow, const char *mul_stuff)
    {
      printf("double pow_%zu(double a) {return %s;}\n\n", pow, mul_stuff);
    }
    
    void genshit(void)
    {
      //printfshit(0,"1");
      size_t end_ind = 1;
      size_t prev_stop = 0;
      size_t end_ind_tmp = 1;
      while (end_ind < 255)
      {
        for (size_t ind1 = 0; ind1 < end_ind_tmp; ind1++)
        {
          for (size_t ind2 = prev_stop; ind2 < end_ind_tmp; ind2++)
          {
            if ( 
                 ((ind1+1) + (ind2+1) < 256) &&
                 (govno[(ind1+1) + (ind2+1)-1] == NULL)
               )
            {
              govno[(ind1+1) + (ind2+1)-1] = concat(govno[ind1], govno[ind2]);
              end_ind++;
            }
          }
        }
        prev_stop = end_ind_tmp;
        end_ind_tmp = end_ind;
      }
      printfshit(1,govno[0]);
      for (size_t i = 1; i < 255; i++ )
      {
        printfshit(i+1,govno[i]);
        free(govno[i]);
      }
    }
    
    int main(void)
    {
      genshit();
      return 0;
    }

    Кодогенератор, написаный специально для Antervis
    http://govnokod.ru/23227#comment388895

    j123123, 08 Августа 2017

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

    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
    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
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.util.ArrayList;
    import java.util.List;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            File file = new File("C:\\file.txt");
    
            BufferedReader reader = new BufferedReader(new FileReader(file));
    
            String newPath = "C:\\Users\\GrakovNe\\Downloads\\errs";
    
            List<String> list = new ArrayList<>();
    
            while (true){
                try {
    
                    String name = reader.readLine();
    
                    if (name == null){
                        break;
                    }
                    list.add(reader.readLine());
                } catch (Exception ex){
                    // go next;
                    continue;
                }
            }
    
            for (int i = 0; i < list.size(); i++){
                try {
                    File file1 = new File(list.get(i).replaceAll("\\\\", "\\\\\\\\").trim());
                    Files.copy(file1.toPath(), new File(newPath + "\\" + file1.getName()).toPath());
                } catch (Exception ex){
                    ex.printStackTrace();
                    continue;
                }
            }
        }
    }

    CTRL-C + CTRL-V

    grakovne, 08 Августа 2017

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Если Отладка Тогда
    				ЗаписьXML.ЗаписатьТекст(СокрЛП(КодИнтернетЗаказа));
    			Иначе
    				ЗаписьXML.ЗаписатьТекст(СокрЛП(КодИнтернетЗаказа));
    			КонецЕсли;

    Безысходность. Судьба предрешена. Бедный Йорик.

    M1CE, 08 Августа 2017

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

    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
    31. 31
    32. 32
    33. 33
    34. 34
    internal static object CreateDefaultEqualityComparer(Type type)
            {
                Debug.Assert(type != null && type is RuntimeType);
    
                object result = null;
                var runtimeType = (RuntimeType)type;
    
                // Specialize for byte so Array.IndexOf is faster.
                if (type == typeof(byte))
                {
                    result = new ByteEqualityComparer();
                }
                // If T implements IEquatable<T> return a GenericEqualityComparer<T>
                else if (typeof(IEquatable<>).MakeGenericType(type).IsAssignableFrom(type))
                {
                    result = CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(GenericEqualityComparer<int>), runtimeType);
                }
                // Nullable does not implement IEquatable<T?> directly because that would add an extra interface call per comparison.
                // Instead, it relies on EqualityComparer<T?>.Default to specialize for nullables and do the lifted comparisons if T implements IEquatable.
                else if (type.IsGenericType)
                {
                    if (type.GetGenericTypeDefinition() == typeof(Nullable<>))
                    {
                        result = TryCreateNullableEqualityComparer(runtimeType);
                    }
                }
                // The equality comparer for enums is specialized to avoid boxing.
                else if (type.IsEnum)
                {
                    result = TryCreateEnumEqualityComparer(runtimeType);
                }
                
                return result ?? CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(ObjectEqualityComparer<object>), runtimeType);
            }

    Код взят из CoreCLR mscorlib сырцов.

    Внимание вопрос. Нахерна было писать эту обосгость когда данный метод легко делается генериком без какого либо вызова "невидимого" кода?

    вот пример как все должно было быть

    ```
    internal static object CreateDefaultEqualityComparer<T>()
    {
    // Specialize for byte so Array.IndexOf is faster.
    if (typeof(T) == typeof(byte))
    {
    result = new ByteEqualityComparer();
    }
    // If T implements IEquatable<T> return a GenericEqualityComparer<T>
    else if (typeof(IEquatable<T>).IsAssignableFrom( typeof(T)))
    {
    result new GenericEqualityComparer<T>();
    }
    // Nullable does not implement IEquatable<T?> directly because that would add an extra interface call per comparison.
    // Instead, it relies on EqualityComparer<T?>.Default to specialize for nullables and do the lifted comparisons if T implements IEquatable.
    else if (typeof(T).IsGenericType)
    {
    if (typeof(T).GetGenericTypeDefinition() == typeof(Nullable<>))
    {
    result = new NullableEqualityComparer<T>();
    }
    }
    // The equality comparer for enums is specialized to avoid boxing.
    else if (typeof(T).IsEnum)
    {
    result = TryCreateEnumEqualityComparer<T>();
    }

    return result ?? new ObjectEqualityComparer<T>();
    }
    ```

    ASD_77, 07 Августа 2017

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

    +4

    1. 1
    http://blog.extremehacking.org/blog/2017/07/31/hungarian-hacker-arrested-pressing-f12/

    Вкратце: в Будапеште за миллион баксов набыдлокодили систему продажи билетов на общественный транспорт с кучей багов, как например поле с суммой было readonly, но если поправить html в браузере, то можно цену поменять, а на бэкенде никто не стал проверку суммы делать. Пацанчик этот баг нашел, написал в саппорт, а через 2 недели его мусора загребли.

    j123123, 05 Августа 2017

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

    +1

    1. 1
    2. 2
    3. 3
    CoolIntf::GetInstance().DoSomething();
    CoolIntf::GetInstance().DoSomethingElse();
    CoolIntf::GetInstance().DoAnything()

    для случая когда GetInstance() не инлайнится, кто-нибудь в крестах какое решение (без ручного введения временной переменной) для такого кода придумал?
    единственное что нашел это вот это: https://stackoverflow.com/a/2279253 .
    потому что "with" слишком общее слово которое в ж не гуглится.

    Dummy00001, 04 Августа 2017

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

    +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
    Объявление метода в интерфейсе:
    
    @NotNull
    List<ServicePojo> getAvailableServices(boolean withoutOffer);
    
    реализация:
    
    @NotNull
    @Override
    public List<ServicePojo> getAvailableServices(boolean withOfferService) {
    ...
    }

    moonson, 04 Августа 2017

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