dlang-community / D-Scanner

Swiss-army knife for D source code
Boost Software License 1.0
238 stars 80 forks source link

syntax check from stdin too, like Style check #529

Open andre2007 opened 6 years ago

andre2007 commented 6 years ago

Please check attached example. I run D-Scanner with command

dub run dscanner -- -t

D-Scanner starts but never comes back. Same for -s. For argument -S D-Scanner is working dlang-sample.zip

Hackerpilot commented 6 years ago

When launched without a file name as an input D-Scanner reads from the standard input stream. It's not failing to respond, you just haven't given it any input. The UNIX cat command has the same "bug".

andre2007 commented 6 years ago

Why does dub run dscanner -- -S works, while dub run dscanner -- -s does not work? In both cases no filename is provided. 

Hackerpilot commented 6 years ago

Why does dub run dscanner -- -SWorks, while dub run dscanner -- -sDoes not work? In both cases no filename is provided.

I assume that by "works" you mean "finishes executing immediately" and not "produces useful output". The reason for this difference is that the style check option doesn't yet support reading from stdin.

andre2007 commented 6 years ago

Sorry. With works I meant: the style check produces the expected output. See here for a sample https://github.com/linkrope/dunit/issues/14

andre2007 commented 6 years ago

I did some more investigations and I found following behavior: The style check which you can call via

dscanner -S

will find all d source code files within the current work dir and sub directories. Example output:

.\sub\t1.d(3:6)[warn]: Public declaration 'abc' is undocumented.

But the syntax check which you can call via

dscanner -s

does not have this functionality. You have to pass the files as console argument e.g.

dscanner -s app.d sub/t1.d

I wonder why there are different behaviors for -S / -s? You mentioned by not specifying the files while calling dscanner -s, D-Scanner is waiting on stdin for file input. I know from DMD this feature was also implemented but with the "dash" syntax: https://github.com/dlang/dmd/pull/6880

The syntax for D-Scanner would look like

dscanner -s -

Would it be possible to enable the "folder scanning" for -s / -t too by not specifying any files? Enabling the stdin input can be done via the dash syntax.