5

Tl;Dr: Make use of the Ask question warnings to reduce the misuse of Stack Snippets. Automatically run it in the background when the user click the "Review your questions button", if there is an error then show a warning.


On I often find questions using with obvious mistakes

  • Added JavaScript in the HTML section
  • Added HTML in the JavaScript section

Based on posts from 2014 and probably other more recent, other tags that might commonly have questions using Stack Snippets with obvious mistakes that aren't the subject of what is being asked.

Another misuse that might appear nou so obviou but that might be easily caught by running the Stack Snippet, is using non standard methods without including the corresponding API or that belong to an unsupported platform, i.e. Google Apps Script methods like SpreadsheetApp.getActiveSpreadsheet().

I think that the frequency of mistakes like these could be reduced without having to invest too much on / / by making use to the / / features when a question is composed.

One "crazy idea" is to automatically trigger the Stack Snippet "run" button in the background and showing a warning if there was an error thrown.


While reviewing this feature request it might be worthy to consider consider the implications of showing warnings when

  • , or aren't included based just on the Stack Snippet code blocks used... i.e., it the HTML block has any content show a warning if the is missing.
  • the HTML section isn't empty but doesn't include HTML tags but include very typical JavaScript script estatements patterns like variable declarations, i.e. line starting with
    • var, let, const followed by a word followed by a =.
    • class followed by word followed by {.
    • function followed by a word, followed by (, ), {.
  • the JavaScript section isn't empty but include very typical HTML patterns like
    • a line starting < followed by a word, followed by one of more typical attributes, id, href, src, and ending with >.

Something "easier" to implement from a coding perspective but not from the overall solution development perspective as it will require to involve a larger team be is to make that the "Ask Question Wizard" asks the OP to run the Stack Snippet and fix any error before posting the question unless that the purpose of the code is to show the error. For first time askers, show a warning if there was an error.


Related

Related

7
  • 3
    I know there are cases where a snippet will throw an error because that's what OP wants to show. However, I think there are vastly more cases when askers just drop some code in a snippet even though it's not even meant to be runnable. Reducing the latter usages would be a huge improvement.
    – VLAZ
    Oct 20, 2022 at 9:59
  • 3
    I don't think SO cares all that much about Stack Snippets, frankly. The author of the original script which handles the console has made many meaningful improvements in the intervening years that have not been merged. Look in the Related list to the right (or below) and see a few of the requests that have been ignored since they were introduced. I regularly edit snippets out of questions that use them incorrectly, or for code that does nothing when run (like showing JSON, or CSS with no HTML). It's an uphill battle... Oct 20, 2022 at 14:02
  • @HereticMonkey A good example of those improvements: Stack Snippets Console can't output ES6 data types
    – zcoop98
    Oct 20, 2022 at 19:46
  • Isn't the real issue that these users found it easier to use StackSnippets than the proper code blocks? Wouldn't a better solution then be to provide a better interface to produce the proper code blocks? Trying to automatically detect if one did intentionally and properly use StackSnippets is meant to fail in some ways. For instance, I sometimes do post answers with only text nodes in the the HTML section, e.g because the rest of the DOM will be populated by JS. Not to mention that trying to check what's really in each form is far from being trivial.
    – Kaiido
    Oct 24, 2022 at 1:30
  • Thanks for your reply @Kaiido. Please tell us more about that better interface for code blocks.
    – Rubén
    Oct 24, 2022 at 1:53
  • Sorry, I don't work for SO. I'm just noting that you found a problem: Some people are misusing a feature instead of another one. You are proposing Let's make that feature auto-detect when it's being misused, I'm proposing Let's make that "another" feature more accessible so that they don't misuse this one instead. To improve it would require some analysis about why these users preferred to use StackSnippets instead of code-blocks, and based on this analysis's results, SO should fix what needs to be fixed. Maybe a more prominent button, maybe a more IDE like UI, maybe something else?
    – Kaiido
    Oct 24, 2022 at 2:01
  • @Kaiido. I edited the question Your proposal looks to be worthy to be mentioned in relation to staging-ground. Please let me know if you make a post about it.
    – Rubén
    Oct 24, 2022 at 13:06

0

You must log in to answer this question.