1. 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)
  2. Java / Говнокод #18448

    +38

    1. 1
    link.setUrlDownload(url.replaceAll("%21", "!").replaceAll("%20", ""));

    Необучаемость.

    3_14dar, 08 Июля 2015

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

    +66

    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
    Map<Organization, Collection<IFormula>> comissionFormulasMap = getComissionFormulae(bank, service, a);
                transIterator:
                for (Transaction T : afterBillingMemorandum) {//для каждой транзакции
    
                    if (comissionFormulasMap.isEmpty()) {
                        //System.out.println("Нет формулы для комиссии");
                        afterComissionSet.add(T); //если нет формулы для определения комиссии транзакция попадает в список на расщепление
                    } else {
                        BigDecimal transactionStartValue = T.getStartValue();
                        Set<Transaction> afterComissionForCurrent = new HashSet<>();
                        BigDecimal fullTax = BigDecimal.ZERO;
                        Collection<IFormula> comissionsAKT = new LinkedList<>();
    
                        for (Map.Entry<Organization, Collection<IFormula>> comissionsByBank : comissionFormulasMap.entrySet()) {
                            Organization comissionBank = comissionsByBank.getKey();
                            for (IFormula f : comissionsByBank.getValue()) {//для каждой формулы по комиссии
                                GeneratedTransactionTypes transactionType = f.getGeneratedTransactionTypes(comissionBank);
    
                                if (transactionType == GeneratedTransactionTypes.AKT) {
                                    comissionsAKT.add(f);
                                } else {
                                    BigDecimal commie = f.commission(transactionStartValue);//Определяем значение комиссии
                                    if (commie.compareTo(BigDecimal.ZERO) == 0)
                                        continue; //Комиссия 0 нам не интересна, переходим к следующей формуле
                                    fullTax = fullTax.add(commie);//складываем комиссии
                                    if (fullTax.compareTo(transactionStartValue) == 1) {
                                        log.error("Помилка зняття комісії. Сума комісій більша 100 %. Транзакція не буде оброблена. Транзакція: {}", T.toBaseString());
                                        continue transIterator;
                                    } else {
                                        afterComissionForCurrent.add(T.getComissionTransaction(f.getOrganization(), commie, transactionType));
                                    }
                                }
                            }
                        }
    //
    //                    afterComissionSet.addAll(afterComissionForCurrent);
    //                    afterComissionForCurrent.clear();
    
                        //Далі зняття по акту
                        BigDecimal afterComissionStartValue = transactionStartValue.subtract(fullTax);
                        BigDecimal aktFullTax = BigDecimal.ZERO;
                        for (IFormula f : comissionsAKT) {
                            GeneratedTransactionTypes transactionType = GeneratedTransactionTypes.AKT;
    
                            BigDecimal commie = f.commission(afterComissionStartValue);
                            if (commie.compareTo(BigDecimal.ZERO) == 0)
                                continue;
                            BigDecimal newFullTax = aktFullTax.add(commie);
                            if (newFullTax.compareTo(afterComissionStartValue) > 0) {
                                continue;
                            }
                            aktFullTax = newFullTax;
                            afterComissionForCurrent.add(T.getComissionTransaction(f.getOrganization(), commie, transactionType));
                        }
    
    
                        afterComissionSet.add(T.getRestTransaction(fullTax.add(aktFullTax)));
                        afterComissionSet.addAll(afterComissionForCurrent);
                    }
                }

    Писал один товарещ, притом взрослый и сформировавшийся как личность )

    ekh, 30 Июня 2015

    Комментарии (2)
  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 / Говнокод #18409

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    String convertingForUi = new Gson().toJson(elements).replaceAll("    \"", "     ");
            convertingForUi = convertingForUi.replaceAll("\"\\[", "[");
            convertingForUi = convertingForUi.replaceAll("]\"", "]");
            convertingForUi = convertingForUi.replaceAll("\":", ":");
            convertingForUi = convertingForUi.replaceAll(": \"", ": '");
            convertingForUi = convertingForUi.replaceAll("\",", "',");
            convertingForUi = convertingForUi.replaceAll("\"\n", "'\n");
            convertingForUi = convertingForUi.replaceAll("'green'", "green")
           ...

    dmli, 27 Июня 2015

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

    +67

    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
    enum MethodCallResult {
        OK,
        INTERNAL_ERROR,
        INVALID_ARGUMENTS,
        ...
    }
    
    MethodCallResult result = ...;
    
    switch (result.ordinal()) {
    	case 0:
    		...
    		break;
    	case 1:
    		...
    		break;
    	...
    }

    Натолкнулся в офигенном Ынтырпрайз-проекте, который спихнули на поддержку. Утверждали, что Sonar выдает 0 ошибок.

    kostoprav, 27 Июня 2015

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

    +69

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

    stasmarkin, 23 Июня 2015

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

    +67

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public class Client extends Thread {
        private final static Logger LOG = Logger.getLogger(Client.class);
    
        @Override
        public void run() {
            System.out.println("Client " + name + " comes to restaurant " + restaurant.getName());
            this.cashDesk = chooseCashDesk();
            System.out.println("Client " + getClientName() + " choosed the cashDesk#"+ cashDesk.getNumber());
           //...остальное говно
       }
    }

    Что такое логгер ? ХЗ. Требуют - значит должно быть!

    argamidon, 21 Июня 2015

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public List<LDAPUserState> getAllLDAPUsersFromAD() {
    		try {
    			ldc.getAllLDAPUsers();
    		} catch (NamingException e) {
    			LOG.error(e.getMessage(), e);
    		}
    	return null;
    }

    InCh, 19 Июня 2015

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

    +142

    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
    private boolean get(CharArrayExt szNum, CountryAreaContainer container)  {
            char cCur = 0;
            if(!szNum.isEmpty()) {
                cCur = szNum.charAt(0);
            }
    
            Country lpSettingsCountry = isRemoveNPrefixAfterCC();
    
            if ((cCur != 0) && lpSettingsCountry != null) {
                int iLen = lpSettingsCountry.getNationalPrefix().length();
    
                if ((iLen > 0) && szNum.startsWith(lpSettingsCountry.getNationalPrefix())) {
                    szNum.cut(iLen);
                    cCur = szNum.charAt(0);
                    container.areaOffset = iLen;
                }
            }
    
            if ((cCur != 0) && isNodeExist(cCur)) {
                if(getNode(cCur).get(szNum.cut(1), container)) {
                    return true;
                }
            }
    
            int iCount = items.size();
    
            if (iCount == 1) { //Normally
                NodeItemBase lpItem = items.get(0);
                if (lpItem.isArea()) {
                    container.area = (Area) lpItem;
                }
                container.country = lpItem.getCountry();
                return true;
            } else {
                if (iCount > 1) {
                    for (int i = 0; i < iCount; i++) {
                        NodeItemBase lpItem = items.get(i);
    
                        if (lpItem.isCountry()) {
                            Country lpCountry = (Country) lpItem;
    
                            if (lpCountry.getAreas().size() == 0) {
                                container.country = lpCountry;
                                return true;
                            }
                        }
                    }
                }
            }
    
            return false;
     }

    Кто писал этот код - знайте, Я Вас НЕНАВИЖУ!!!

    zaebalsya, 18 Июня 2015

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