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

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

    +69

    1. 1
    2. 2
    http://habrahabr.ru/post/263703/
    https://github.com/veryEvilMan/fl-ru-damp/issues/3#issuecomment-125602470

    Так, признавайтесь, кто приложил потные ручонки.

    bakagaijin, 30 Июля 2015

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

    +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
    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
    totOwed1 = BigDecimalUtils
    				.subtract(
    						BigDecimalUtils.subtract(
    								BigDecimalUtils.subtract(
    										BigDecimalUtils.subtract(
    												BigDecimalUtils.subtract(
    														BigDecimalUtils.subtract(
    																BigDecimalUtils
    																		.subtract(
    																				BigDecimalUtils
    																						.subtract(
    																								BigDecimalUtils
    																										.subtract(
    																												BigDecimalUtils
    																														.subtract(
    																																BigDecimalUtils
    																																		.subtract(
    																																				BigDecimalUtils
    																																						.subtract(
    																																								BigDecimalUtils
    																																										.subtract(
    																																												BigDecimalUtils
    																																														.subtract(
    																																																BigDecimalUtils
    																																																		.subtract(
    																																																				BigDecimalUtils
    																																																						.subtract(
    																																																								BigDecimalUtils
    																																																										.subtract(
    																																																												BigDecimalUtils
    																																																														.subtract(
    																																																																BigDecimalUtils
    																																																																		.subtract(
    																																																																				BigDecimalUtils
    																																																																						.subtract(
    																																																																								hMoTotalPayAmt,
    																																																																								hClmPaperChrgAmt),
    																																																																				hRestitutionAmt),
    																																																																hRestQaAmt),
    																																																												hRestNmAmt),
    																																																								hOverPaymentAmt),
    																																																				hLevyAmt),
    																																																hSupportOrdAmt),
    																																												hBackUpWithhdAmt),
    																																								hEyefinDebitAmt),
    																																				hPrePaymentAmt),
    																																hMoDebitsVsplab),
    																												hMoDebitsPlexus),
    																								hMoDebitsCollab),
    																				hDebitsLegends),
    																hDebitsUltra),
    														hDebitsCapitol),
    												hDebitsSandiego),
    										hDebitsTampabay), hDebitsStcloud),
    						hMoDebitsAltair);

    kostoprav, 09 Июля 2015

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

    +69

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private static <T extends Contract> Class getClazz(T contract) {
            return contract instanceof ContractLease ? ContractLease.class :
                    contract instanceof ContractPlantsSale ? ContractPlantsSale.class :
                            contract instanceof ContractForestWorks ? ContractForestWorks.class :
                                    contract instanceof ContractPermanent ? ContractPermanent.class :
                                            contract instanceof ContractForestDeclaration ? ContractForestDeclaration.class :
                                                    contract instanceof ContractReport ? ContractReport.class : null;

    Обожаю такие штуки, такая красивая лесенка...

    floppy, 30 Июня 2015

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

    +69

    1. 1
    2. 2
    3. 3
    debug("Continue current `round={}`", next);
    /** 3-мя строчками ниже */
    debug("Next round `round={}`", current);

    stasmarkin, 23 Июня 2015

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

    +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
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    package mypackage;
    import java.io.*;
    
    public class RimToArab {
    		public static void main(String [] args){
    			System.out.println("Enter the Roman numeral:");
    			String Rim = "";
    			char[] Rch = {'I','V','X','L','C','D','M'};
    			int[] Acf = {1,5,10,50,100,500,1000};
    			
    			
    			int i,j=0,rez=0;						
    			try {
    				BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
    				Rim = d.readLine();  
    			} catch  (IOException e) {
    				System.out.println("Input error!");
    			} 				
    			for (int c = Rim.length()-1; c>=0; --c ){				
    					for(i=6;i>=0; --i){
    						if (Rch[i]==Rim.charAt(c)){
    							if (j>Acf[i]){
    								rez=rez-Acf[i];
    							} else {
    								rez=rez+Acf[i];
    							}					
    							j=Acf[i];
    						}											
    					}							
    									
    			}				
    			if (rez!=0){
    				System.out.println(rez);
    			}	else {
    				System.out.println("Wrong format of input!");
    			}
    		}
    }

    говнокод наоборот римские в арабские

    Norick, 21 Марта 2015

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

    +69

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    "add()\n";
    assert((row_indx >= 0 && row_indx <= rows) && 
    (col_indx >= 0 && col_indx < cols)
    );
    
    if(row_indx == rows)
    addRow();
    
    if(init_flag_arr[row_indx][col_indx])
    {
    std::cout « "in moving\n";
    int uninit_i, uninit_j;
    bool found = false;
    for(int i = row_indx; found == false && i < rows; i++)
    for(int j = col_indx; found == false && j < cols; j++)
    if(!init_flag_arr[i][j]) // если флаг == false
    {
    std::cout « "found!\n";
    uninit_i = i;
    uninit_j = j;
    found = true;
    
    }
    if(!found)
    {
    std::cout « "not found!\n";
    addRow(); // добовляем новую строку в матрицу (rows++)
    uninit_i = rows - 1;
    uninit_j = 0;
    }
    
    bool exit = false;
    for(int i = uninit_i, j = uninit_j; exit == false; i--)
    {
    for(; ;j--)
    {
    if(j == col_indx && i == row_indx)
    {
    exit = true;
    break;
    }
    if(j == 0)
    {
    matrix[i][j] = matrix[i - 1][cols - 1];
    init_flag_arr[i][j] = init_flag_arr[i - 1][cols - 1];
    break; 
    }
    matrix[i][j] = matrix[i][j - 1];
    init_flag_arr[i][j] = init_flag_arr[i][j - 1];
    
    }
    j = cols - 1;
    }
    } 
    matrix[row_indx][col_indx] = obj;
    init_flag_arr[row_indx][col_indx] = true;
    std::cout « "end add()\n";
    
    }
    
    // Для дебага, вывод инициализированных ячеек матрицы
    void Matrix::InitTable(std::ostream& os)const // чисто для дебага
    {
    for(int i = 0; i < rows; i++)
    {
    for(int j = 0; j < cols; j++)
    if(!init_flag_arr[i][j])
    os « "false\t";
    else
    os « "true\t";
    os « std::endl;
    }
    }
    // Удаление объекта с матрицы
    void Matrix::remove(int row_indx, int col_indx)
    {
    std::cout « "remove()\n";
    assert((row_indx >= 0 && row_indx < rows) && 
    (col_indx >= 0 && col_indx < cols)
    );
    matrix[row_indx][col_indx] = 0;
    init_flag_arr[row_indx][col_indx] = false;
    
    std::cout « "end remove()\n";
    }
    
    void Matrix::removeRow(int row_indx)
    {
    assert(row_indx >= 0 && row_indx < rows);
    int** new_matrix = new int*[rows - 1];
    bool** new_init_flag_arr = new bool*[rows];
    for(int i = 0; i < rows - 1; i++)
    {
    new_matrix[i] = new int[cols];
    new_init_flag_arr[i] = new bool[cols];
    //for(int j = 0; j < cols; j++)
    //{
    // new_matrix[i][j] = 0;
    // new_init_flag_arr[i][j] = false;
    //}/

    ...

    ana_stasia , 06 Августа 2014

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

    +69

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public static boolean isEmpty(CharSequence str) {
        if (str == null || str.length() == 0)
            return true;
        else
            return false;
    }

    Я считаю это странным
    Нашёл в android.text.TextUtils

    jonasas, 07 Июля 2014

    Комментарии (22)
  9. Java / Говнокод #15990

    +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
    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
    92. 92
    93. 93
    94. 94
    95. 95
    package com.javarush.test.level06.lesson11.bonus02;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
     
    /* Нужно добавить в программу новую функциональность
    Задача: У каждой кошки есть имя и кошка-мама. Создать класс, который бы описывал данную ситуацию. Создать два объекта: кошку-дочь и кошку-маму. Вывести их на экран.
    Новая задача: У каждой кошки есть имя, кошка-папа и кошка-мама. Изменить класс Cat так, чтобы он мог описать данную ситуацию.
    Создать 6 объектов: маму, папу, сына, дочь, бабушку(мамина мама) и дедушку(папин папа).
    Вывести их всех на экран в порядке: дедушка, бабушка, папа, мама, сын, дочь.
     
    Пример ввода:
    дедушка Вася
    бабушка Мурка
    папа Котофей
    мама Василиса
    сын Мурчик
    дочь Пушинка
     
    Пример вывода:
    Cat name is дедушка Вася, no mother, no father
    Cat name is бабушка Мурка, no mother, no father
    Cat name is папа Котофей, no mother, father is дедушка Вася
    Cat name is мама Василиса, mother is бабушка Мурка, no father
    Cat name is сын Мурчик, mother is мама Василиса, father is папа Котофей
    Cat name is дочь Пушинка, mother is мама Василиса, father is папа Котофей
    */
     
    public class Solution
    {
        public static void main(String[] args) throws IOException
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
     
            String grfatherName = reader.readLine();
            Cat catGrfather = new Cat(grfatherName);
     
            String grmotherName = reader.readLine();
            Cat catGrmother = new Cat(grmotherName);
     
            String fatherName = reader.readLine();
            Cat catFather = new Cat(fatherName, catGrfather, null);
     
            String motherName = reader.readLine();
            Cat catMother = new Cat(motherName, null, catGrmother);
     
            String sonName = reader.readLine();
            Cat catSon = new Cat(sonName, catFather, catMother);
     
            String daughterName = reader.readLine();
            Cat catDaughter = new Cat(daughterName, catFather, catMother);
     
            System.out.println(catGrfather);
            System.out.println(catGrmother);
            System.out.println(catFather);
            System.out.println(catMother);
            System.out.println(catSon);
            System.out.println(catDaughter);
     
        }
     
        public static class Cat
        {
            private String name;
            private Cat father;
            private Cat mother;
     
     
            Cat(String name)
            {
                this.name = name;
            }
     
            Cat (String name, Cat father, Cat mother){
                this.name = name;
                this.mother = mother;
                this.father = father;
     
            }
     
            @Override
            public String toString()
            {
                if ((mother == null) && (father == null))
                    return "Cat name is " + name + ", no mother, no father ";
                else if (father == null)
                    return "Cat name is " + name + ", mother is " + mother.name + " , no father";
                else if (mother == null)
                    return  "Cat name is " + name + ", no mather " + ", father is " + father.name;
                else
                    return "Cat name is " + name + ", mother is " + mother.name + ", father is " + father.name;
            }
        }
    }

    Да лаба, точнее задание. Но меня так умиляет решение задачи :) Просто немного хардкода :)

    kostoprav, 15 Мая 2014

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

    +69

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public void startApp() {
            StringItem si = new StringItem("Some label","Some text");
            try{
                Image img = Image.createImage("/res/path/to/image.gif");
                FORM.append(img);
            }catch (java.io.IOException ioe){
                ioe.printStackTrace();
            }
            FORM.append(si);
            DISPLAY.setCurrent(FORM);
        }

    Wtf?
    http://www.gfs-team.ru/articles/read/107

    gost, 31 Марта 2014

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

    +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
    final double base = 10.0;
    final int minCode = (int)Math.pow(base, CODE_LENGTH - 1) - 1;
    final int maxCode = (int)Math.pow(base, CODE_LENGTH) - 1;
    
    while (true)
    {
        final int code = codeGenerator.nextInt();
        if ((code > minCode) && (code <= maxCode))
        {
            return String.valueOf(code);
        }
    }

    Геренация случайного пина с определенным интервалом.

    rvller, 26 Февраля 2014

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