nilaway icon indicating copy to clipboard operation
nilaway copied to clipboard

Feature Request: Running against generated and vendored code

Open stephen-slm opened this issue 1 year ago • 5 comments

👋

The tool is not taking into consideration generated code, mocks and vendored directories. It would be nice to be able to explicitly exclude these. Exclusion options exist for -exclude-errors-in-files, -exclude-file-docstrings, -exclude-pkgs but they don't fully meet the needs of entire folder exclusion or generated code that follows the best practice package comments marking generated code (// Code generated by).

stephen-slm avatar Nov 16 '23 12:11 stephen-slm

The generated code standard: ^// Code generated .* DO NOT EDIT\.$

dolmen avatar Nov 22 '23 14:11 dolmen

@stephensli , thanks for raising this issue. We currently do not support for regex or glob patterns when specifying include or exclude lists. We do plan add regex support soon. Thanks, @dolmen, for the pointer! 👍

sonalmahajan15 avatar Nov 30 '23 07:11 sonalmahajan15

Please also add support for excluding code that is put into the standard vendor dir by the standard go mod vendor command. I think, this vendor-exclusion should be on by default.

Currently I have to always rm -rf vendor before nilaway ./... to check the current modules code only.

ubunatic avatar Jan 02 '24 11:01 ubunatic

I have the same problem with code in the vendor directory. An option to ignore that directory would be super helpful.

marcelloh avatar Jan 04 '24 07:01 marcelloh

If generated code is in special folders, like mocks, we should be able to skip those folders with the -exclude-pkgs flag. but it is unclear how to use that, because nilaway -exclude-pkgs "mocks" doesn't work. (neither does "./mocks" or "./.../mocks") I expect based on the little documentation there is, that a package name should be the value here.

marcelloh avatar Mar 26 '24 00:03 marcelloh