Questions tagged [spotless]

Use this tag for errors or bugs related to usage of this plugin, usually combined with the specific tags of language or technology.

Spotless is a code formatter plugin for Maven, Gradle and other build systems.

34 questions
20
votes
3 answers

Confgure IntelliJ to use the same Java formatter as Spotless

I use the Spotless Gradle plugin to ensure consistent formatting of the Java code in my app. The relevant entries in build.gradle are plugins { id "com.diffplug.gradle.spotless" version "3.27.0" } spotless { java { // The available versions…
Antonio Dragos
  • 1,973
  • 2
  • 29
  • 52
8
votes
0 answers

Spotless + Java Google format vs Intellij + import file

I am trying to configure a maven spring boot application to use spotless with google java format style. I would like as well to have Intellij formatting the code as the maven plugin does. But i am noticing that the formmat applied differ a little…
mpssantos
  • 931
  • 13
  • 30
7
votes
0 answers

Use of checkstyle.xml in diffplug/spotless

I have a checkstyle.xml file to check for formatting violations . Is there any way to provide checkstyle.xml as a input to diffplug/spotless formatter . Java8 is being used and spotless verison is 2.11.0 . If this is possible using spotless::apply…
7
votes
1 answer

How to prevent Spotless/Eclipse from joining lines?

I have a project that uses Spotless with the Eclipse formatter to check and format the source code. Now one problem is that the formatter creates some absurdly long lines such as the following: @ApiModelProperty(value = "This is a placeholder…
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112
7
votes
1 answer

Gradle: Spotless task not firing when needed

I followed the Spotless plugin's readme and included the following into my build.gradle: apply plugin: 'java' spotless { java { eclipseFormatFile 'my-eclipse-format.xml' } } When I run "gradlew build", I expect Spotless to a)…
user3651020
  • 101
  • 1
  • 1
  • 4
6
votes
2 answers

Klint and spotless: com.pinterest.ktlint.core.ParseException: Expecting a parameter declaration

I'm getting weird exception when trying to run ./gradlew spotlessApply on my project in Kotlin. Class causing the problem: import io.realm.RealmObject import io.realm.annotations.PrimaryKey open class CurrentFluttering( @PrimaryKey var id: Long…
Babu
  • 4,324
  • 6
  • 41
  • 60
4
votes
1 answer

How can I use the googleJavaFormat to make reflowLongStrings set to a max of 120 chars per line

I am using the Spotless plugin to format my Java code. However, when I am enabling the reflowLongStrings rule, it breaks lines to be no longer than 80 chars. Is it possible to change it to 120?
4
votes
1 answer

Kotlin Gradle Spotless ktlint configuration

I currently use the following way to apply ktlint to my projects: plugins{ id("com.diffplug.spotless") version "6.7.2" } allprojects { apply(plugin = "com.diffplug.gradle.spotless") spotless { kotlin { …
MozenRath
  • 9,652
  • 13
  • 61
  • 104
3
votes
0 answers

What does .userData([android:"true"]) convey in ktlint('0.43.2').userData([android: "true"])

ktlint('0.43.2').userData([android: "true"]) is a statement in spotless.gralde on using spotless with ktlint. I would like to know what is being conveyed when we give android:"true" in userData. kotlin { target '**/*.kt' …
2
votes
1 answer

Configure enum constants on its own line using Eclipse Code Formatter

I'm using Spotless with Gradle. I've configured it to use Eclipse's JDT Code Formatter: spotless { groovyGradle { greclipse("4.21.0").configFile("${rootDir}/config/spotless/eclipe_groovy_formatter.xml") } java { …
x80486
  • 6,627
  • 5
  • 52
  • 111
2
votes
0 answers

How to decrease indent level in Spotless?

I'm using the following in my build.gradle: plugins { id 'com.diffplug.gradle.spotless' version '4.5.1' } spotless { java { googleJavaFormat() replaceRegex 'Combine function with lambda.', '(\\.[A-Za-z][0-9A-Za-z]+\\()\\n\\s+', '$1' …
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
1
vote
0 answers

How to configure spotless to keep line breaks for java builders

I am using spotless to format my java code and I am fairly happy with it. However it keeps reformatting my builders so that everything is on one line when it is within the line limits. For example this final var user = User.builder() .id(1L) …
Zounadire
  • 1,496
  • 2
  • 18
  • 38
1
vote
0 answers

Java spotless plugin with starred imports

I have a swagger openapi yml definition to generate apis. But this plugin incorporates unused imprts into the generated files. I could erase most of them by spotless plugin but I can't stop swagger to make starred imports (import…
HowToTellAChild
  • 623
  • 1
  • 9
  • 21
1
vote
1 answer

How can I force the 'this' keyword on local fields and methods with the Spotless Java code formatter?

I want to enforce the use of the 'this' keyword using Spotless. For example: getTowerData().recordMap would be this.getTowerData().recordMap. I'm running Spotless with Gradle with the current configuration: spotless { java { …
lolMagixD
  • 39
  • 1
  • 3
1
vote
2 answers

spotless elicpse wtp format config file

I'm using spotless to format code in my project. I've decided to use WTP plugin to format html, css and js in this projet. There should be a config to select the way html is formated. eg. with space instead of…
benzen
  • 6,204
  • 4
  • 25
  • 37
1
2 3