It depends.
If your sketch is proprietary (trade secret) then you should try to produce a small non-secret sketch that reproduces the problem.
If you understand the problem enough to produce a small sketch that reproduces the problem, do that and post it.
If your sketch is not a secret but large and spread across a bunch of files and you don't undertand it enough to produce a small sketch that will demonstrate the problem, pack it all in a .zip file (or other archive format) and upload/attach it.
If your sketch is one file but you don't understand it enough to create a much smaller version that demonstrates the problem, use the IDE 'Tools->Auto Format' and 'Edit->Copy for Forum' and post the whole thing.
These are best practices. Most people try to get away with posting one line or a few lines. This CAN work, especially if an entire function and all of the variable declarations it needs are included.