35

I am a new approver for the Suggested Edits review queue.

After going through several of them yesterday; I found that 3 to 4 of them were just suggestions either to add or remove Stack Snippets from the post. Nothing else.

I had to skip them as I was not aware of the guidelines on this. I tried to find something in the help center or on meta. But could not find.

Could someone please shed some light on this?

6
  • 40
    If a Stack Snippet has been erroneously used in a question where it cannot possibly apply (like one tagged C++), then it should be removed. Unfortunately, I see this fairly frequently, and as someone who doesn't work in webby languages, Stack Snippets are more of an annoyance to me than a benefit. Yes, please approve edits that fix this plague. I don't otherwise know what kind of "guidelines" you're looking for. Ask yourself: "does this edit substantially improve the overall quality of the post?" If so, approve. If not, reject.
    – Cody Gray Mod
    Commented May 2, 2017 at 10:16
  • 5
    @cody - that comment looks like it could usefully be an answer... Commented May 2, 2017 at 10:21
  • 14
    @CodyGray even in "webby languages", most snippets are a nuisance rather than a feature. There are lots of ways to create a broken snippet - not including required libraries, having <img>s with relative URLs that obviously 404 when on Stack Overflow, putting SCSS into the CSS section, and so on - and trust me, question askers manage to do them much more often than they manage to get it right. Meanwhile, there are swathes of suggested editors who will blindly turn (perfectly fine) non-snippet code blocks into blatantly broken snippets, and reviewers ready and willing to approve those edits.
    – Mark Amery
    Commented May 2, 2017 at 11:02
  • 7
    Not a webby guy either, but if snippets are misused that often, maybe make them a low-rep privilege like inline pictures? Maybe people read the privilege description when they earn it so we can tell them what not to do.
    – Baum mit Augen Mod
    Commented May 2, 2017 at 11:06
  • @BaummitAugen that would also have the effect that more people are aware that stack snippets exist and what they are. I was not until I have seen people talking about it on meta.^^" My bad.
    – Rhayene
    Commented May 2, 2017 at 11:21
  • 6
    @BaummitAugen Or maybe warn people when they're using a stack snippet and the question isn't tagged as JavaScript, HTML, or CSS?
    – Ajedi32
    Commented May 2, 2017 at 20:37

2 Answers 2

36

Edits adding a snippet

If the snippet demonstrates the issue the OP is asking about when you click Run code snippet, approve. If not, reject.

Edits removing a snippet

If the snippet demonstrates the issue the OP is asking about when you click Run code snippet, reject. If not, it's more complicated:

  • If the snippet contains invalid content, approve. Examples:

    • Something that isn't HTML in the HTML panel, including PHP tags.
    • Something that isn't JavaScript in the JavaScript panel, including TypeScript or CoffeeScript or similar unless a client-side transpiler has also been correctly included.
      Note 1: JavaScript has been changing a lot lately, some modern JavaScript doesn't look much like JavaScript from five years ago.
      Note 2: React snippets may well contain what looks like invalid JavaScript in the form of JSX, but provided the Babel checkbox is checked, that's fine (details here).
    • Something that isn't CSS in the CSS panel, including Less or Sass.
  • If the snippet could be reasonably edited to demonstrate the issue the OP is asking about (for instance, it's missing a library that could readily be added) but just hasn't been, I would lean toward reject on the basis that it doesn't improve anything to go backward. But this would be vary case-by-case. The right thing where possible, of course, would be to add the missing things.

Edits editing a snippet

(Just for completeness.)

Pretty much like any other edit: If it's an improvement, approve; if not, reject.

For example:

  • If the original snippet didn't demonstrates the problem and the new one does, approve.
  • If the original snippet demonstrated the problem and the new one doesn't, reject.
  • If the snippet should have just been removed (see above — wrong languages, etc.), reject.
  • If the original snippet didn't didn't demonstrate the problem, and the new one doesn't either, but the edit improves it in some way (formatting, adding missing library, etc.), approve; if not, reject.
9
  • 2
    There is a third category: edits editing a snippet. Not sure if the question is about those. In any case, I approve of suggested edits that add missing external libraries and/or stylesheets. When a suggested edit introduces a snippet, but misses something small that breaks it (for example, not referencing an external library), I like to improve the edit accordingly to make it run. Commented May 2, 2017 at 14:33
  • 14
    This is fairly comprehensive, but I just want to point out explicitly - Stack Snippets only support HTML, CSS, and JavaScript (and JS libraries that are properly linked and supported within the Snippet). Questions with code in any other language should not have a Stack Snippet (like C++, Python, Java, Lua, Haskell, etc.). Likewise, a question that does not have enough code to produce an output (e.g. if the code is only CSS, or if it is JavaScript that edits markup without actually including said markup in the HTML section) should not be in a runnable Stack Snippet.
    – TylerH
    Commented May 2, 2017 at 14:59
  • 1
    Also, HTML that is tangentially related to the question should not be put in a snippet. (I may still be a little sore.) For example, questions about Pug probably don't need a snippet to display the output (example). Commented May 2, 2017 at 16:10
  • Also a small pedantic comment about the "doesn't run" thing: since questions are usually about "why doesn't my code work", snippets that produce no output (or malformed output) can easily be what the OP did intend to show! So any edit to a snippet that makes it run properly should be scrutinised carefully to see if it shouldn't be rejected as "attempt to answer".
    – Mr Lister
    Commented May 4, 2017 at 12:04
  • 1
    @MrLister: I'll clarify. "Doesn't run" means exactly taht: Doesn't run. At all. As opposed to running, incorrectly, demonstrating the problem the OP is asking about. Commented May 4, 2017 at 12:05
  • @MrLister: Didn't need "runs and demonstrates" at all, really, did I? Fixed. :-) Commented May 4, 2017 at 12:10
  • But was with any other edits. If there are other things that obviously need to be improved in the question and the editor does not do those things and only removes the stack snippet then I tend to Reject and Edit and make those improvements as well.
    – Dijkgraaf
    Commented May 4, 2017 at 23:46
  • 1
    My take as one who OFTEN try to help newcomers not getting scared off by their question massively being voted down: I convert code to snippet, especially when the new OP posts 2 or 3 (poorly) formatted sets of html, JS and CSS. I ALSO convert to a snippet that may or may not be runnable and ask OP to complete the snippet to make a [mcve] of said snippet. In most cases they do, and everybody is happy. In some cases they do not and then I may be told off for creating the snippet in the first place. I will still try to help a user update a question instead vote down for missing information
    – mplungjan
    Commented Sep 9, 2022 at 10:21
  • 1
    @mplungjan - FWIW, I think you're spot-on there. Commented Sep 9, 2022 at 10:26
6

Unfortunately, there is an ongoing epidemic in which users (sometimes with a decent reputation) add/use Stack Snippets even when it's obvious that they never intended to present code that runs.

This is an uncomplicated case for which a suggestion to remove should clearly be accepted – and a suggestion to add should be rejected.
Here is such an example that I just edited.

For other cases, see this well-written answer.

You must log in to answer this question.

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