incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
599 stars 72 forks source link

Tool crashes when parsing Intellij Idea templates #162

Open sruehl opened 2 months ago

sruehl commented 2 months ago

when running goimports-reviser ./...

I get

Failed to fix directory ./...: failed to walk dif: failed to fix: 18:5: expected 'package', found 'EOF'

when running in projects containing Intellij Idea templates.

Is there an option to not crash the program and just ignore that directory? Seems a bit tedious to workaround that...

sruehl commented 2 months ago

code point for reference https://github.com/incu6us/goimports-reviser/blob/5f29621b9217398814dbf41a021f51536cb54be1/reviser/dir.go#L138

sruehl commented 2 months ago

~would be good to at least output the path in the error message to, otherwise the error looks a bit silly as can be seen above~ (edit: fixed with #163 )

sruehl commented 1 month ago

ok guess the title is wrong, it actually crashes because of the idea template (with the help of #163): .idea/fileTemplates/includes/File Header Go.go. So I was able to fix this by -excludes .idea.

So I wonder if it might be an option to add a eager option or something which just continues on those cases or another option is to provide sensible defaults for excludes like .idea or .git because I'm quite positive that you never want to format stuff in those directories.