dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Detect undocumented command-line options

Open ntrel opened this issue 1 year ago • 10 comments

Works when dmd is compiled in debug mode. Only detects simple non-suffix options.

Hopefully any PRs forgetting to call gotOpt will be detected in reviews as surrounding lines tend to call it. Failing that, at least we can grep for if (arg == " to list all the hidden/unchecked options (e.g. -quiet, --b).

Add docs for -multiobj, -nofloat, -vcg-ast.

ntrel avatar Nov 08 '22 14:11 ntrel

Thanks for your pull request and interest in making D better, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
23471 enhancement undocumented dmd CLI options

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14630"

dlang-bot avatar Nov 08 '22 14:11 dlang-bot

What's the issue ? We already detect unused arguments L2550 / 2580:

        else
        {
        Lerror:
            error("unrecognized switch '%s'", arguments[i]);
            continue;
        Lnoarg:
            error("argument expected for switch '%s'", arguments[i]);
            continue;
        }

Geod24 avatar Nov 08 '22 15:11 Geod24

@Geod24 This helps detect valid options that don't have --help documentation.

ntrel avatar Nov 08 '22 15:11 ntrel

You can see the check firing in the tests for the first commit (before I added missing docs) here: https://app.circleci.com/pipelines/github/dlang/dmd/23098/workflows/1da53291-0849-49a4-b6c1-6bc0f758fa21/jobs/50668

core.exception.AssertError@src/dmd/mars.d(1596): missing doc for -multiobj in cli.d

ntrel avatar Nov 08 '22 15:11 ntrel

Add docs for -multiobj, -nofloat, -vcg-ast.

Note sure about the first two, but -vcg-ast was intentionally not documented because it was meant for internal use.

dkorpel avatar Nov 08 '22 15:11 dkorpel

I suggest adding a parameter to gotOpt so you can specify that a switch is deliberately undocumented, and add documentation to switches in a separate PR.

dkorpel avatar Nov 08 '22 16:11 dkorpel

Thanks for cleaning up the argument parsing code!

nordlow avatar Nov 09 '22 09:11 nordlow

Undocumented flags are mostly pointless/even dangerous, I'd rather we documented them like llvm/ldc does with -help-hidden

maxhaton avatar Nov 16 '22 17:11 maxhaton

@ntrel what are your plans with this PR?

RazvanN7 avatar Dec 19 '22 13:12 RazvanN7

Ping @ntrel

dkorpel avatar May 02 '23 12:05 dkorpel