Refactor flag can only be used with an individual file
chris-martin opened this issue · 2 comments
> hlint -j . -o "..." --refactor --refactor-options="--inplace"
hlint: Refactor flag can only be used with an individual file
CallStack (from HasCallStack):
errorIO, called at src/HLint.hs:213:14 in hlint-3.4.1-2AxkzXrwpEoEYKlPa1ZKgm:HLint
Why does this limitation exist? Would it be possible to allow refactoring multiple files at a time? It would be really great to be able to automatically apply a replacement rule throughout an entire project.
As a workaround I can do something like this: fish> for x in (git ls-files '**/*.hs'); hlint -o "..." --refactor --refactor-options="--inplace" $x; end
but I don't understand why it's necessary.
I have no idea. Do you @zliu41 ? I think it should be as simple as changing https://github.com/ndmitchell/hlint/blob/14162e89c2fbf5c42a451e4e2368a8b11625f5cb/src/HLint.hs#L212C1-L223 to be:
forM_ cmdFiles $ \file -> do
...
If someone can test it out, and it actually works, I'd be happy to take a PR.
This was introduced in 2016 (#274) and no reason was given in the PR. It certainly seems douable, though it may require a bit more than forM_ cmdFiles $ \file -> do
, since it may need to find the Idea
s corresponding to each file. I agree this is a good first issue so I'll leave it for someone else to fix.