43
\$\begingroup\$

I can understand that sometimes questions are closed as being too opinionated, too broad, or unclear, but my question was closed as being off-topic. I have read the On-Topic Help Center page for Code Review, but more detail would be useful.

I see there are a number of sub-reasons for being off-topic:

When questions are closed with these reasons, what does it mean, and what can I do?

\$\endgroup\$
0

5 Answers 5

37
\$\begingroup\$

If your question contains code that doesn't work as intended…

If your question contains something like:

  • ... runs ...but it gives the wrong answer...
  • ...I tried ... but sometimes...
  • ...works great when I do ..., but when I do ...
  • ...it works fine, but I also need it to do ...
  • ...it fails a test case... (**unless that test case is a performance test)

then your code does not work in the way that you expect, or need.

Special note about code that produces the correct results, but runs slower than expected/required in a challenge or competition: if this is the only failing test case then these questions are on-topic, but use the tag .

Broken code is code that:

  • cannot possibly compile even if other dependencies are included
  • fails to run (crashes, throws exceptions, core-dumps, segfaults, etc.)
  • produces results that are obviously incorrect (fails unit test cases, etc.)

Please don't be offended that we put your question on hold. In our experience, Code Review answers can be much more productive when the code is working correctly. Putting the question on hold gives you a chance to fix obvious problems. Once answers start rolling in, you will no longer be allowed to alter the code in the question, since it would be unfair for reviewers to evaluate a moving target.

The most straightforward action would be for you, the author of the question, to edit the question to fix the bug(s).

After you edit the question, it will be automatically put into a queue where other users will vote to reopen it, if they consider the code to be in a working state. You shouldn't need to flag a moderator to request reopening. If your question hasn't been reopened in a few hours, it is likely that other users still consider your code to be broken.

If your question was improperly closed because we misinterpreted your question, edit the question to clarify your intentions.

Resources that may be useful

  • If you are trying to solve a common problem, try searching to see if a similar question has already been asked on Code Review.
  • You may find Stack Overflow to be a useful resource in fixing your bug. First, try searching to see if a similar question has already been asked on Stack Overflow. Note, however, that simply reposting the same question to Stack Overflow will likely result in a rejection there as well. (A good Stack Overflow question would typically include a simplest possible example that reproduces the bug, explain the expected behaviour, and state the unexpected results. You shouldn't post your entire program and ask strangers to help you debug it for you.)
\$\endgroup\$
0
31
\$\begingroup\$

If your question is not real code…

Unlike other Stack Exchange sites, which encourage general reference questions and offer broadly applicable answers, Code Review aims to offer customized advice specific to your code. To make that work, we need to see real code.


If your question was asking for a review of pseudocode, then we need you to post an implementation in a real programming language. Some specific cases of pseudocode include:

  • If your question was about regular expressions in general, then please pick a specific programming language (e.g. ) and tag the question accordingly. Regular expressions differ significantly between programming languages.
  • If you are asking about a code excerpt that might be or or , we need you to pick a language and tag the question accordingly. Even if you think that the question is generic, reviewers might offer different advice depending on the language.
  • If you are asking to review code in a language for which a specification exists but for which there is no interpreter or compiler implemented, then Code Review is not the place to ask.

If your question contains stub code, then there are significant pieces of the core functionality missing, and we need you to fill in the details. Excerpts of large projects are fine, but if you have omitted too much, then reviewers are left imagining how your program works.


If your code was deemed to be example code, too hypothetical to be meaningfully reviewed, then we need you to provide concrete details.

  • Remove any hedging language such as "Suppose I have code like…" and "For example…" from your question.
  • Replace generic identifiers such as foo and MyClass with something that would plausibly appear in a real, useful program.
  • Sometimes, authors are unable to post real code due to employers' confidentiality policies. In that case, consider fabricating a related realistic program that looks plausibly useful. In other words, instead of omitting details that you can't reveal, make up details instead. (When we point out issues with your fabricated example, just play along. Please don't reply with "what if…" comments.)
\$\endgroup\$
0
25
\$\begingroup\$

If your question contains someone else's code…

For moral, practical, and legal reasons, we are only able to review code that you wrote or code that you maintain. Code Review is not the place to ask about someone else's code.

We also expect you to understand how your code works. If you are seeking an explanation of how your code works, then we will treat the question as if someone else wrote it.

Resources that may be useful

  • If you are not seeking to improve the code, but rather just to understand how it works, you may be able to ask a question on Stack Overflow. A good question should mention what the observed behaviour is, and why your expectations differ.
\$\endgroup\$
24
\$\begingroup\$

If your question does not include the code to be reviewed…

Please embed the code to be reviewed directly in the question, for multiple reasons, including quality and licensing.

You may optionally also link to a third-party site where your programming project is hosted, but the question must contain enough code to stand on its own.

There is a length limit of 65536 characters, but we encourage you to keep your questions much shorter than that. If your question is too long, you can either break it up into several related questions or ask to review just a relevant excerpt.

After you edit the question, it will be automatically put into a queue where other users will vote to reopen it. You should not need to flag your question for moderator attention.

\$\endgroup\$
23
\$\begingroup\$

If your question is asking for advice about code not yet written…

If you have not yet written your program, or if you are wondering how to add functionality to your code, then Code Review is unfortunately not the place to ask for help.

We would be glad to have you ask another Code Review question later, after you complete your program.


Now you might be asking how you're supposed to complete your program so it can be reviewed when you need the advice in order to complete the program. We appreciate the conundrum that creates.

Well scoped design review questions are on-topic for Software Engineering, so we cautiously suggest asking there. But be certain to review their on-topic and off-topic help pages first. And we strongly recommend reviewing their meta guidance about questions being close voted and why discussion based questions aren't a good fit there.

Please carefully review that guidance, as many design review requests end up being closed as too broad. And you're always welcome to ask in their Meta or chat to see if a question is on-topic before asking on their main site.

\$\endgroup\$

You must log in to answer this question.

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