Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error Reformatting Code with Spotless #20

Open
pmcnsr opened this issue Jul 26, 2024 · 6 comments · Fixed by #21
Open

Error Reformatting Code with Spotless #20

pmcnsr opened this issue Jul 26, 2024 · 6 comments · Fixed by #21
Labels
bug Something isn't working

Comments

@pmcnsr
Copy link

pmcnsr commented Jul 26, 2024

Hi, I receive following error, when adding the plugin as an commit hook. Using it via shortcut is no problem. Im using a multi module project if you need any more information happy to provide. Regards

Error while reformatting code with Spotless: Argument for @NotNull parameter 'moduleInfo' of com/github/lipiridi/spotless/applier/ReformatProcessor. must not be null

@lipiridi lipiridi added the bug Something isn't working label Jul 27, 2024
@lipiridi
Copy link
Owner

Hi! Yeah, currently, the commit hook doesn't support multi-module projects. This is because an additional window needs to be displayed, asking which modules we want to format (same when we are running reformat project action).
image
I believe it would be inconvenient to have such a window appear during commits, so I'll check the feasibility of identifying affected modules and applying Spotless only to those.

@lipiridi
Copy link
Owner

lipiridi commented Aug 4, 2024

I investigated the ability to determine changed files and found that it is possible. We have to implement CommitCheck for SpotlessCheckinHandler. Here is what the doc says:

This interface supersedes CheckinHandler. beforeCheckin method, and will be used instead if CheckinHandler implements CommitCheck

The runCheck method from the new interface includes a commitInfo parameter in its signature, which helps us identify the affected changes.

@lipiridi
Copy link
Owner

Hello! It was not possible to use CommitCheck because it uses EDT mode. So it was resolved using ChangeListManager.
Version 1.1.1 is published - https://plugins.jetbrains.com/plugin/22455-spotless-applier/versions/stable/585523

@pmcnsr
Copy link
Author

pmcnsr commented Aug 12, 2024

Hi @lipiridi thanks for your response and the update. I checked it today but I get an error, when I execute spotless applier in one of the submodules:

Task 'spotlessApply' not found in root project 'subproject1'.

Our multi module project is structured like
yoj4x

When I run it in master everythings fine

@lipiridi
Copy link
Owner

Hello! I guess this issue is also related - #23
I'm on my way to find the cause.

@lipiridi lipiridi reopened this Aug 12, 2024
@lipiridi
Copy link
Owner

No, it is not related to #23.

I have few questions:

  1. Is spotless applied to submodules in the master build?
  2. Is spotless task present in the gradle tool window for submodules?

I would be grateful if you share settings and build files.

I tested 2 cases during development:

  1. Multi-module project where settings and build are located in the root (not in a separate module)
  2. Many modules (not tied up with the settings file) opened as a one project, where each module has it's own build file with spotless dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants