- 1
public static final String DOCUMENT_NUMBER_FORMAT = "******************************";
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+72
public static final String DOCUMENT_NUMBER_FORMAT = "******************************";
+144
static void Main(string[] args)
{
int[,] mas = new int[5, 5];
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
mas[i, j] = rnd.Next(0, 100);
Console.Write(mas[i, j] + "\t");
}
Console.WriteLine();
}
}
−168
private function updateIssueView () : void
{
if (_issue != null)
{
if(_issue["issue"]["wfAreaCd"] == "REFERRAL_COMMODITIES")
{
if (editComm != null) editComm.setIssue(_issue);
else callLater(updateIssueView);
}
else
{
if (editGffx != null) editGffx.setIssue(_issue);
else callLater(updateIssueView);
}
}
}
А ну создайся! Создавайся, я кому сказал! :D
+113
const string newObjectName = "Новый объект";
// формирует имя нового объекта
string BuildNewObjectName()
{
var namesTaken = from node in objectAdapters where node.Name.Contains(newObjectName) select node.Name;
int n = 0;
// ищем максимальное число в конце имени
if (namesTaken.Any())
n = namesTaken.Aggregate(n, (acc, name) =>
{
int current;
return (int.TryParse(name.Split().Last(), out current) && current > acc) ? current : acc;
});
// возвращаем следующее
return newObjectName + " " + (n+1).ToString();
}
Получение имени для нового объекта. Смесь различных техник. Не читаемо.
+74
public static int count(String s) {
int res = 0;
for (int i = 0; i < s.length(); i++) {
if(s.charAt(i) == '1') res++;
}
return res;
}
public List<VDictLiability> get(String currency_id, String usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id) {
for(int i = 0;i<5;i++){
int j = 0;
while(j < 32) {
if(count(Integer.toBinaryString(j)) == i) {
String s = Integer.toBinaryString(j);
while (s.length() != 5) {
s = "0" + s;
}
List<VDictLiability> result = get(currency_id, usedTrailer, actualDate, contract_class_id, product_id, risk_object_type_id, s);
if(result.size() > 0) return result;
}
j++;
}
}
return Collections.EMPTY_LIST;
}
public List<VDictLiability> get(String currency_id, String usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id, String mask) {
String territoryCode = App.config.getCurrentBrunchCode().substring(1, 3);
...
HashMap<Double, VDictLiability> map = new HashMap<Double, VDictLiability>();
for (VDictLiability liabilityRow : get()) {
if(!territoryType.equals(liabilityRow.getterritory_type_id()) && !(mask.charAt(4) == '1' && liabilityRow.getterritory_type_id() == null)){
continue;
}
if(actualDate != null && !CompareUtil.isInside(liabilityRow.getstart_date(), liabilityRow.getend_date(), actualDate)){
continue;
}
if(((risk_object_type_id != null && !CompareUtil.isEquals(liabilityRow.getrisk_object_type_id(), risk_object_type_id)) && !(mask.charAt(0) == '1' && liabilityRow.getrisk_object_type_id() == null))){
continue;
}
if(((product_id != null && !CompareUtil.isEquals(liabilityRow.getproduct_id(), product_id)) && !(mask.charAt(1) == '1' && liabilityRow.getproduct_id() == null))){
continue;
}
if(((contract_class_id != null && !CompareUtil.isEquals(liabilityRow.getcontract_class_id(), contract_class_id)) && !(mask.charAt(2) == '1' && liabilityRow.getcontract_class_id() == null))){
continue;
}
if((liabilityRow.getcurrency_id() != null & !CompareUtil.isEquals(liabilityRow.getcurrency_id(), currency_id)) && !(mask.charAt(3) == '1' && liabilityRow.getcurrency_id() == null)){
continue;
}
if(liabilityRow.getis_used_trailer() != SQLUtils.NULL_INTEGER_VALUE & !CompareUtil.isEquals(""+liabilityRow.getis_used_trailer(), usedTrailer)){
continue;
}
map.put(liabilityRow.getvalue(), liabilityRow);
}
ArrayList<VDictLiability> result = new ArrayList<VDictLiability>();
result.addAll(map.values());
...
return result;
}
public List<VDictLiability> get(String currency_id, boolean usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id) {
return get(currency_id, usedTrailer?"1":"0", actualDate, contract_class_id, product_id, risk_object_type_id);
}
Это ад
+82
private String addZerosToColor(String color)
{
switch(color.length())
{
case 1:
color = (new StringBuilder()).append("00000").append(color).toString();
break;
case 2:
color = (new StringBuilder()).append("0000").append(color).toString();
break;
case 3:
color = (new StringBuilder()).append("000").append(color).toString();
break;
case 4:
color = (new StringBuilder()).append("00").append(color).toString();
break;
case 5:
color = (new StringBuilder()).append("0").append(color).toString();
break;
}
return color;
}
Понятно и весьма эстетично :D
+94
if MessageDlg('Удалить проводку №'+srcTransact.DataSet.FieldByName('Trans_ID').AsString+' и ее спецификацию?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
CMD.SQL.Add('EXEC dbo.asp_DelTransact '+srcTransact.DataSet.FieldByName('Trans_ID').AsString );
CMD.Execute;
_refresh(srcTransact.DataSet);
end;
end;
Из реального проекта (учётная система).
При определённых условиях можно удалить не только то что пользователь собирался удалить :).
Да и вообще, сам код - говно.
+115
public static string GetTable(int type, string title, string[][] rows)
{
bool flag2;
int num;
bool isEmpty = false;
string str = "";
switch (type)
{
case 1:
str = str + "\r\n <div class='clear'> </div>\r\n\t\t\r\n\t\t <div class='down'>\r\n \r\n\t\t\t\t\t <div class='ProperyDetailHeading'>\r\n\t\t\t\t\t\t <span class='color2'>" + title + "</span>\r\n\t\t\t\t\t </div>\r\n\t\t\t\t\t <div class='PropertyDetailContent'>\r\n\t\t\t\t\t\t <div class='PropertyDetailInformation content_inner'>\r\n\t\t\t\t\t\t\t <table summary='Test Table'>\r\n\t\t\t\t\t\t\t\t <tbody>";
if ((rows != null) && (rows.Length > 0))
{
flag2 = true;
for (num = 0; num < rows.Length; num++)
{
if ((rows[num] != null) && (rows[num].Length > 0))
{
str = str + GetTableRow(ref flag2, rows[num][0], rows[num][1], ref isEmpty);
}
}
}
break;
case 2:
......
ASP.NET, пакистанские кодеры. Вообще весь код с сайта можна поместить на сайте отдельным разделом. В проекте вообще не используются контролы типа DataGrid/FormView.. даже DataSource. У них и тэмплэйты свои :(.. Грустно так все...(
−126
if [ "$PROJECTVERSION" -gt "1.1.0" ; then
Именно в таком виде найдено в проходящих письмах коммитницы.
−172
UTF8 = {
encode: function(str){
for(var c:String, i:Number = -1, l:Number = (str = str.split("")).length, o:Function = String.fromCharCode; ++i < l;
str[i] = (c = str[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : str[i]
);
return str.join("");
},
decode: function(str){
for(var a:Array, b:Array, i:Number = -1, l:Number = (str = str.split("")).length, o:Function = String.fromCharCode, c:String = "charCodeAt"; ++i < l;
((a = str[i][c](0)) & 0x80) &&
(str[i] = (a & 0xfc) == 0xc0 && ((b = str[i + 1][c](0)) & 0xc0) == 0x80 ?
o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), str[++i] = "")
);
return str.join("");
}
};
Это чудо народного зодчества было предложено в качестве конвертора из ASCII в UTF8 и обратно. Проблема осложняется тем, что человек так делает в полной уверенности, что он что-то соптимизировал. (Ну и конечно, китайцы со своими иероглифами, как всегда в пролете, а так же французы со своими диакритиками, поляки, немцы и т.д.). То что страдает типизация и инкапсуляция, просто меркнет перед форматированием и полным отсутствием здравого смысла.
http://www.kirupa.com/forum/showthread.php?t=351816