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

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

    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
    Vector_type(const Vector_type& m1) {
    		if (this->size != m1.size) {
    			if (this->size != 0)
    				destroy_memmory();
    			this->size = m1.size;
    			this->M = new m_type[size];
    			for (int i = 0; i < size; i++)
    				this->M[i] = m1.M[i];
    		}
    		else {
    			for (int i = 0; i < size; i++)
    				this->M[i] = m1.M[i];
    		}
    	};
    	Vector_type& operator = (const Vector_type& m1) {
    		if (this->size != m1.size)
    			throw "not right =";
    		for (int i = 0; i < size; i++)
    			this->M[i] = m1.M[i];
    		return *this;
    	};

    Действительно что могло пойти не так? просто копировать приравнять, копировать, приравнять, копировать...

    cat_code, 12 Октября 2018

    Комментарии (10)
  3. C# / Говнокод #24895

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // todo '+1' is temporary
    private string CorrectPhoneNumber(string phoneNumber, string countryCode = "+1")
    {
    	if (phoneNumber.Substring(0, 1) != "+")
    	{
    		return string.Format("{0}{1}", phoneNumber.Length == 10 ? countryCode : "+", phoneNumber);
    	}
    
    	return phoneNumber;
    }

    Genious!

    Moses, 11 Октября 2018

    Комментарии (10)
  4. JavaScript / Говнокод #24820

    −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
    <a class="callformtrigger"  href="http://#ck_callback_button"><!-- container box --></a>
    <script>
    (function(){
    	try{
                var el = $("a.callformtrigger");
                var hash = el.attr("href");
                hash = hash.replace("http://", "");
                el.attr("href", hash);
    	}
    	catch(e)
    	{
    		/** **/
    	}
    })();
    </script>

    вместо того, чтобы поправить данный url в исходниках, был применен данный способ

    turbosnail, 26 Сентября 2018

    Комментарии (10)
  5. C# / Говнокод #24808

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // тухло 
    if (json.Contains("message")) 
    { 
        classOperatios.ResultOper2 result2 = JsonConvert.DeserializeObject<classOperatios.ResultOper2>(json); 
        MessageBox.Show(result2.message + (char)13 + (char)10 + result2.errors); 
    }

    Царский код. Как склеить две строки с разделителем "новая строка".

    awesome3000, 25 Сентября 2018

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    const (
    	millisPerSecond     = int64(time.Second / time.Millisecond)
    	nanosPerMillisecond = int64(time.Millisecond / time.Nanosecond)
    )

    Автор предусмотрел возможность изменения СИ.

    cheshir, 21 Сентября 2018

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

    −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
    int[][] arr = new int[3][];
                arr[0] = new int[3];
                arr[1] = new int[2];
                arr[2] = new int[5];
                arr[0][2] = 16;
                arr[1][0] = 45;
                arr[2][4] = 99;
                foreach (int item in arr[0])
                    Console.Write(item + " ");
                Console.WriteLine();
                foreach (int item in arr[1])
                    Console.Write(item + " ");
                Console.WriteLine();
                foreach (int item in arr[2])
                    Console.Write(item + " ");
    
    Этот foreach просто божественен

    Auzergos, 14 Сентября 2018

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private Integer getIntegerValue(int length) throws PivotReadExeption {
            getValue(length);
            return this.stringBuffer.toString().trim().isEmpty()?0:Integer.valueOf(this.stringBuffer.toString());
        }
    
        private BigDecimal getDoubleValue(int length) throws PivotReadExeption {
            getValue(length);
            if(this.stringBuffer.toString().trim().isEmpty()) return null;
            return new BigDecimal(this.stringBuffer.toString().trim());
        }

    Сотрудник выдал. Это говнокод или нет?

    gaal, 11 Сентября 2018

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio.h(false);
        cin.tie(0);
        cout.tie(0);
    }

    Чо за хуйня?

    LinuxGovno, 07 Сентября 2018

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

    −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
    63. 63
    64. 64
    65. 65
    private static function preparePostProperty(&$data, $propName = [], $type = 'float'){
            if(!in_array($type, ['float', 'integer', 'string']))
                return;
            if(is_array($data) && !empty($propName)){
                $key = '$data["' . implode('"]["', $propName) . '"]';
    
                @eval("if(isset($key)) $key = ($type)$key;");
            }
        }
    
    
        public static function preparePost($data, $documentsObjects = []){
            if(is_array($data)){
                self::preparePostProperty($data, ['general', 'fromMtender', 'lotDetails', 'lotAmount']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountBrutto']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountNetto']);
                self::preparePostProperty($data, ['general', 'additionalData', 'budgetDetails', 'amountPrepayment']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountGuarantee']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountGE']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountWithdraw']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'amountMaxWithdraw']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'transferDuration']);
                self::preparePostProperty($data, ['general', 'additionalData', 'bankGuarantee', 'nonPaymentMax']);
                self::preparePostProperty($data, ['general', 'additionalData', 'executionShouldStart']);
                self::preparePostProperty($data, ['general', 'additionalData', 'executionDuration']);
    
                foreach ($data['subject'] as $k => $subjects){
                    //data[subject][0][fromMtender][itemQuantity]
                    self::preparePostProperty($data, ['subject', $k, 'fromMtender', 'itemQuantity']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'unitPrice', 'withoutVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'unitPrice', 'withVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'amountPrice', 'withoutVAT']);
                    self::preparePostProperty($data, ['subject', $k, 'additionalData', 'itemDetails', 'itemPrice', 'amountPrice', 'withVAT']);
    
                    foreach ($subjects['additionalData']['budget'] as $kb => $budgets){
                        self::preparePostProperty($data, ['subject', $k, 'additionalData', 'budget', $kb, 'budgetAmount']);
                    }
                }
    
                self::preparePostProperty($data, ['ca', 'additionalData', 'caPerson', 'caPersonCode']);
    
                self::preparePostProperty($data, ['eo', 'fromMtender', 'eoCode']);
                self::preparePostProperty($data, ['eo', 'additionalData', 'eoLicenses', 'eoValidityDuration']);
                self::preparePostProperty($data, ['eo', 'additionalData', 'eoPerson', 'eoPersonCode']);
    
                self::preparePostProperty($data, ['otherConditions', 'sla', 'deliveryDelayLiability', 'liabilityPercent']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'deliveryDelayLiability', 'liabilityPercentMax']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'paymentDelayLiability', 'liabilityPercent']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'paymentDelayLiability', 'liabilityPercentMax']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'maxPenalty']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'maxDelay']);
                self::preparePostProperty($data, ['otherConditions', 'sla', 'warrantyPeriod']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnSigned']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnFM']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'informOnTermination']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'respondOnTermination']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'submitClaimsMax']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'respondClaimsMax']);
                self::preparePostProperty($data, ['otherConditions', 'timeline', 'deliverOnClaims']);
            }
    
            self::appendPostDocuments($data, $documentsObjects);
    
            return $data;
        }

    ЧТОЕТА?

    dd3d, 20 Августа 2018

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

    −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
    public Pattern waitNotEmptyRegex(){
            String read;
            Pattern pattern;
    
            while (true) {
                try {
                    try {
                        read = in.readLine();
                        if (!read.trim().isEmpty()) {
                            pattern = Pattern.compile(read);
                        } else {
                            context.getOut().write(context.localizKey("console.messages.emptyString") + "\n");
                        }
                    } catch (PatternSyntaxException e) {
                        context.getOut().write(context.localizKey("console.messages.invalidPattern") + "\n");
                    }
                }catch (IOException e){
                    throw new IllegalStateException(e);
                }
            }
        }

    Боооольше вложенных блоков

    the-alator, 20 Августа 2018

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