Skip to content

Commit 836fbe9

Browse files
committed
Keep the style gods happy!
1 parent f9a12b6 commit 836fbe9

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/metrics/validator/PerfMetricValidator.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,21 @@ public static void validateAttribute(@NonNull Map.Entry<String, String> attribut
148148
} else if (value == null || value.length() == 0) {
149149
throw new IllegalArgumentException("Attribute value must not be null or empty");
150150
} else if (key.length() > Constants.MAX_ATTRIBUTE_KEY_LENGTH) {
151-
throw new IllegalArgumentException(String.format(
152-
Locale.US,
153-
"Attribute key length must not exceed %d characters",
154-
Constants.MAX_ATTRIBUTE_KEY_LENGTH));
151+
throw new IllegalArgumentException(
152+
String.format(
153+
Locale.US,
154+
"Attribute key length must not exceed %d characters",
155+
Constants.MAX_ATTRIBUTE_KEY_LENGTH));
155156
} else if (value.length() > Constants.MAX_ATTRIBUTE_VALUE_LENGTH) {
156-
throw new IllegalArgumentException(String.format(
157-
Locale.US,
158-
"Attribute value length must not exceed %d characters",
159-
Constants.MAX_ATTRIBUTE_VALUE_LENGTH));
157+
throw new IllegalArgumentException(
158+
String.format(
159+
Locale.US,
160+
"Attribute value length must not exceed %d characters",
161+
Constants.MAX_ATTRIBUTE_VALUE_LENGTH));
160162
} else if (!key.matches("^(?!(firebase_|google_|ga_))[A-Za-z][A-Za-z_0-9]*")) {
161-
throw new IllegalArgumentException("Attribute key must start with letter, must only contain alphanumeric characters and"
162-
+ " underscore and must not start with \"firebase_\", \"google_\" and \"ga_");
163+
throw new IllegalArgumentException(
164+
"Attribute key must start with letter, must only contain alphanumeric characters and"
165+
+ " underscore and must not start with \"firebase_\", \"google_\" and \"ga_");
163166
}
164167
}
165168

firebase-perf/src/test/java/com/google/firebase/perf/metrics/validator/FirebasePerfTraceValidatorTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,15 @@ public void traceValidator_customAttributeWithNumberPrefix_marksPerfMetricInvali
182182

183183
@Test
184184
public void traceValidator_customAttributeWithGooglePrefix_marksPerfMetricInvalid() {
185-
TraceMetric.Builder trace = createValidTraceMetric().putCustomAttributes("google_test", "value");
185+
TraceMetric.Builder trace =
186+
createValidTraceMetric().putCustomAttributes("google_test", "value");
186187
assertThat(new FirebasePerfTraceValidator(trace.build()).isValidPerfMetric()).isFalse();
187188
}
188189

189190
@Test
190191
public void traceValidator_customAttributeWithFirebasePrefix_marksPerfMetricInvalid() {
191-
TraceMetric.Builder trace = createValidTraceMetric().putCustomAttributes("firebase_test", "value");
192+
TraceMetric.Builder trace =
193+
createValidTraceMetric().putCustomAttributes("firebase_test", "value");
192194
assertThat(new FirebasePerfTraceValidator(trace.build()).isValidPerfMetric()).isFalse();
193195
}
194196

@@ -223,7 +225,8 @@ public void traceValidator_customAttributeWithLongKey_marksPerfMetricInvalid() {
223225
for (int i = 0; i <= Constants.MAX_ATTRIBUTE_KEY_LENGTH; i++) {
224226
longString.append("a");
225227
}
226-
TraceMetric.Builder trace = createValidTraceMetric().putCustomAttributes(longString.toString(), "value");
228+
TraceMetric.Builder trace =
229+
createValidTraceMetric().putCustomAttributes(longString.toString(), "value");
227230
assertThat(new FirebasePerfTraceValidator(trace.build()).isValidPerfMetric()).isFalse();
228231
}
229232

@@ -234,10 +237,11 @@ public void traceValidator_customAttributeWithLongValue_marksPerfMetricInvalid()
234237
for (int i = 0; i <= Constants.MAX_ATTRIBUTE_VALUE_LENGTH; i++) {
235238
longString.append("a");
236239
}
237-
TraceMetric.Builder trace = createValidTraceMetric().putCustomAttributes("key", longString.toString());
240+
TraceMetric.Builder trace =
241+
createValidTraceMetric().putCustomAttributes("key", longString.toString());
238242
assertThat(new FirebasePerfTraceValidator(trace.build()).isValidPerfMetric()).isFalse();
239243
}
240-
244+
241245
@Test
242246
public void testIsValid() {
243247
TraceMetric.Builder trace = createValidTraceMetric().putCounters("counter", 2);

0 commit comments

Comments
 (0)