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

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

    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
    /**
         * Sets the user in the token.
         *
         * The user can be a UserInterface instance, or an object implementing
         * a __toString method or the username as a regular string.
         *
         * @param string|object $user The user
         *
         * @throws \InvalidArgumentException
         */
        public function setUser($user)
        {
            if (!($user instanceof UserInterface || (is_object($user) && method_exists($user, '__toString')) || is_string($user))) {
                throw new \InvalidArgumentException('$user must be an instanceof UserInterface, an object implementing a __toString method, or a primitive string.');
            }
            if (null === $this->user) {
                $changed = false;
            } elseif ($this->user instanceof UserInterface) {
                if (!$user instanceof UserInterface) {
                    $changed = true;
                } else {
                    $changed = $this->hasUserChanged($user);
                }
            } elseif ($user instanceof UserInterface) {
                $changed = true;
            } else {
                $changed = (string) $this->user !== (string) $user;
            }
            if ($changed) {
                $this->setAuthenticated(false);
            }
            $this->user = $user;
        }

    https://github.com/symfony/security-core/blob/master/Authentication/Token/AbstractToken.php#L93

    craaazy19, 26 Июля 2016

    Комментарии (28)
  3. Куча / Говнокод #19746

    +5

    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
    type asynchronizer struct {
    	payload interface{}
    }
    
    func (as *asynchronizer) MarshalJSON() ([]byte, error) {
    	insert := []byte("\"async\":true,")
    	if as.payload == nil {
    		as.payload = struct{}{}
    	}
    	raw, err := json.Marshal(as.payload)
    	if err != nil {
    		return raw, err
    	}
    	if raw[1] == '}' {
    		insert = insert[:len(insert)-2]
    	}
    	return append(append(raw[0:1], insert...), raw[1:]...), nil
    }

    Чем дальше в лес, тем больше Го напоминает ПХП.

    wvxvw, 03 Апреля 2016

    Комментарии (28)
  4. C# / Говнокод #19602

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    private bool trap = false;
    public bool TrapExceptions
    {
    	get { return this.trap; }
    	set { this.trap = true; }
    }

    Выхода нет.

    yamamoto, 10 Марта 2016

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool compareArrays(int[] a,int[] b)
    	{
    		if(a.Length != b.Length)
    			return false;
    
    		for(int i = 0;i<a.Length;i++)
    			if(a[i] != b[i])
    				return false;
    
    		return true;
    	}

    Нобелевская премия по программированию

    d_fomenok, 02 Марта 2016

    Комментарии (28)
  6. C++ / Говнокод #19530

    +2

    1. 1
    if ( LIKELY( _mode == normal ))

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

    govnokoderatata, 25 Февраля 2016

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

    +7

    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
    static int[] Compute(int[] array) 
    { 
    int count = array.Length; 
    int[] result = new int[count]; 
    
    for (int i = 0, j = 0, mul = 1; i < count; ++i, j = 0, mul = 1) 
    { 
    for (; j != i; ++j) 
    mul *= array[j]; 
    
    for (++j; j != count; ++j) 
    mul *= array[j]; 
    
    result[i] = mul; 
    } 
    return result; 
    }

    Ибо нефиг писать такие шарпи у for

    d_fomenok, 11 Февраля 2016

    Комментарии (28)
  8. C# / Говнокод #19388

    −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
    float PriceByProductID(string product_id)
    	{
    		if(product_id == RUBY_PILE)
    			return 1.99f;
    		else if (product_id == RUBY_BAG)
    			return 4.99f;
    		else if (product_id == RUBY_SACK)
    			return 9.99f;
    		else if (product_id == RUBY_BOX)
    			return 19.99f;
    		else if (product_id == RUBY_CHEST)
    			return 39.99f;
    		else if (product_id == RUBY_TRUNK)
    			return 99.99f;
    		else if (product_id == GOLD_PILE)
    			return 0.99f;
    		else if (product_id == GOLD_BAG)
    			return 2.99f;
    		else if (product_id == GOLD_SACK)
    			return 7.99f;
    		else if (product_id == GOLD_BOX)
    			return 14.99f;
    		else if (product_id == GOLD_CHEST)
    			return 29.99f;
    		else if (product_id == GOLD_TRUNK)
    			return 79.99f;
    		return 0f;
    	}

    kschingiz, 03 Февраля 2016

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

    +3

    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
    /*
    =============
    TempVector
    
    This is just a convenience function
    for making temporary vectors for function calls
    =============
    */
    float  *tv (float x, float y, float z)
    {
      static  int    index;
      static  vec3_t  vecs[8];
      float  *v;
    
      // use an array so that multiple tempvectors won't collide
      // for a while
      v = vecs[index];
      index = (index + 1)&7;
    
      v[0] = x;
      v[1] = y;
      v[2] = z;
    
      return v;
    }

    LispGovno, 13 Сентября 2015

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

    +4

    1. 1
    static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };

    Это я нашел в libJPG (они там в конец двинулись сдвигать отрицательные числа)

    maxis11, 16 Августа 2015

    Комментарии (28)
  11. JavaScript / Говнокод #18540

    +1001

    1. 1
    'used strict'

    Уже "попользовался" strict

    Оригинал: https://github.com/tischenkoa/portfolio-front-end-javascript/blob/master/24_task_(Ajax_loading_comics)/loadimg.js#L4

    volter9, 27 Июля 2015

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