- 1
List<KeyValuePair<string, string>> documentList = GetList();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 14
+130
List<KeyValuePair<string, string>> documentList = GetList();
использование списка пар ключ-значение вместо словаря (Dictionary<string, string>)
+114
//request.IsSecureConnection и TargetHttps - булевы переменные
if (!(request.IsSecureConnection ^ TargetHttps))
вместо if (request.IsSecureConnection == TargetHttps)
−162
/*здесь было много кода*/
DECLARE @Strings TABLE /* in this temporary table we keep all strings, even the names of the elements, since they are 'escaped' in a different way, and may contain, unescaped, brackets denoting objects or lists. These are replaced in the JSON string by tokens representing the string */
(
String_ID INT IDENTITY(1, 1),
StringValue NVARCHAR(MAX)
)
SELECT--initialise the characters to convert hex to ascii
@characters='0123456789abcdefghijklmnopqrstuvwxyz',
/* firstly we process all strings. This is done because [{} and ] aren't escaped in strings, which complicates an iterative parse. */
@parent_ID=0;
WHILE 1=1 --forever until there is nothing more to do
BEGIN
SELECT
@start=PATINDEX('%[^a-zA-Z]["]%', @json collate SQL_Latin1_General_CP850_Bin);--next delimited string
IF @start=0 BREAK --no more so drop through the WHILE loop
IF SUBSTRING(@json, @start+1, 1)='"'
BEGIN --Delimited Name
SET @start=@Start+1;
SET @end=PATINDEX('%[^\]["]%', RIGHT(@json, LEN(@json+'|')-@start) collate SQL_Latin1_General_CP850_Bin);
END
IF @end=0 --no end delimiter to last string
BREAK --no more
SELECT @token=SUBSTRING(@json, @start+1, @end-1)
--now put in the escaped control characters
SELECT @token=REPLACE(@token, FROMString, TOString)
FROM
(SELECT
'\"' AS FromString, '"' AS ToString
UNION ALL SELECT '\\', '\'
UNION ALL SELECT '\/', '/'
UNION ALL SELECT '\b', CHAR(08)
UNION ALL SELECT '\f', CHAR(12)
UNION ALL SELECT '\n', CHAR(10)
UNION ALL SELECT '\r', CHAR(13)
UNION ALL SELECT '\t', CHAR(09)
) substitutions
SELECT @result=0, @escape=1
--Begin to take out any hex escape codes
WHILE @escape>0
BEGIN
SELECT @index=0,
--find the next hex escape sequence
@escape=PATINDEX('%\x[0-9a-f][0-9a-f][0-9a-f][0-9a-f]%', @token collate SQL_Latin1_General_CP850_Bin)
IF @escape>0 --if there is one
BEGIN
WHILE @index<4 --there are always four digits to a \x sequence
BEGIN
SELECT --determine its value
@result=@result+POWER(16, @index)
*(CHARINDEX(SUBSTRING(@token, @escape+2+3-@index, 1),
@characters)-1), @index=@index+1 ;
END
-- and replace the hex sequence by its unicode value
SELECT @token=STUFF(@token, @escape, 6, NCHAR(@result))
END
END
--now store the string away
INSERT INTO @Strings (StringValue) SELECT @token
-- and replace the string with a token
SELECT @JSON=STUFF(@json, @start, @end+1,
'@string'+CONVERT(NVARCHAR(5), @@identity))
END
парсинг json-строки sql скриптом. полная версия тут : https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/
+114
EventTypeId = (int)Enum.Parse(typeof(AmazonMailingLogEventType), Enum.GetName(typeof(AmazonMailingLogEventType), AmazonMailingLogEventType.SendEmailError))
вместо
EventTypeId = (int)AmazonMailingLogEventType.SendEmail Error
+140
try
{
client.SendData(xml);
}
catch(Exception e)
{
string s = e.ToString();
if(s.Substring(0,80)=="System.InvalidOperationException: Operation not allowed on non-connected sockets")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else if (s.Substring(0,71)=="System.IO.IOException: Unable to write data to the transport connection")
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
else
{
client.tcpclient.Close();
clients.Remove(client.SessionId);
}
}
нестандартное определение типа исключения
найдено в примерах кода кандидата на работу
+125
int code = 300;
if (
ex is Exceptions.ApiErrorNotFoundException ||
ex is Exceptions.CardAuthHistoryNotFoundException ||
ex is Exceptions.CardNotFoundException ||
ex is Exceptions.CardStateNotFoundException ||
ex is Exceptions.CurrencyNotFoundException ||
ex is EmailTemplateNotFoundException ||
ex is Exceptions.ExchangeRateNotFoundException ||
ex is Exceptions.InfoBlockNotFoundException ||
ex is InvoiceNotFoundException ||
ex is Exceptions.InvoiceStateNotFoundException ||
ex is Exceptions.ManagerNotFoundException ||
ex is Exceptions.PasswordRecoveryNotFoundException ||
ex is Exceptions.PayCommissionNotFoundException ||
ex is Exceptions.PaymentStateNotFoundException ||
ex is Exceptions.PaymentTypeNotFoundException ||
ex is Exceptions.PaySystemNotFoundException ||
ex is Exceptions.PersonNotFoundException ||
ex is Exceptions.SecretWordNotFoundException ||
ex is ShopNotFoundException ||
ex is SiteNotFoundException ||
ex is Exceptions.SysSettingsNotFoundException ||
ex is Exceptions.SysWalletNotFoundException ||
ex is Exceptions.TariffNotFoundException ||
ex is Exceptions.UserNotFoundException ||
ex is Exceptions.UserParamsNotFoundException ||
ex is Exceptions.WorldCurrencyNotFoundException ||
ex is Exceptions.WorldExchangeRateNotFoundException
)
{
code = 504;
}
+143
</body></html></div><!-- generation time = <b>362</b> ЛЯ -->
не говнокод, просто лучик ненависти верстальщика
+114
public partial class Chat : System.Web.UI.Page
{
...
private List<string> Messages
{
get { return (List<string>)Cache["messages"]; }
set { Cache.Insert("messages", value); }
}
protected void btnAddMessage_Click(object sender, EventArgs e)
{
if (this.Messages != null)
{
this.Messages.Add(string.Format("{0} say :{1}\n", this.UserName, tbUserMessage.Text));
// wai... oh shi---
this.Messages = this.Messages;
}
}
}
+144
// TODO: Rewiew
// ...
жопой чую, что ниже этих строк - пиздец
+172
function getCodeByCode(code)
хорошее название функции