akoutmos / doctor

Ensure that your Elixir project documentation is healthy
MIT License
178 stars 15 forks source link

fix: allow different arguments to __using__ #48

Closed randycoulman closed 2 years ago

randycoulman commented 2 years ago

ModuleInformation.parse_ast_for_using would only handle using blocks with a single argument named _opts.

In cases where the argument was named differently (for example, opts because the options are needed by the block), the __using__ block would not be detected.

This change generalizes the pattern match a bit so that it accepts an array with a single argument (which is what __using__ requires), but makes no assumptions about the name of the argument.

It didn't seem worth it to add a new test for this case. I could have changed the name of the argument in Doctor.UseModule, but what's there is pretty conventional. So, in the end, I decided to leave the tests as-is. I can revisit that choice if you prefer.

akoutmos commented 2 years ago

Good catch. Thanks!