Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Specify --mode diff when using plugin #109

Closed
alexklibisz opened this issue Jul 8, 2020 · 5 comments · Fixed by #172
Closed

Specify --mode diff when using plugin #109

alexklibisz opened this issue Jul 8, 2020 · 5 comments · Fixed by #172

Comments

@alexklibisz
Copy link

Hi, we're using this plugin in our org and recently updated from 1.2.0 to the latest version.
This led to very large scalafmt diffs, and we'd prefer to catch up incrementally over time.
It seems that the scalafmt CLI lets you specify --mode diff which will only apply scalafmt to the files that are diffed against the main/master branch.
Is there a way to specify this flag in the plugin?
If not, I'd be happy to try to contribute the change, but would appreciate some direction.
For example, is the plugin the right place to put this? Maybe it actually belongs in the .scalafmt.conf file, in which case the change should occur in the main scalafmt repo?

@poslegm
Copy link
Collaborator

poslegm commented Jul 9, 2020

Hello! Sadly, there is a global problem with it.

Duplicated issue #18, related issue: #11

Code for handling --diff and another useful CLI flags is located in the scalafmt-cli module and cannot be accessed from any other place. Duplicating this code in the plugin doesn't seem like the best idea to me. In a good way we must extract useful options to another common module (scalafmt-control? scalafmt-management?) and depend on it in the CLI and in the plugin. But this requires a lot of effort to refactoring.

@alexklibisz
Copy link
Author

@poslegm I see, thanks for the explanation. I have a follow up question: there are already some runner params that work from the scalafmt file, e.g. runner.debug. I figured maybe runner.mode would be a similar mechanism. Is the runner completely distinct from the cli?

@poslegm
Copy link
Collaborator

poslegm commented Jul 10, 2020

It's a name collision. ScalafmtRunner from CLI module reads files and pass it to formatter. runner from config describes formatter parameters (parsing dialect, max iterations count, verbose logging, etc)

@kitbellew
Copy link
Contributor

@poslegm would this help: scalameta/scalafmt#2871?

@poslegm
Copy link
Collaborator

poslegm commented Nov 9, 2021

Yes! Thank you. I will try to use it in the plugin soon.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants