Skip to content

Commit ab78a22

Browse files
Merge pull request #219 from Countly/codacy_useshortarray
[Android] UseShortArrayInitializer #Codacy
2 parents 7aee965 + 0bbe7b7 commit ab78a22

20 files changed

+43
-43
lines changed

app/src/main/java/ly/count/android/demo/ActivityExampleAPM.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
public class ActivityExampleAPM extends AppCompatActivity {
1414

15-
int[] successCodes = new int[] { 100, 101, 200, 201, 202, 205, 300, 301, 303, 305 };
16-
int[] failureCodes = new int[] { 400, 402, 405, 408, 500, 501, 502, 505 };
15+
int[] successCodes = { 100, 101, 200, 201, 202, 205, 300, 301, 303, 305 };
16+
int[] failureCodes = { 400, 402, 405, 408, 500, 501, 502, 505 };
1717

1818
Random rnd = new Random();
1919

app/src/main/java/ly/count/android/demo/ActivityExampleCrashReporting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void EmptyFunction_3() {
3333
public void onClickOutOfBounds(View v) {
3434
Countly.sharedInstance().crashes().addCrashBreadcrumb("Out of bounds crash");
3535
//noinspection MismatchedReadAndWriteOfArray
36-
int[] data = new int[] {};
36+
int[] data = {};
3737
data[0] = 9;
3838
}
3939

app/src/main/java/ly/count/android/demo/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void onCreate() {
8484
}
8585

8686
//sample certificate for the countly try server
87-
String[] certificates = new String[] {
87+
String[] certificates = {
8888
"MIIGnjCCBYagAwIBAgIRAN73cVA7Y1nD+S8rToAqBpQwDQYJKoZIhvcNAQELBQAwgY8xCzAJ"
8989
+ "BgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1"
9090
+ "NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UEAxMuU2VjdGln"

sdk/src/androidTest/java/ly/count/android/sdk/CountlyConfigTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void constructor() {
3636

3737
@Test
3838
public void settingAllValues() {
39-
String[] s = new String[] { "4234234234ff", "sssa2323", "sds", "sdfsdf232", "aa22", "xvcx", "hghn", "0gifg", "kfkfdd" };
39+
String[] s = { "4234234234ff", "sssa2323", "sds", "sdfsdf232", "aa22", "xvcx", "hghn", "0gifg", "kfkfdd" };
4040
Context c = getContext();
4141
CountlyConfig config = new CountlyConfig();
4242
CountlyStore cs = new CountlyStore(c, mock(ModuleLog.class));
@@ -63,7 +63,7 @@ public void onDismiss() {
6363
hv.put("11", "22");
6464
hv.put("1331", "2332");
6565

66-
String[] fn = new String[] { "ds dsd", "434f", "ngfhg" };
66+
String[] fn = { "ds dsd", "434f", "ngfhg" };
6767

6868
CrashFilterCallback callback = new CrashFilterCallback() {
6969
@Override
@@ -78,12 +78,12 @@ public boolean filterCrash(String crash) {
7878
vs.put("s44s", 33_434.33d);
7979
vs.put("dds44s", true);
8080

81-
Class[] act = new Class[] { Activity.class };
81+
Class[] act = { Activity.class };
8282

83-
String[] appCrawlerNames = new String[] { "Some", "Crazy", "name" };
83+
String[] appCrawlerNames = { "Some", "Crazy", "name" };
8484

85-
String[] publicKeyCerts = new String[] { "ddd", "111", "ffd" };
86-
String[] certificateCerts = new String[] { "ddsd", "vvcv", "mbnb" };
85+
String[] publicKeyCerts = { "ddd", "111", "ffd" };
86+
String[] certificateCerts = { "ddsd", "vvcv", "mbnb" };
8787

8888
Map<String, Object> crashSegments = new HashMap<>();
8989
crashSegments.put("s2s", "fdf");

sdk/src/androidTest/java/ly/count/android/sdk/CountlyStoreTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ public void addRequest_MaxQueueLimit() {
582582
*/
583583
@Test
584584
public void testDeviceIDStorage() {
585-
String[] values = new String[] { "aa", null, "bb", "", "cc" };
586-
String[] values2 = new String[] { "11", "22", null, "33", "" };
585+
String[] values = { "aa", null, "bb", "", "cc" };
586+
String[] values2 = { "11", "22", null, "33", "" };
587587

588588
assertNull(sp.getDeviceID());
589589
assertNull(sp.getDeviceIDType());

sdk/src/androidTest/java/ly/count/android/sdk/EventTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,12 @@ public void toJSON_sumNaNCausesJSONException() throws JSONException {
595595
*/
596596
@Test
597597
public void segmentationSorterFull() {
598-
String[] keys = new String[] { "a", "b", "c", "d", "e", "f", "l", "r", "q", "w", "m" };
598+
String[] keys = { "a", "b", "c", "d", "e", "f", "l", "r", "q", "w", "m" };
599599

600600
Map<String, Object> automaticViewSegmentation = new HashMap<>();
601601

602602
Object obj = new Object();
603-
int[] arr = new int[] { 1, 2, 3 };
603+
int[] arr = { 1, 2, 3 };
604604

605605
automaticViewSegmentation.put(keys[0], 2);
606606
automaticViewSegmentation.put(keys[1], 12);

sdk/src/androidTest/java/ly/count/android/sdk/ModuleConsentTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@RunWith(AndroidJUnit4.class)
1616
public class ModuleConsentTests {
1717

18-
protected static final String[] usedFeatureNames = new String[] {
18+
protected static final String[] usedFeatureNames = {
1919
Countly.CountlyFeatureNames.sessions,
2020
Countly.CountlyFeatureNames.events,
2121
Countly.CountlyFeatureNames.views,
@@ -205,7 +205,7 @@ public void initTimeNoConsentGivenRQ() throws JSONException {
205205
@Test
206206
public void initTimeSetConsentRQ_2() throws JSONException {
207207
RequestQueueProvider rqp = mock(RequestQueueProvider.class);
208-
String[] initialConsent = new String[] { Countly.CountlyFeatureNames.clicks, Countly.CountlyFeatureNames.push, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback };
208+
String[] initialConsent = { Countly.CountlyFeatureNames.clicks, Countly.CountlyFeatureNames.push, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback };
209209
Countly mCountly = new Countly().init(TestUtils.createConsentCountlyConfig(true, initialConsent, null, rqp));
210210

211211
//this should send consent state and empty location
@@ -222,7 +222,7 @@ public void initTimeSetConsentRQ_2() throws JSONException {
222222
@Test
223223
public void initTimeSetConsentRQ_3() throws JSONException {
224224
RequestQueueProvider rqp = mock(RequestQueueProvider.class);
225-
String[] initialConsent = new String[] { Countly.CountlyFeatureNames.clicks, Countly.CountlyFeatureNames.push, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback, Countly.CountlyFeatureNames.location };
225+
String[] initialConsent = { Countly.CountlyFeatureNames.clicks, Countly.CountlyFeatureNames.push, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback, Countly.CountlyFeatureNames.location };
226226
Countly mCountly = new Countly().init(TestUtils.createConsentCountlyConfig(true, initialConsent, null, rqp));
227227

228228
TestUtils.verifyConsentValuesInRQMock(1, initialConsent, TestUtils.getReminderConsent(initialConsent), rqp);
@@ -238,7 +238,7 @@ public void initTimeSetConsentRQ_3() throws JSONException {
238238
@Test
239239
public void initTimeSetConsentRQ_4() throws JSONException {
240240
RequestQueueProvider rqp = mock(RequestQueueProvider.class);
241-
String[] initialConsent = new String[] { Countly.CountlyFeatureNames.attribution, Countly.CountlyFeatureNames.starRating, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback, Countly.CountlyFeatureNames.location };
241+
String[] initialConsent = { Countly.CountlyFeatureNames.attribution, Countly.CountlyFeatureNames.starRating, Countly.CountlyFeatureNames.users, Countly.CountlyFeatureNames.feedback, Countly.CountlyFeatureNames.location };
242242
CountlyConfig cc = TestUtils.createConsentCountlyConfig(true, initialConsent, null, rqp);
243243
cc.setLocation("qw", "Böston 墨尔本", "123.9009", "qwe890");
244244
Countly mCountly = new Countly().init(cc);

sdk/src/androidTest/java/ly/count/android/sdk/ModuleRatingsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void tearDown() {
3838
public void recordManualRating() {
3939
EventProvider ep = TestUtils.setEventProviderToMock(mCountly, mock(EventProvider.class));
4040

41-
String[] vals = new String[] { "aa", "bb", "cc" };
41+
String[] vals = { "aa", "bb", "cc" };
4242
mCountly.ratings().recordManualRating(vals[0], 3, vals[1], vals[2], true);
4343

4444
final Map<String, Object> segm = new HashMap<>();

sdk/src/androidTest/java/ly/count/android/sdk/ModuleRemoteConfigTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void valuesClearedOnConsentRemoval() {
4343
Countly countly = (new Countly()).init(config);
4444

4545
//set RC
46-
String[] rcArr = new String[] { rcEStr("a", 123), rcEStr("b", "fg") };
46+
String[] rcArr = { rcEStr("a", 123), rcEStr("b", "fg") };
4747
countlyStore.setRemoteConfigValues(RemoteConfigValueStore.dataFromString(rcArrIntoJSON(rcArr), false).dataToString());
4848

4949
Assert.assertEquals(123, countly.remoteConfig().getValue("a").value);
@@ -62,7 +62,7 @@ public void valuesClearedOnConsentRemoval() {
6262
public void automaticRCTriggers() {
6363
for (int a = 0; a < 2; a++) {
6464
countlyStore.clear();
65-
final int[] triggerCounter = new int[] { 0 };
65+
final int[] triggerCounter = { 0 };
6666
int intendedCount = 0;
6767

6868
CountlyConfig config = (new CountlyConfig(getContext(), "appkey", "http://test.count.ly")).setDeviceId("1234").setLoggingEnabled(true).enableCrashReporting();

sdk/src/androidTest/java/ly/count/android/sdk/ModuleViewsTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ModuleViewsTests {
3131
//Countly mCountly;
3232
CountlyStore countlyStore;
3333

34-
String[] viewNames = new String[] { "a", "b", "c", "e", "f", "g", "h", "i" };
34+
String[] viewNames = { "a", "b", "c", "e", "f", "g", "h", "i" };
3535

3636
int idx = 0;
3737
final String[] vals = TestUtils.viewIDVals;
@@ -298,7 +298,7 @@ public void recordViewNoSegm() throws InterruptedException {
298298
Countly mCountly = new Countly().init(cc);
299299
@NonNull EventProvider ep = TestUtils.setEventProviderToMock(mCountly, mock(EventProvider.class));
300300

301-
String[] viewNames = new String[] { "DSD", "32", "DSD" };
301+
String[] viewNames = { "DSD", "32", "DSD" };
302302

303303
final Map<String, Object> segm = new HashMap<>();
304304
ClearFillSegmentationViewStart(segm, viewNames[0], true);
@@ -588,7 +588,7 @@ public void autoSessionFlow_1() throws InterruptedException {
588588
@NonNull Activity act2 = mock(TestUtils.Activity2.class);
589589
@NonNull Activity act3 = mock(TestUtils.Activity3.class);
590590

591-
String viewNames[] = new String[] { act.getClass().getSimpleName(), act2.getClass().getSimpleName(), act3.getClass().getSimpleName() };
591+
String viewNames[] = { act.getClass().getSimpleName(), act2.getClass().getSimpleName(), act3.getClass().getSimpleName() };
592592
final Map<String, Object> segm = new HashMap<>();
593593

594594
//go from one activity to another in the expected way and then "go to background"

0 commit comments

Comments
 (0)