1. Java / Говнокод #2101

    +77.2

    1. 1
    2. 2
    3. 3
    4. 4
    public static long hash(URL url) {
    	FNV1 fnv; (fnv = new FNV1a32()).init(url.toExternalForm());
    	return fnv.getHash();
    }

    Какой читаемый код... :)

    ShadowX, 05 Ноября 2009

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

    +75.4

    1. 1
    <many-to-one name="nurseSex" entity-ref="sex" title="Пол ухаживающего"/>

    Атрибут "title" развеял все мои фантазии о сексе с медсестрой :)

    eveel, 05 Ноября 2009

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

    +77.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // Год и месяц редактируются как Double, а хранятся в  базе как два инта
                    if (aValue == null) {
                        current.setStartMonth(0);
                        current.setStartMonth(0);
                    } else {
                        current.setStartMonth(Integer.parseInt(aValue.toString().split(".")[0]));
                        current.setStartMonth(Integer.parseInt(aValue.toString().split(".")[1]));
                    }

    Программисты клиента и базы стоят один другого

    Jk, 27 Октября 2009

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

    +79.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
    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
    String _desc = postParams.get( "description" );
    
    if (_desc == null)
        _desc = "Merchant payment";
    
    _desc = _desc.replace("%20", " ");
    _desc = _desc.replace("%21", "!");
    _desc = _desc.replace("%22", "\"");
    _desc = _desc.replace("%23", "#");
    _desc = _desc.replace("%24", "$");
    _desc = _desc.replace("%25", "%");
    _desc = _desc.replace("%26", "&");
    _desc = _desc.replace("%27", "'");
    _desc = _desc.replace("%28", "(");
    _desc = _desc.replace("%29", ")");
    _desc = _desc.replace("%2A", "*");
    _desc = _desc.replace("%2B", "+");
    _desc = _desc.replace("%2C", ",");
    _desc = _desc.replace("%2D", "-");
    _desc = _desc.replace("%2E", ".");
    _desc = _desc.replace("%2F", "/");
    _desc = _desc.replace("%3A", ":");
    _desc = _desc.replace("%3B", ";");
    _desc = _desc.replace("%3C", "<");
    _desc = _desc.replace("%3D", "=");
    _desc = _desc.replace("%3E", ">");
    _desc = _desc.replace("%3F", "?");
    _desc = _desc.replace("%40", "@");
    _desc = _desc.replace("%5B", "[");
    _desc = _desc.replace("%5C", "\\");
    _desc = _desc.replace("%5D", "]");
    _desc = _desc.replace("%5E", "^");
    _desc = _desc.replace("%5F", "_");
    _desc = _desc.replace("%60", "`");
    _desc = _desc.replace("%7B", "{");
    _desc = _desc.replace("%7C", "|");
    _desc = _desc.replace("%7D", "}");
    _desc = _desc.replace("%7E", "~");

    Разработчики java.net.URLDecoder были идиотами. Напишем КРУЧЕ!

    spbAngel, 24 Октября 2009

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

    +72.6

    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
    TransferInfo info = new QiwiTransferInfo();
    
    if( command.equalsIgnoreCase( "pay" ) )
    {
        ( ( QiwiTransferInfo ) info ).setCommand( QiwiCommand.PAY );
        ( ( QiwiTransferInfo ) info ).setTxnDate( request.getParameter( "txn_date" ) );
    }
    else
    {
        ( ( QiwiTransferInfo ) info ).setCommand( QiwiCommand.CKECK );
    }
    
    ( ( QiwiTransferInfo ) info ).setAmout( Double.parseDouble( amount ) );
    ( ( QiwiTransferInfo ) info ).setTxnId( txn_id );
    ( ( QiwiTransferInfo ) info ).setAccount( account );
    ( ( QiwiTransferInfo ) info ).setCurrency( Currency.getInstance( "RUB" ) );

    C другой стороны, я никогда не могу предсказать что же вернет конструктор...

    spbAngel, 24 Октября 2009

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

    +72.2

    1. 1
    assert ( false );

    Найдено в глубинах кода :)

    generalgda, 23 Октября 2009

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

    +75.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
    boolean isCustomerWMIDExists = containParameterWithName( request, CUSTOMER_WMID_PARAM_NAME );
    boolean isSellerWMIDExists = containParameterWithName( request, SELLER_WMID_PARAM_NAME );
    boolean isPurseExists = containParameterWithName( request, PURSE_PARAM_NAME );
    boolean isDescriptionExists = containParameterWithName( request, BasePaymentSystem.DESCRIPTION_PARAM_NAME );
    boolean isInvAddressExists = containParameterWithName( request, INVADDRESS_PARAM_NAME );
    boolean isPeriodExists = containParameterWithName( request, PERIOD_PARAM_NAME );
    boolean isExperationExists = containParameterWithName( request, EXPERATION_PARAM_NAME );
    boolean isDateCrtExists = containParameterWithName( request, DATECRT_PARAM_NAME );
    boolean isDateUpdExists = containParameterWithName( request, DATEUPD_PARAM_NAME );
    boolean isWmInvIdExists = containParameterWithName( request, INVID_PARAM_NAME );
    boolean isRequestNExists = containParameterWithName( request, REQUESTN_PARAM_NAME );
    boolean isProjectIdExists = containParameterWithName( request, BasePaymentSystem.PROJECTID_PARAM_NAME );
    boolean isUserIdExists = containParameterWithName( request, BasePaymentSystem.USERID_PARAM_NAME );
    boolean isCurrencyExists = containParameterWithName( request, CURRENCY_PARAM_NAME );
    
    if (isCustomerWMIDExists && isSellerWMIDExists && isPurseExists && isDescriptionExists && isInvAddressExists && isPeriodExists
    		&& isExperationExists && isDateCrtExists && isDateUpdExists && isWmInvIdExists && isRequestNExists && isProjectIdExists
    		&& isUserIdExists && isCurrencyExists)
    {
    	wminfo.setCustomerWMID( request.getParameter( CUSTOMER_WMID_PARAM_NAME ) );
    	wminfo.setSellerWMID( request.getParameter( SELLER_WMID_PARAM_NAME ) );
    	wminfo.setPurse( request.getParameter( PURSE_PARAM_NAME ) );
    	wminfo.setDescription( request.getParameter( BasePaymentSystem.DESCRIPTION_PARAM_NAME ) );
    	wminfo.setInvAddress( request.getParameter( INVADDRESS_PARAM_NAME ) );
    	wminfo.setPeriod( Byte.parseByte( request.getParameter( PERIOD_PARAM_NAME ) ) );
    	wminfo.setExperation( Byte.parseByte( request.getParameter( EXPERATION_PARAM_NAME ) ) );
    	wminfo.setDateCrt( ( getWebMoneyDateString( Long.parseLong( request.getParameter( DATECRT_PARAM_NAME ) ) ) ) );
    	wminfo.setDateUpd( ( getWebMoneyDateString( Long.parseLong( request.getParameter( DATEUPD_PARAM_NAME ) ) ) ) );
    
    	wminfo.setWmInvID( request.getParameter( INVID_PARAM_NAME ) );
    	wminfo.setRequestN( Long.parseLong( request.getParameter( REQUESTN_PARAM_NAME ) ) );
    	wminfo.setCurrency( Currency.getInstance( request.getParameter( CURRENCY_PARAM_NAME ) ) );
    	...
    }

    Разбор параметров GET-запроса, переданных из http://govnokod.ru/2015
    // не дай бог, начальство заметит, что я рабочий код публикую

    spbAngel, 21 Октября 2009

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

    +80.4

    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
    StringBuilder sb = new StringBuilder();
    
    sb.append( "?" + BasePaymentSystem.CHECKPAYMENT_PARAM_NAME + "=true&" + WebMoneyXmlSystem.CUSTOMER_WMID_PARAM_NAME + "="
    		+ getCustomerWMID() + "&" + WebMoneyXmlSystem.CURRENCY_PARAM_NAME + "=" + getCurrency().toString() + "&"
    		+ WebMoneyXmlSystem.SELLER_WMID_PARAM_NAME + "=" + _sellerWMID + "&" + WebMoneyXmlSystem.PURSE_PARAM_NAME + "=" + _purse
    		+ "&" + WebMoneyXmlSystem.DESCRIPTION_PARAM_NAME + "=" + getDescription() + "&" + WebMoneyXmlSystem.INVADDRESS_PARAM_NAME
    		+ "=" + _invAddress + "&" + WebMoneyXmlSystem.PERIOD_PARAM_NAME + "=" + _period + "&"
    		+ WebMoneyXmlSystem.EXPERATION_PARAM_NAME + "=" + _experation + "&" + WebMoneyXmlSystem.DATECRT_PARAM_NAME + "="
    		+ dateCreateMills.toString() + "&" + WebMoneyXmlSystem.DATEUPD_PARAM_NAME + "=" + dateUpdateMills.toString() + "&wmInvId="
    		+ _wmInvId + "&requestN=" + String.valueOf( _requestn ) + "&" + BasePaymentSystem.PROJECTID_PARAM_NAME + "="
    		+ _projectId.toString() + "&" + BasePaymentSystem.USERID_PARAM_NAME + "=" + _userId.toString() );
    
    return new String( sb );

    Формирование строки GET запроса.

    spbAngel, 21 Октября 2009

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

    +77.5

    1. 1
    2. 2
    3. 3
    4. 4
    //devPin и pin - массивы байт, а сравниваем мы их так :
    
    if (Utils.bytesToHex(devPin).equals(Utils.bytesToHex(pin))) {
    ....

    :)))

    tuba.linux, 21 Октября 2009

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

    +72.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
    private char readNextChar() throws IOException {
            synchronized (in) {
                if (plain) {
                    if (BANDWIDTH_DEBUG) {
                        CasinoServer.bandwidthChecker.addClientMessageReceived(1);
                    }
                    int c = in.read();
                    if (c == -1) {
                        throw new IOException("Client disconnected");
                    }
                    return (char) c;
                }
                if (num_bytes_read % 5 == 0) {
                    if (!isNgClient()) {
                        last_byte_read = readURLEncodedChar();
                    } else {
                        if (BANDWIDTH_DEBUG) {
                            CasinoServer.bandwidthChecker.addClientMessageReceived(1);
                        }
                        int c = in.read();
                        if (c == -1) {
                            throw new IOException("Client disconnected");
                        }
                        last_byte_read = c & 0xff;
                    }
                    ++num_bytes_read;
                }
                int x;
                if (!isNgClient()) {
                    x = readURLEncodedChar();
                } else {
                    if (BANDWIDTH_DEBUG) {
                        CasinoServer.bandwidthChecker.addClientMessageReceived(1);
                    }
                    int c = in.read();
                    if (c == -1) {
                        throw new IOException("Client disconnected");
                    }
                    x = c & 0xff;
                }
                last_byte_read ^= x;
                int y = last_byte_read;
                last_byte_read = (x & 0xff);
                ++num_bytes_read;
                return (char) (y & 0xff);
            }
        }

    This is the ingenious algorithm, invented by the estonians to read a simple byte from a socket. Couldn't think of anything more error-prone, and less readable. Enjoy!

    bot225, 20 Октября 2009

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