diffplug / diffplug/spotless

Diff formatting shows weird whitespace characters on Windows 10 (� and ╖ instead of ·)

Open
#695 7 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 13h
Merged PRs (30d)
34

Description

## Summary of problem

When outputting the details of what lines have format violations, the `·` characters representing whitespace are not rendering correctly in the Command Prompt, Android Studio & Intellij's console output on Windows 10. I tried the same project with the same IDEs and Gradle files on Mac OS Catalina and don't see the issue.

I use defaults fonts on Windows and in the IDEs. I tried other monospaced fonts and character encoding thinking it's something on my end. Didn't seem to have any effect. I'm suspecting something in the library is possibly using an encoding that isn't translating back to UTF-8 correctly.

Android Studio & Intellij's output (Windows 10)
```
Execution failed for task ':app:spotlessKotlinCheck'.
> The following files had format violations:
app\src\main\java\com\corwinjv\postmodernandroid\common\di\NetworkModule.kt
@@ -6,15 +6,14 @@
import�dagger.Provides
import�dagger.hilt.InstallIn
import�dagger.hilt.android.components.ApplicationComponent
+import�javax.inject.Singleton
import�okhttp3.OkHttpClient
import�retrofit2.Retrofit
import�retrofit2.converter.gson.GsonConverterFactory
-import�javax.inject.Singleton
@InstallIn(ApplicationComponent::class)
@Module
-class�NetworkModule
-{
+class�NetworkModule�{
����@Provides
����@Singleton
����fun�provideOkHttpClient():�OkHttpClient�{
@@ -24,7 +23,7 @@
����@Provides
����@Singleton
-����fun�provideProgrammingQuotesApi(okHttpClient:�OkHttpClient)�:�ProgrammingQuotesApi�{
+����fun�provideProgrammingQuotesApi(okHttpClient:�OkHttpClient):�ProgrammingQuotesApi�{
��������return�Retrofit.Builder()
... (8 more lines that didn't fit)
```

Command Prompt's output (Windows 10)
```
Execution failed for task ':app:spotlessKotlinCheck'.
> The following files had format violations:
app\src\main\java\com\corwinjv\postmodernandroid\common\di\NetworkModule.kt
@@ -6,15 +6,14 @@
import╖dagger.Provides
import╖dagger.hilt.InstallIn
import╖dagger.hilt.android.components.ApplicationComponent
+import╖javax.inject.Singleton
import╖okhttp3.OkHttpClient
import╖retrofit2.Retrofit
import╖retrofit2.converter.gson.GsonConverterFactory
-import╖javax.inject.Singleton

@InstallIn(ApplicationComponent::class)
@Module
-class╖NetworkModule
-{
+class╖NetworkModule╖{
╖╖╖╖@Provides
╖╖╖╖@Singleton
╖╖╖╖fun╖provideOkHttpClient():╖OkHttpClient╖{
@@ -24,7 +23,7 @@

╖╖╖╖@Provides
╖╖╖╖@Singleton
-╖╖╖╖fun╖provideProgrammingQuotesApi(okHttpClient:╖OkHttpClient)╖:╖ProgrammingQuotesApi╖{
+╖╖╖╖fun╖provideProgrammingQuotesApi(okHttpClient:╖OkHttpClient):╖ProgrammingQuotesApi╖{
╖╖╖╖╖╖╖╖return╖Retrofit.Builder()
... (8 more lines that didn't fit)
```

Android Studio 4.0's output (Mac OS Catalina)
```
Execution failed for task ':app:spotlessKotlinCheck'.
> The following files had format violations:
app/src/androidTest/java/com/corwinjv/postmodernandroid/ExampleInstrumentedTest.kt
@@ -1,13 +1,11 @@
package·com.corwinjv.postmodernandroid

+import·androidx.test.ext.junit.runners.AndroidJUnit4
import·androidx.test.platform.app.InstrumentationRegistry
-import·androidx.test.ext.junit.runners.AndroidJUnit4
-
+import·org.junit.Assert.assertEquals
import·org.junit.Test
import·org.junit.runner.RunWith

-import·org.junit.Assert.assertEquals
-
/**
·*·Instrumented·test,·which·will·execute·on·an·Android·device.
·*
app/src/main/java/com/corwinjv/postmodernandroid/App.kt
@@ -4,4 +4,4 @@
import·dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
-class·App·:·Application()
+class·App·:·Application()
app/src/main/java/com/corwinjv/postmodernandroid/common/di/NetworkModule.kt
@@ -6,15 +6,14 @@
import·dagger.Provides
import·dagger.hilt.InstallIn
import·dagger.hilt.android.components.ApplicationComponent
+import·javax.inject.Singleton
import·okhttp3.OkHttpClient
import·retrofit2.Retrofit
import·retrofit2.converter.gson.GsonConverterFactory
-import·javax.inject.Singleton

@InstallIn(ApplicationComponent::class)
@Module
-class·NetworkModule
-{
+class·NetworkModule·{
····@Provides
····@Singleton
····fun·provideOkHttpClient():·OkHttpClient·{
@@ -24,7 +23,7 @@

····@Provides
····@Singleton
-····fun·provideProgrammingQuotesApi(okHttpClient:·OkHttpClient)·:·ProgrammingQuotesApi·{
+····fun·provideProgrammingQuotesApi(okHttpClient:·OkHttpClient):·ProgrammingQuotesApi·{
········return·Retrofit.Builder()
... (8 more lines that didn't fit)
```

## gradle or maven version

Gradle - 6.1.1

## spotless version

5.5.1

## operating system and version

* Windows 10 Pro (19041.508)
* Android Studio 4.0
* Intellij IDEA 2019.3.4

## copy-paste your full Spotless configuration block(s)

**Root project Gradle file**
```
buildscript {
repositories {
// ...
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
// ...
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0"
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.5.1"
}
}

apply plugin: "com.diffplug.spotless"
// ...
```

**Subproject (app)'s Gradle file**
```
// ...
apply plugin: "com.diffplug.spotless"

spotless {
kotlin {
target 'src/*/java/**/*.kt'
ktlint()
}
}
// ...
```

## copy-paste the full content of any console errors emitted by `gradlew spotless[Apply/Check] --stacktrace`

See summary

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.