Sublime Forum

Bug with JS indentation

#1

Friend from team sent me bug, he ignored it, but I wonna report it to you.

We have socket.io app in node.js and he wrote code to send 2 localized messages to users and few lines below that code he’s editor (Sublime Text 3) made mistake.

[code]io.on(‘connection’, function (socket) {
socket.on(‘join room’, function(data) {
if(getRoomData(data.room).banned_users.indexOf(socket.username) > -1) {
socket.emit(‘new message’, {
username: ‘chat system’,
message: ‘začítzač ítzač ítzačítz ačítzačít začítzačítzačítzačít můzačítzačítzačítžeš začít’
});
}
socket.join(data.room);
socket_rooms.push(data.room);

	var room_data = getRoomData(data.room);
	if(!(socket.username == 'guest')) {			
		room_data.users.push(socket.username);
		io.to(data.room).emit('user joined', {username: socket.username});

		touch_room(data.room, socket);
	}	

	socket.emit('new message', {username: 'chat system', message: 'Joined ' + data.room});

	room_data.chat_history.forEach(function(message_obj) {
		socket.emit('new message', message_obj);
	});
	if(socket.username == 'guest') 
		socket.emit('new message', {
			username: 'chat system',
			message: 'začítzač ítzač ítzačítz ačítzačít začítzačítzačítzačít můzačítzačítzačítžeš začít začítzačítzačítzačítzačítzačítzačítzačítzačít'
		});
});

socket.on(‘ban’, function(data) {
if(socket.username == socket_rooms[0]) {
getRoomData(socket_rooms[0]).banned_users.push(data.username);
}
});
});[/code]

Line 32 (6th from bottom) should be indented 1 tab to right and following lines too. I changed localized text to one repeated random word, because we wonna be “transparent” with this project (NDA written).

0 Likes