- 1
return ('3');
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−55.2
return ('3');
Возвращаем код ошибки.
+161.9
function checkAllRemarks()
{ // ЧТО ЭТО!?!?!?!?17СЕМНАДЦАТЬ!!!!1111
for (i = 0; i < document.getElementsByTagName("input").length; i++)
{
if (document.getElementsByTagName("input")[i].name.split("|").length>=2)
{
if (document.getElementsByTagName("input")[i].name.split("|")[0]=="CBR")
{
if (document.getElementsByTagName("input")[i].name.split("|")[1].length==36)
{
if (document.getElementsByName("allRemarks")[0].checked == true)
document.getElementsByTagName("input")[i].checked = true;
else
document.getElementsByTagName("input")[i].checked = false;
}
}
}
}
}
Много кривого кода я видел на работе, но глядя на эту функцию я не мог не поразиться.
+133.9
switch (aDataType.FullName)
{
case "System.SByte":
case "System.Int16":
case "System.Int32":
case "System.Int64":
case "System.Single":
case "System.Double":
case "System.Decimal":
case "System.DateTime":
_IsNumeric = true;
break;
case "System.String":
_IsNumeric = false;
break;
default:
throw new ArgumentException("Not supported field data type: " +
aDataType.FullName, "aDataType");
}
Не надо хардкодить названия типов
+142
echo $search;
$result = mysql_query ("SELECT id,title,description,date,author,view,mini_img FROM data WHERE MATCH(text) AGAINST('".$search."')");
+48
while( !InputFileStream.atEnd() )
{
QString Qstrtmp;
InputFileStream >> Qstrtmp;
ReadButton.bTag = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
InputFileStream >> Qstrtmp;
ReadButton.iTag = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
InputFileStream >> Qstrtmp;
ReadButton.Popup = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
ReadButton.PartitionId = *iVar;
this->Buttons.push_back( ReadButton );
}
Код взят из совместного проекта 5-ти студентов.
Это был начальный период нашего изучения Qt.
+70.9
import javax.microedition.lcdui.*;
import java.lang.*;
import java.io.*;
public class LNRES
{
public InputStream is=null;
public String lines[]=null;
LNRES(String name,int size)
{
int x=0;
is=getClass().getResourceAsStream(name);
byte mb[]=new byte[size];
try { x=is.read(mb); } catch (Exception ex) { }
char mc[]=new char[x];
for (int i=0; i<x; i++) mc[i]=(char)mb[i];
int n=0,a=0,l=0;
String mas2[]=null;
for (int i=0; i<mc.length; i++) {
if ((mb[i]==13)||(i==mc.length-1)) {
mas2=new String[n+1];
for (int j=0; j<n; j++) mas2[j]=new String(lines[j]);
mas2[n]=new String(mc,a,l+((i==mc.length-1)?1:0)); n++; lines=new String[n];
for (int k=0; k<n; k++) lines[k]=new String(mas2[k]);
a=i+2; l=0; i++;
} else l++;
}
lines=new String[n];
for (int i=0; i<n; i++) lines[i]=new String(mas2[i]);
}
}
Писалось под j2me. Класс считывает весь файл и превращает его в массив строк.
−95.4
@ids.each_index do |di|
if @ids[di] then
@ids[di].each_index do |li|
@employ[di][li] = Hash.new
@employ[di][li][:subject] = Subject.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:subject_id]
}")[:title] if @ids[di][li]
@employ[di][li][:class] = SchoolClass.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:school_class_id]
}")[:number].to_s +
SchoolClass.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:school_class_id]
}")[:letter] if @ids[di][li]
@employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
}")[:name] + ' ' +
@employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
}")[:surname] + ' ' +
@employ[di][li][:teacher] = Teacher.find(:first, :conditions => "id = #{
Lesson.find(:first, :conditions => "id = #{@ids[di][li]}")[:teacher_id]
}")[:patronymic] if @ids[di][li]
end
end
end
Небольшая утренняя ревизия кода раскрыла заговор по свержению власти и захвату мозга остальных кодеров проекта.
Сидим, рефакторим.
+62.7
class UglyColumnsRedefine < ActiveRecord::Migration
def self.up
change_column :variable_sets, :active, :boolean
VariableSet.all.each{|v| v.update_attribute :active, !!v.active}
end
def self.down
end
end
Миграция с весёлым названием 20090601130619_ugly_columns_redefine.rb, для рельсового приложения, аля "так делать низя".
−105.1
def init_images():
rect = [[0,0],[0,0],[0,0],[0,0],[0,0]]
image = [[0,0],[0,0],[0,0],[0,0],[0,0]]
rect[0][0], image[0][0]=load_image('box.png')
rect[0][1], image[0][1]=load_image('box.png')
rect[1][0], image[1][0]=load_image('fpoint.png')
rect[1][1], image[1][1]=load_image('freefpoint.png')
rect[2][0], image[2][0]=load_image('spoint.png')
rect[2][1], image[2][1]=load_image('freespoint.png')
rect[3][0], image[3][0]=load_image('fbox.png')
rect[3][0], image[3][0]=load_image('fbox.png')
rect[4][0], image[4][0]=load_image('sbox.png')
rect[4][1], image[4][1]=load_image('sbox.png')
return image, rect
Процедура загрузки изображений. Т.к. программа писалась через силу (мозги не работали), получались вот такие жуткие куски кода...
+158.8
function h_circle_1_view() {
document.getElementById("circle_1").style.display = "block";
document.getElementById("circle_2").style.display = "none";
document.getElementById("circle_3").style.display = "none";
document.getElementById("circle_4").style.display = "none";
document.getElementById("circle_5").style.display = "none";
}
function h_circle_1_none() {
document.getElementById("circle_1").style.display = "none";
}
function h_circle_2_view() {
document.getElementById("circle_1").style.display = "none";
document.getElementById("circle_2").style.display = "block";
document.getElementById("circle_3").style.display = "none";
document.getElementById("circle_4").style.display = "none";
document.getElementById("circle_5").style.display = "none";
}
function h_circle_2_none() {
document.getElementById("circle_2").style.display = "none";
}
function h_circle_3_view() {
document.getElementById("circle_1").style.display = "none";
document.getElementById("circle_2").style.display = "none"; // прячем 1, 2
document.getElementById("circle_3").style.display = "block"; // показываем 3
document.getElementById("circle_4").style.display = "none";
document.getElementById("circle_5").style.display = "none";
}
function h_circle_3_none() {
document.getElementById("circle_3").style.display = "none";
}
function h_circle_4_view() {
document.getElementById("circle_1").style.display = "none";
document.getElementById("circle_2").style.display = "none";
document.getElementById("circle_3").style.display = "none"; // прячем 1, 2
document.getElementById("circle_4").style.display = "block"; // показываем 3
document.getElementById("circle_5").style.display = "none";
}
function h_circle_4_none() {
document.getElementById("circle_4").style.display = "none";
}
function h_circle_5_view() {
document.getElementById("circle_1").style.display = "none";
document.getElementById("circle_2").style.display = "none";
document.getElementById("circle_3").style.display = "none"; // прячем 1, 2
document.getElementById("circle_4").style.display = "none"; // показываем 3
document.getElementById("circle_5").style.display = "block";
}
function h_circle_5_none() {
document.getElementById("circle_5").style.display = "none";
}
Натолкнулся вот при тестировании одного проекта