You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we add replaceRegex with Spotless, it takes effect silently when running mvn spotless:apply. If we use mvn spotless:check, it will point out the specific line which violates the rule but will not tell which specific rule the code violates. If we could have the name of replaceRegex printed as well, it would help.
For example, if we use the following configuration, and there are some wildcard imports in the code, it would be better if users could see some message like triggering Remove wildcard imports rule when running mvn spotless:apply or mvn spotless:check.
Firstly, it's important to note that Spotless is not a list of rules, it is a list of functions, String -> String, and that is all. There are lots of advantages to this model, like our idempotence guarantee. But one of the disadvantages is that it's hard to attribute a specific failure to a specific rule. But it is possible! Here is how we could do it.
First, identify which lines are different between the input content and the canonical formatted content.
Now, apply each step on the input content, one at a time.
For each step, diff the before/after, and identify which lines were changed
This is more complicated than it seems at first, because of the idempotence guarantee mentioned earlier, it might be the case that steps are applied more than once.
Now, for each line in the canonical content, you have list of which steps altered that line, which you can use to annotate the changes.
That's a big project, but it would be possible. My guess is that it's not worth the effort, but who knows what PR's might show up someday :)
A workaround specifically for the wildcard import removal mentioned above could be to append a comment indicating that wildcard imports are disallowed and making the import invalid (see google/gson#2550):
replaceRegex
withSpotless
, it takes effect silently when runningmvn spotless:apply
. If we usemvn spotless:check
, it will point out the specific line which violates the rule but will not tell which specific rule the code violates. If we could have thename
ofreplaceRegex
printed as well, it would help.wildcard imports
in the code, it would be better if users could see some message liketriggering Remove wildcard imports rule
when runningmvn spotless:apply
ormvn spotless:check
.Thanks!
The text was updated successfully, but these errors were encountered: