Skip to content

Commit 21d4f15

Browse files
authored
Merge 10e880d into 4db5dc8
2 parents 4db5dc8 + 10e880d commit 21d4f15

File tree

180 files changed

+1821
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+1821
-1421
lines changed

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,11 @@ your app module's build.gradle.
217217

218218
### Code Formatting
219219

220-
#### Java
220+
Java and Kotlin are both formatted using `spotless`.
221221

222-
N/A for now
223-
224-
225-
#### Kotlin
226-
227-
Kotlin code in this repo is formatted with the `ktfmt` tool. You can enable
228-
this formatting in Android Studio by downloading and installing the
229-
[ktfmt plugin](https://plugins.jetbrains.com/plugin/14912-ktfmt).
230-
Enable the plugin in Preferences | Editor | ktfmt Settings. and set code style to Google (internal).
231-
232-
To run formatting on your entire project you can run
222+
To run formatting on a project, run
233223
```bash
234-
./gradlew :<firebase-project>:ktfmtFormat
224+
./gradlew :<firebase-project>:spotlessApply
235225
```
236226

237227
### Contributing

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/internal/NetworkClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ String getHeartBeat() {
212212
return null;
213213
}
214214
}
215+
215216
/** Gets the Android package's SHA-1 fingerprint. */
216217
private String getFingerprintHashForPackage() {
217218
byte[] hash;

build.gradle

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ buildscript {
2929
artifact()
3030
}
3131
}
32-
32+
maven {
33+
url "https://plugins.gradle.org/m2/"
34+
}
3335
}
3436

3537
dependencies {
3638
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.4'
3739
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:3.1.0'
3840
classpath 'com.google.gms:google-services:4.3.15'
39-
classpath "com.ncorti.ktfmt.gradle:plugin:0.11.0"
4041
classpath 'com.google.firebase:firebase-appdistribution-gradle:5.0.0'
4142
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
43+
classpath "com.diffplug.spotless:spotless-plugin-gradle:7.0.0.BETA1"
4244
}
4345
}
4446

@@ -83,10 +85,17 @@ configure(subprojects) {
8385
}
8486
}
8587

86-
apply plugin: "com.ncorti.ktfmt.gradle"
88+
apply plugin: "com.diffplug.spotless"
8789

88-
ktfmt {
89-
googleStyle()
90+
spotless {
91+
java {
92+
target 'src/**/*.java'
93+
googleJavaFormat('1.22.0').reorderImports(false).skipJavadocFormatting()
94+
}
95+
kotlin {
96+
target 'src/**/*.kt'
97+
ktfmt('0.41').googleStyle()
98+
}
9099
}
91100
}
92101

encoders/firebase-encoders-processor/src/test/resources/ExpectedAtEmptyAnnotation.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@
1414

1515
package com.example;
1616

17-
import java.lang.Class;
18-
import java.lang.Object;
19-
import java.lang.Override;
20-
import java.lang.String;
2117
import java.lang.annotation.Annotation;
2218

2319
public final class AtEmptyAnnotation {
2420
private static final AtEmptyAnnotation BUILDER = new AtEmptyAnnotation();
2521

2622
private static final EmptyAnnotation INSTANCE = new EmptyAnnotationImpl();
2723

28-
private AtEmptyAnnotation() {
29-
}
24+
private AtEmptyAnnotation() {}
3025

3126
public static AtEmptyAnnotation builder() {
3227
return BUILDER;
@@ -37,8 +32,7 @@ public EmptyAnnotation build() {
3732
}
3833

3934
private static final class EmptyAnnotationImpl implements EmptyAnnotation {
40-
EmptyAnnotationImpl() {
41-
}
35+
EmptyAnnotationImpl() {}
4236

4337
@Override
4438
public Class<? extends Annotation> annotationType() {
@@ -65,4 +59,4 @@ public String toString() {
6559
return sb.toString();
6660
}
6761
}
68-
}
62+
}

encoders/firebase-encoders-processor/src/test/resources/ExpectedAtMyAnnotation.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
package com.example;
1616

17-
import java.lang.Class;
18-
import java.lang.Object;
19-
import java.lang.Override;
20-
import java.lang.String;
2117
import java.lang.annotation.Annotation;
2218
import java.util.Arrays;
2319

@@ -90,7 +86,8 @@ public static AtMyAnnotation builder() {
9086
}
9187

9288
public MyAnnotation build() {
93-
return new MyAnnotationImpl(intVal, longVal, boolVal, shortVal, floatVal, doubleVal, doubleArrayVal, strVal, enumVal);
89+
return new MyAnnotationImpl(
90+
intVal, longVal, boolVal, shortVal, floatVal, doubleVal, doubleArrayVal, strVal, enumVal);
9491
}
9592

9693
private static final class MyAnnotationImpl implements MyAnnotation {
@@ -112,8 +109,16 @@ private static final class MyAnnotationImpl implements MyAnnotation {
112109

113110
private final MyAnnotation.MyEnum enumVal;
114111

115-
MyAnnotationImpl(int intVal, long longVal, boolean boolVal, short shortVal, float floatVal,
116-
double doubleVal, double[] doubleArrayVal, String strVal, MyAnnotation.MyEnum enumVal) {
112+
MyAnnotationImpl(
113+
int intVal,
114+
long longVal,
115+
boolean boolVal,
116+
short shortVal,
117+
float floatVal,
118+
double doubleVal,
119+
double[] doubleArrayVal,
120+
String strVal,
121+
MyAnnotation.MyEnum enumVal) {
117122
this.intVal = intVal;
118123
this.longVal = longVal;
119124
this.boolVal = boolVal;
@@ -195,16 +200,18 @@ public boolean equals(Object other) {
195200

196201
@Override
197202
public int hashCode() {
198-
return + (-15901618 ^ ((int)intVal))
199-
+ (1338661755 ^ ((int)(longVal ^ (longVal >>> 32))))
203+
return +(-15901618 ^ ((int) intVal))
204+
+ (1338661755 ^ ((int) (longVal ^ (longVal >>> 32))))
200205
+ (-373377111 ^ (boolVal ? 1231 : 1237))
201-
+ (-549529221 ^ ((int)shortVal))
206+
+ (-549529221 ^ ((int) shortVal))
202207
+ (1880085339 ^ (Float.floatToIntBits(floatVal)))
203-
+ (696767088 ^ ((int) ((Double.doubleToLongBits(doubleVal) >>> 32) ^ Double.doubleToLongBits(doubleVal))))
208+
+ (696767088
209+
^ ((int)
210+
((Double.doubleToLongBits(doubleVal) >>> 32)
211+
^ Double.doubleToLongBits(doubleVal))))
204212
+ (-1932334201 ^ Arrays.hashCode(doubleArrayVal))
205213
+ (-1615429424 ^ strVal.hashCode())
206-
+ (-170319456 ^ enumVal.hashCode())
207-
;
214+
+ (-170319456 ^ enumVal.hashCode());
208215
}
209216

210217
@Override

encoders/firebase-encoders-processor/src/test/resources/ExpectedGenericsEncoder.java

Lines changed: 76 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -18,126 +18,119 @@
1818
import com.google.firebase.encoders.config.Configurator;
1919
import com.google.firebase.encoders.config.EncoderConfig;
2020
import java.io.IOException;
21-
import java.lang.Override;
22-
import java.lang.SuppressWarnings;
2321

2422
/**
2523
* @hide */
2624
@SuppressWarnings("KotlinInternal")
2725
public final class AutoGenericsEncoder implements Configurator {
28-
public static final int CODEGEN_VERSION = 2;
26+
public static final int CODEGEN_VERSION = 2;
2927

30-
public static final Configurator CONFIG = new AutoGenericsEncoder();
28+
public static final Configurator CONFIG = new AutoGenericsEncoder();
3129

32-
private AutoGenericsEncoder() {
33-
}
30+
private AutoGenericsEncoder() {}
3431

35-
@Override
36-
public void configure(EncoderConfig<?> cfg) {
37-
cfg.registerEncoder(Generics.class, GenericsEncoder.INSTANCE);
38-
cfg.registerEncoder(Bar.class, BarEncoder.INSTANCE);
39-
cfg.registerEncoder(Baz.class, BazEncoder.INSTANCE);
40-
cfg.registerEncoder(Foo.class, FooEncoder.INSTANCE);
41-
cfg.registerEncoder(Member3.class, Member3Encoder.INSTANCE);
42-
cfg.registerEncoder(Member4.class, Member4Encoder.INSTANCE);
43-
cfg.registerEncoder(Multi.class, MultiEncoder.INSTANCE);
44-
cfg.registerEncoder(Member.class, MemberEncoder.INSTANCE);
45-
cfg.registerEncoder(Member2.class, Member2Encoder.INSTANCE);
46-
}
32+
@Override
33+
public void configure(EncoderConfig<?> cfg) {
34+
cfg.registerEncoder(Generics.class, GenericsEncoder.INSTANCE);
35+
cfg.registerEncoder(Bar.class, BarEncoder.INSTANCE);
36+
cfg.registerEncoder(Baz.class, BazEncoder.INSTANCE);
37+
cfg.registerEncoder(Foo.class, FooEncoder.INSTANCE);
38+
cfg.registerEncoder(Member3.class, Member3Encoder.INSTANCE);
39+
cfg.registerEncoder(Member4.class, Member4Encoder.INSTANCE);
40+
cfg.registerEncoder(Multi.class, MultiEncoder.INSTANCE);
41+
cfg.registerEncoder(Member.class, MemberEncoder.INSTANCE);
42+
cfg.registerEncoder(Member2.class, Member2Encoder.INSTANCE);
43+
}
4744

48-
private static final class GenericsEncoder implements ObjectEncoder<Generics> {
49-
static final GenericsEncoder INSTANCE = new GenericsEncoder();
45+
private static final class GenericsEncoder implements ObjectEncoder<Generics> {
46+
static final GenericsEncoder INSTANCE = new GenericsEncoder();
5047

51-
private static final FieldDescriptor BAR3_DESCRIPTOR = FieldDescriptor.of("bar3");
48+
private static final FieldDescriptor BAR3_DESCRIPTOR = FieldDescriptor.of("bar3");
5249

53-
private static final FieldDescriptor BAR4_DESCRIPTOR = FieldDescriptor.of("bar4");
50+
private static final FieldDescriptor BAR4_DESCRIPTOR = FieldDescriptor.of("bar4");
5451

55-
private static final FieldDescriptor MULTI_DESCRIPTOR = FieldDescriptor.of("multi");
52+
private static final FieldDescriptor MULTI_DESCRIPTOR = FieldDescriptor.of("multi");
5653

57-
@Override
58-
public void encode(Generics value, ObjectEncoderContext ctx) throws IOException {
59-
ctx.add(BAR3_DESCRIPTOR, value.getBar3());
60-
ctx.add(BAR4_DESCRIPTOR, value.getBar4());
61-
ctx.add(MULTI_DESCRIPTOR, value.getMulti());
62-
}
54+
@Override
55+
public void encode(Generics value, ObjectEncoderContext ctx) throws IOException {
56+
ctx.add(BAR3_DESCRIPTOR, value.getBar3());
57+
ctx.add(BAR4_DESCRIPTOR, value.getBar4());
58+
ctx.add(MULTI_DESCRIPTOR, value.getMulti());
6359
}
60+
}
6461

65-
private static final class BarEncoder implements ObjectEncoder<Bar> {
66-
static final BarEncoder INSTANCE = new BarEncoder();
62+
private static final class BarEncoder implements ObjectEncoder<Bar> {
63+
static final BarEncoder INSTANCE = new BarEncoder();
6764

68-
private static final FieldDescriptor FOO_DESCRIPTOR = FieldDescriptor.of("foo");
65+
private static final FieldDescriptor FOO_DESCRIPTOR = FieldDescriptor.of("foo");
6966

70-
@Override
71-
public void encode(Bar value, ObjectEncoderContext ctx) throws IOException {
72-
ctx.add(FOO_DESCRIPTOR, value.getFoo());
73-
}
67+
@Override
68+
public void encode(Bar value, ObjectEncoderContext ctx) throws IOException {
69+
ctx.add(FOO_DESCRIPTOR, value.getFoo());
7470
}
71+
}
7572

76-
private static final class BazEncoder implements ObjectEncoder<Baz> {
77-
static final BazEncoder INSTANCE = new BazEncoder();
73+
private static final class BazEncoder implements ObjectEncoder<Baz> {
74+
static final BazEncoder INSTANCE = new BazEncoder();
7875

79-
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
76+
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
8077

81-
@Override
82-
public void encode(Baz value, ObjectEncoderContext ctx) throws IOException {
83-
ctx.add(T_DESCRIPTOR, value.getT());
84-
}
78+
@Override
79+
public void encode(Baz value, ObjectEncoderContext ctx) throws IOException {
80+
ctx.add(T_DESCRIPTOR, value.getT());
8581
}
82+
}
8683

87-
private static final class FooEncoder implements ObjectEncoder<Foo> {
88-
static final FooEncoder INSTANCE = new FooEncoder();
84+
private static final class FooEncoder implements ObjectEncoder<Foo> {
85+
static final FooEncoder INSTANCE = new FooEncoder();
8986

90-
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
87+
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
9188

92-
@Override
93-
public void encode(Foo value, ObjectEncoderContext ctx) throws IOException {
94-
ctx.add(T_DESCRIPTOR, value.getT());
95-
}
89+
@Override
90+
public void encode(Foo value, ObjectEncoderContext ctx) throws IOException {
91+
ctx.add(T_DESCRIPTOR, value.getT());
9692
}
93+
}
9794

98-
private static final class Member3Encoder implements ObjectEncoder<Member3> {
99-
static final Member3Encoder INSTANCE = new Member3Encoder();
95+
private static final class Member3Encoder implements ObjectEncoder<Member3> {
96+
static final Member3Encoder INSTANCE = new Member3Encoder();
10097

101-
@Override
102-
public void encode(Member3 value, ObjectEncoderContext ctx) throws IOException {
103-
}
104-
}
98+
@Override
99+
public void encode(Member3 value, ObjectEncoderContext ctx) throws IOException {}
100+
}
105101

106-
private static final class Member4Encoder implements ObjectEncoder<Member4> {
107-
static final Member4Encoder INSTANCE = new Member4Encoder();
102+
private static final class Member4Encoder implements ObjectEncoder<Member4> {
103+
static final Member4Encoder INSTANCE = new Member4Encoder();
108104

109-
@Override
110-
public void encode(Member4 value, ObjectEncoderContext ctx) throws IOException {
111-
}
112-
}
105+
@Override
106+
public void encode(Member4 value, ObjectEncoderContext ctx) throws IOException {}
107+
}
113108

114-
private static final class MultiEncoder implements ObjectEncoder<Multi> {
115-
static final MultiEncoder INSTANCE = new MultiEncoder();
109+
private static final class MultiEncoder implements ObjectEncoder<Multi> {
110+
static final MultiEncoder INSTANCE = new MultiEncoder();
116111

117-
private static final FieldDescriptor FOOT_DESCRIPTOR = FieldDescriptor.of("fooT");
112+
private static final FieldDescriptor FOOT_DESCRIPTOR = FieldDescriptor.of("fooT");
118113

119-
private static final FieldDescriptor FOOU_DESCRIPTOR = FieldDescriptor.of("fooU");
114+
private static final FieldDescriptor FOOU_DESCRIPTOR = FieldDescriptor.of("fooU");
120115

121-
@Override
122-
public void encode(Multi value, ObjectEncoderContext ctx) throws IOException {
123-
ctx.add(FOOT_DESCRIPTOR, value.getFooT());
124-
ctx.add(FOOU_DESCRIPTOR, value.getFooU());
125-
}
116+
@Override
117+
public void encode(Multi value, ObjectEncoderContext ctx) throws IOException {
118+
ctx.add(FOOT_DESCRIPTOR, value.getFooT());
119+
ctx.add(FOOU_DESCRIPTOR, value.getFooU());
126120
}
121+
}
127122

128-
private static final class MemberEncoder implements ObjectEncoder<Member> {
129-
static final MemberEncoder INSTANCE = new MemberEncoder();
123+
private static final class MemberEncoder implements ObjectEncoder<Member> {
124+
static final MemberEncoder INSTANCE = new MemberEncoder();
130125

131-
@Override
132-
public void encode(Member value, ObjectEncoderContext ctx) throws IOException {
133-
}
134-
}
126+
@Override
127+
public void encode(Member value, ObjectEncoderContext ctx) throws IOException {}
128+
}
135129

136-
private static final class Member2Encoder implements ObjectEncoder<Member2> {
137-
static final Member2Encoder INSTANCE = new Member2Encoder();
130+
private static final class Member2Encoder implements ObjectEncoder<Member2> {
131+
static final Member2Encoder INSTANCE = new Member2Encoder();
138132

139-
@Override
140-
public void encode(Member2 value, ObjectEncoderContext ctx) throws IOException {
141-
}
142-
}
133+
@Override
134+
public void encode(Member2 value, ObjectEncoderContext ctx) throws IOException {}
135+
}
143136
}

0 commit comments

Comments
 (0)