- 1
- 2
- 3
- 4
public string GetRegion(CallContext context)
{
return "Регион";
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+6
public string GetRegion(CallContext context)
{
return "Регион";
}
+6
using System;
namespace Colculator
{
public partial class Form1 : Form
{
bool BOOL = {
true,true,true,true,true,true,true,false};
if(BOOL(new Random(1,8)){
Consosle.WriteLine("ДА");
}
Так делать нельзя!!!
+1
if ( text.Contains( "лет" ) || text.Contains( "год" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddYears( -Int32.Parse( match.Value ) );
}
else if ( text.Contains( "дн" ) || text.Contains( "ден" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddDays( -Int32.Parse( match.Value ) );
}
else if ( text.Contains( "месяц" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddMonths( -Int32.Parse( match.Value ) );
}
else if ( text.Contains( "час" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddHours( -Int32.Parse( match.Value ) );
}
else if ( text.Contains( "недел" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddHours( ( -Int32.Parse( match.Value ) ) * 7 );
}
else if ( text.Contains( "минут" ) )
{
var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
if ( !match.Success )
return null;
var date = DateTime.UtcNow;
return date.AddMinutes( -Int32.Parse( match.Value ) );
}
return null;
Копипаста >_< До кучи ещё и с классической copy-paste ошибкой в логике.
−1
if (p != null)
{
Thread thread = new Thread(() =>
{
StaffList.App.Controls.Personal.PersonRec rec = new Controls.Personal.PersonRec();
rec.DataContext = p;
rec.Mode = StaffList.Controls.OperatingMode.Show;
var win = new BaseWindow();
win.Form = rec;
win.ShowDialog();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
Это мы так делаем немодальные окна.
+10
public static string toFormat(string s, int u)
{
return " ".Substring(0, u * 4) + s +"\r\n";
}
Функция используется для форматирования файла класса, созданного автоматически.
+2
if (t.IsFaulted)
{
try
{
throw t.Exception.InnerException;
}
catch (ObjectDisposedException)
{
Dispose();
return;
}
...
}
−1
public async Task AddOrUpdateAsync<T>(string key, T value) where T : class
{
ConcurrentQueue<T> queue = null;
await Task.Run(() =>
{
var cacheItem = _cache.GetCacheItem(key);
if (cacheItem != null)
{
queue = cacheItem.Value as ConcurrentQueue<T>;
}
});
await Task.Run(() => queue.Enqueue(value));
}
типа кусок из добавления нового элемента в кэш. Стильно, модно, асинхронно!
−1
private bool IsDriverSuccessfullyInstalled(DriverInfo di, string historyDriverVersion, string historyPackageVersion)
{
bool flag = false;
if (!string.IsNullOrWhiteSpace(di.VersionAfterInstallation) && !string.IsNullOrWhiteSpace(di.VersionAfterInstallation) && new Version(di.VersionAfterInstallation).CompareTo(new Version(di.VersionBeforeInstallation)) >= 0)
flag = true;
return flag;
}
При попытке поставить драйвер интеловской видюхи инсталлер вывалился с ArgumentNullException. Декомпильнул его и увидел вот это.
Копипаста головного мозга.
−2
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Collections.ObjectModel;
using System.Linq;
namespace DemoFeb2014.DataContexts
{
using System;
using System.Collections.Generic;
public partial class Author
{
....
public ICollection<Tuple<MusicalWork, string>> Author2MusicalWorkParsed
{
get
{
...
}
}
}
}
Спасибо коллегам! Благодаря только им можно потратить полчаса времени на розыск коммита в котором пропал метод Author2MusicalWorkParsed и выяснения причин того, почему же он пропал...
Видимо комментарии в начале файла недостаточно "жирные".
+7
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