Skip to content

Conversation

@sormuras
Copy link
Contributor

@sormuras sormuras commented Oct 7, 2016

See https://google.github.io/styleguide/javaguide.html#s3.3.3-import-ordering-and-spacing - a re-ordering of import will/should result in a spotlessCheck failure, as gjf will re-arrange the imports according to the style guide.

See https://google.github.io/styleguide/javaguide.html#s3.3.3-import-ordering-and-spacing - a re-ordering of import will/should result in a `spotlessCheck` failure, as gjf will re-arrange the imports according to the style guide.
@nedtwigg
Copy link
Member

nedtwigg commented Oct 7, 2016

Roger, thanks for the correction. Just FYI, Spotless doesn't care if the rules fight, it just applies them sequentially. spotlessCheck will succeed so long as the final result is the same as the initial result, regardless of the intermediate results. e.g.

spotless {
    misc 'someFormat', {
        toLowerCase()
        toUpperCase()
        toLowerCase()
    }
}

The final result would be for the files to all be lowercase, and spotlessCheck would be fine with it. But this is a good PR regardless because it would clearly not be canonical googleJavaFormat usage to change import order if googleJavaFormat has something to say about import order.

@nedtwigg nedtwigg merged commit f252fc7 into diffplug:master Oct 7, 2016
@sormuras sormuras deleted the patch-1 branch October 7, 2016 23:14
@sormuras
Copy link
Contributor Author

sormuras commented Oct 7, 2016

So basically, a spotlessCheck is a splotApply with reverting to the inital state after checking for equality?

@nedtwigg
Copy link
Member

nedtwigg commented Oct 7, 2016

Exactly. Each step is just a Function<String, String>, and Spotless applies them one after the other. For spotlessCheck it yells at you if they don't match. For spotlessApply it just writes the result to disk whether it matches or not.

@sormuras
Copy link
Contributor Author

sormuras commented Oct 7, 2016

Thanks for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants