Many suggested edits just consist in indenting some lines by four spaces (and sometimes add a padding blank line before).

Would it be possible to automatically approve such edits? In almost all cases it is just code formatting.

  • I dunno, I think that may leave you exposed...
    – user1228
    May 13, 2011 at 13:20
  • @Will don't give a♦: You cheated, you inserted text instead of indenting it. So that does not count.
    – Benoit
    May 13, 2011 at 13:38
  • lol you're right. I see what you meant there. However...
    – user1228
    May 13, 2011 at 13:40
  • @Will don't give a♦: And then do you think that so many people will do the latter when it is not needed?
    – Benoit
    May 13, 2011 at 13:41
  • 4
    Just the trolls.
    – user1228
    May 13, 2011 at 13:42

2 Answers 2



Simple method for reliably detecting code in text?

We just deployed a method that we think is quite reliable for blocking 98% of posts submitted with code that has improper code formatting (or no code formatting at all).

For example, when I go into Chrome incognito and attempt to ask this question body on Stack Overflow right now:

I needed to add up all the rows for a result. Using the select_sum as follows

Here is the model

function Dues_Paid_Tot($date)
        $query = $this->db->select_sum('Dues_Paid', 'Dues_Paid_Tot');
        $query = $this->db->get('Membership');
        return $query->result();

Here is the controller

function Fiscal2()
    $date = $this->input->post('Select_Date');
        if($query = $this->report_model->fiscal_list($date))
            $data['records'] = $query;
    $data['date'] = $this->input->post('Select_Date');
    $data['Dues_Paid_Tot'] = $this->report_model->Dues_Paid_Tot($date);
    $data['main_content'] = 'report_fiscal_view';
    $this->load->view('includes/template', $data);

I get back:

Oops! Your question couldn't be submitted because:

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

This check is limited to users with <= 50 reputation and is performed on questions / answers / edits and suggested edits.

If you see or hear of any cases where this is triggered inappropriately -- or not triggered, and it should have been -- let us know.

  • 3
    I'm sure Meta will soon be flooded with people whining about this.. :) Jul 14, 2011 at 9:22

I don't think code edits should be treated any differently from any other edits. Just because somebody has entered an extra blank line / a bunch of spaces, doesn't mean that the code appearance has actually been improved, or was necessary. The race to fix newly asked questions can already turn into a bun fight, where people try to get their small change in, before somebody else edits the post rather than editing the whole thing in one sweep.

If you did go down this route, the least you would have to do is remove any rep gain from automated approvals, to remove the likelihood of gaming the system by going round inserting 4 spaces one line at a time to random code samples around the site...

  • do you gain reputation when an edit you make has been approved?
    – Benoit
    May 13, 2011 at 13:40
  • 1
    @Benoit You gain +2 reputation, up to a maximum of +1000 reputation in total, for each approved edit you make.
    – Grace Note StaffMod
    May 13, 2011 at 13:43
  • So in this case, disabling reputation gain for such edits would of course be a good thing
    – Benoit
    May 13, 2011 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .