Skip to content

Commit

Permalink
Merge 10e880d into 4db5dc8
Browse files Browse the repository at this point in the history
  • Loading branch information
emilypgoogle committed Jul 16, 2024
2 parents 4db5dc8 + 10e880d commit 21d4f15
Show file tree
Hide file tree
Showing 180 changed files with 1,821 additions and 1,421 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,11 @@ your app module's build.gradle.

### Code Formatting

#### Java
Java and Kotlin are both formatted using `spotless`.

N/A for now


#### Kotlin

Kotlin code in this repo is formatted with the `ktfmt` tool. You can enable
this formatting in Android Studio by downloading and installing the
[ktfmt plugin](https://plugins.jetbrains.com/plugin/14912-ktfmt).
Enable the plugin in Preferences | Editor | ktfmt Settings. and set code style to Google (internal).

To run formatting on your entire project you can run
To run formatting on a project, run
```bash
./gradlew :<firebase-project>:ktfmtFormat
./gradlew :<firebase-project>:spotlessApply
```

### Contributing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ String getHeartBeat() {
return null;
}
}

/** Gets the Android package's SHA-1 fingerprint. */
private String getFingerprintHashForPackage() {
byte[] hash;
Expand Down
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ buildscript {
artifact()
}
}

maven {
url "https://plugins.gradle.org/m2/"
}
}

dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.4'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:3.1.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath "com.ncorti.ktfmt.gradle:plugin:0.11.0"
classpath 'com.google.firebase:firebase-appdistribution-gradle:5.0.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
classpath "com.diffplug.spotless:spotless-plugin-gradle:7.0.0.BETA1"
}
}

Expand Down Expand Up @@ -83,10 +85,17 @@ configure(subprojects) {
}
}

apply plugin: "com.ncorti.ktfmt.gradle"
apply plugin: "com.diffplug.spotless"

ktfmt {
googleStyle()
spotless {
java {
target 'src/**/*.java'
googleJavaFormat('1.22.0').reorderImports(false).skipJavadocFormatting()
}
kotlin {
target 'src/**/*.kt'
ktfmt('0.41').googleStyle()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@

package com.example;

import java.lang.Class;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.annotation.Annotation;

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

private static final EmptyAnnotation INSTANCE = new EmptyAnnotationImpl();

private AtEmptyAnnotation() {
}
private AtEmptyAnnotation() {}

public static AtEmptyAnnotation builder() {
return BUILDER;
Expand All @@ -37,8 +32,7 @@ public EmptyAnnotation build() {
}

private static final class EmptyAnnotationImpl implements EmptyAnnotation {
EmptyAnnotationImpl() {
}
EmptyAnnotationImpl() {}

@Override
public Class<? extends Annotation> annotationType() {
Expand All @@ -65,4 +59,4 @@ public String toString() {
return sb.toString();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

package com.example;

import java.lang.Class;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.annotation.Annotation;
import java.util.Arrays;

Expand Down Expand Up @@ -90,7 +86,8 @@ public static AtMyAnnotation builder() {
}

public MyAnnotation build() {
return new MyAnnotationImpl(intVal, longVal, boolVal, shortVal, floatVal, doubleVal, doubleArrayVal, strVal, enumVal);
return new MyAnnotationImpl(
intVal, longVal, boolVal, shortVal, floatVal, doubleVal, doubleArrayVal, strVal, enumVal);
}

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

private final MyAnnotation.MyEnum enumVal;

MyAnnotationImpl(int intVal, long longVal, boolean boolVal, short shortVal, float floatVal,
double doubleVal, double[] doubleArrayVal, String strVal, MyAnnotation.MyEnum enumVal) {
MyAnnotationImpl(
int intVal,
long longVal,
boolean boolVal,
short shortVal,
float floatVal,
double doubleVal,
double[] doubleArrayVal,
String strVal,
MyAnnotation.MyEnum enumVal) {
this.intVal = intVal;
this.longVal = longVal;
this.boolVal = boolVal;
Expand Down Expand Up @@ -195,16 +200,18 @@ public boolean equals(Object other) {

@Override
public int hashCode() {
return + (-15901618 ^ ((int)intVal))
+ (1338661755 ^ ((int)(longVal ^ (longVal >>> 32))))
return +(-15901618 ^ ((int) intVal))
+ (1338661755 ^ ((int) (longVal ^ (longVal >>> 32))))
+ (-373377111 ^ (boolVal ? 1231 : 1237))
+ (-549529221 ^ ((int)shortVal))
+ (-549529221 ^ ((int) shortVal))
+ (1880085339 ^ (Float.floatToIntBits(floatVal)))
+ (696767088 ^ ((int) ((Double.doubleToLongBits(doubleVal) >>> 32) ^ Double.doubleToLongBits(doubleVal))))
+ (696767088
^ ((int)
((Double.doubleToLongBits(doubleVal) >>> 32)
^ Double.doubleToLongBits(doubleVal))))
+ (-1932334201 ^ Arrays.hashCode(doubleArrayVal))
+ (-1615429424 ^ strVal.hashCode())
+ (-170319456 ^ enumVal.hashCode())
;
+ (-170319456 ^ enumVal.hashCode());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,126 +18,119 @@
import com.google.firebase.encoders.config.Configurator;
import com.google.firebase.encoders.config.EncoderConfig;
import java.io.IOException;
import java.lang.Override;
import java.lang.SuppressWarnings;

/**
* @hide */
@SuppressWarnings("KotlinInternal")
public final class AutoGenericsEncoder implements Configurator {
public static final int CODEGEN_VERSION = 2;
public static final int CODEGEN_VERSION = 2;

public static final Configurator CONFIG = new AutoGenericsEncoder();
public static final Configurator CONFIG = new AutoGenericsEncoder();

private AutoGenericsEncoder() {
}
private AutoGenericsEncoder() {}

@Override
public void configure(EncoderConfig<?> cfg) {
cfg.registerEncoder(Generics.class, GenericsEncoder.INSTANCE);
cfg.registerEncoder(Bar.class, BarEncoder.INSTANCE);
cfg.registerEncoder(Baz.class, BazEncoder.INSTANCE);
cfg.registerEncoder(Foo.class, FooEncoder.INSTANCE);
cfg.registerEncoder(Member3.class, Member3Encoder.INSTANCE);
cfg.registerEncoder(Member4.class, Member4Encoder.INSTANCE);
cfg.registerEncoder(Multi.class, MultiEncoder.INSTANCE);
cfg.registerEncoder(Member.class, MemberEncoder.INSTANCE);
cfg.registerEncoder(Member2.class, Member2Encoder.INSTANCE);
}
@Override
public void configure(EncoderConfig<?> cfg) {
cfg.registerEncoder(Generics.class, GenericsEncoder.INSTANCE);
cfg.registerEncoder(Bar.class, BarEncoder.INSTANCE);
cfg.registerEncoder(Baz.class, BazEncoder.INSTANCE);
cfg.registerEncoder(Foo.class, FooEncoder.INSTANCE);
cfg.registerEncoder(Member3.class, Member3Encoder.INSTANCE);
cfg.registerEncoder(Member4.class, Member4Encoder.INSTANCE);
cfg.registerEncoder(Multi.class, MultiEncoder.INSTANCE);
cfg.registerEncoder(Member.class, MemberEncoder.INSTANCE);
cfg.registerEncoder(Member2.class, Member2Encoder.INSTANCE);
}

private static final class GenericsEncoder implements ObjectEncoder<Generics> {
static final GenericsEncoder INSTANCE = new GenericsEncoder();
private static final class GenericsEncoder implements ObjectEncoder<Generics> {
static final GenericsEncoder INSTANCE = new GenericsEncoder();

private static final FieldDescriptor BAR3_DESCRIPTOR = FieldDescriptor.of("bar3");
private static final FieldDescriptor BAR3_DESCRIPTOR = FieldDescriptor.of("bar3");

private static final FieldDescriptor BAR4_DESCRIPTOR = FieldDescriptor.of("bar4");
private static final FieldDescriptor BAR4_DESCRIPTOR = FieldDescriptor.of("bar4");

private static final FieldDescriptor MULTI_DESCRIPTOR = FieldDescriptor.of("multi");
private static final FieldDescriptor MULTI_DESCRIPTOR = FieldDescriptor.of("multi");

@Override
public void encode(Generics value, ObjectEncoderContext ctx) throws IOException {
ctx.add(BAR3_DESCRIPTOR, value.getBar3());
ctx.add(BAR4_DESCRIPTOR, value.getBar4());
ctx.add(MULTI_DESCRIPTOR, value.getMulti());
}
@Override
public void encode(Generics value, ObjectEncoderContext ctx) throws IOException {
ctx.add(BAR3_DESCRIPTOR, value.getBar3());
ctx.add(BAR4_DESCRIPTOR, value.getBar4());
ctx.add(MULTI_DESCRIPTOR, value.getMulti());
}
}

private static final class BarEncoder implements ObjectEncoder<Bar> {
static final BarEncoder INSTANCE = new BarEncoder();
private static final class BarEncoder implements ObjectEncoder<Bar> {
static final BarEncoder INSTANCE = new BarEncoder();

private static final FieldDescriptor FOO_DESCRIPTOR = FieldDescriptor.of("foo");
private static final FieldDescriptor FOO_DESCRIPTOR = FieldDescriptor.of("foo");

@Override
public void encode(Bar value, ObjectEncoderContext ctx) throws IOException {
ctx.add(FOO_DESCRIPTOR, value.getFoo());
}
@Override
public void encode(Bar value, ObjectEncoderContext ctx) throws IOException {
ctx.add(FOO_DESCRIPTOR, value.getFoo());
}
}

private static final class BazEncoder implements ObjectEncoder<Baz> {
static final BazEncoder INSTANCE = new BazEncoder();
private static final class BazEncoder implements ObjectEncoder<Baz> {
static final BazEncoder INSTANCE = new BazEncoder();

private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");

@Override
public void encode(Baz value, ObjectEncoderContext ctx) throws IOException {
ctx.add(T_DESCRIPTOR, value.getT());
}
@Override
public void encode(Baz value, ObjectEncoderContext ctx) throws IOException {
ctx.add(T_DESCRIPTOR, value.getT());
}
}

private static final class FooEncoder implements ObjectEncoder<Foo> {
static final FooEncoder INSTANCE = new FooEncoder();
private static final class FooEncoder implements ObjectEncoder<Foo> {
static final FooEncoder INSTANCE = new FooEncoder();

private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");
private static final FieldDescriptor T_DESCRIPTOR = FieldDescriptor.of("t");

@Override
public void encode(Foo value, ObjectEncoderContext ctx) throws IOException {
ctx.add(T_DESCRIPTOR, value.getT());
}
@Override
public void encode(Foo value, ObjectEncoderContext ctx) throws IOException {
ctx.add(T_DESCRIPTOR, value.getT());
}
}

private static final class Member3Encoder implements ObjectEncoder<Member3> {
static final Member3Encoder INSTANCE = new Member3Encoder();
private static final class Member3Encoder implements ObjectEncoder<Member3> {
static final Member3Encoder INSTANCE = new Member3Encoder();

@Override
public void encode(Member3 value, ObjectEncoderContext ctx) throws IOException {
}
}
@Override
public void encode(Member3 value, ObjectEncoderContext ctx) throws IOException {}
}

private static final class Member4Encoder implements ObjectEncoder<Member4> {
static final Member4Encoder INSTANCE = new Member4Encoder();
private static final class Member4Encoder implements ObjectEncoder<Member4> {
static final Member4Encoder INSTANCE = new Member4Encoder();

@Override
public void encode(Member4 value, ObjectEncoderContext ctx) throws IOException {
}
}
@Override
public void encode(Member4 value, ObjectEncoderContext ctx) throws IOException {}
}

private static final class MultiEncoder implements ObjectEncoder<Multi> {
static final MultiEncoder INSTANCE = new MultiEncoder();
private static final class MultiEncoder implements ObjectEncoder<Multi> {
static final MultiEncoder INSTANCE = new MultiEncoder();

private static final FieldDescriptor FOOT_DESCRIPTOR = FieldDescriptor.of("fooT");
private static final FieldDescriptor FOOT_DESCRIPTOR = FieldDescriptor.of("fooT");

private static final FieldDescriptor FOOU_DESCRIPTOR = FieldDescriptor.of("fooU");
private static final FieldDescriptor FOOU_DESCRIPTOR = FieldDescriptor.of("fooU");

@Override
public void encode(Multi value, ObjectEncoderContext ctx) throws IOException {
ctx.add(FOOT_DESCRIPTOR, value.getFooT());
ctx.add(FOOU_DESCRIPTOR, value.getFooU());
}
@Override
public void encode(Multi value, ObjectEncoderContext ctx) throws IOException {
ctx.add(FOOT_DESCRIPTOR, value.getFooT());
ctx.add(FOOU_DESCRIPTOR, value.getFooU());
}
}

private static final class MemberEncoder implements ObjectEncoder<Member> {
static final MemberEncoder INSTANCE = new MemberEncoder();
private static final class MemberEncoder implements ObjectEncoder<Member> {
static final MemberEncoder INSTANCE = new MemberEncoder();

@Override
public void encode(Member value, ObjectEncoderContext ctx) throws IOException {
}
}
@Override
public void encode(Member value, ObjectEncoderContext ctx) throws IOException {}
}

private static final class Member2Encoder implements ObjectEncoder<Member2> {
static final Member2Encoder INSTANCE = new Member2Encoder();
private static final class Member2Encoder implements ObjectEncoder<Member2> {
static final Member2Encoder INSTANCE = new Member2Encoder();

@Override
public void encode(Member2 value, ObjectEncoderContext ctx) throws IOException {
}
}
@Override
public void encode(Member2 value, ObjectEncoderContext ctx) throws IOException {}
}
}
Loading

0 comments on commit 21d4f15

Please sign in to comment.