Skip to content

Commit c3336fe

Browse files
fix linting issue and adress review comment
1 parent 0f6d71a commit c3336fe

25 files changed

Lines changed: 395 additions & 431 deletions

File tree

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/checkout@v4
4949
with:
5050
repository: mparticle/mparticle-android-sdk
51-
ref: developmentreq
51+
ref: ${{ inputs.branch_name }}
5252
submodules: recursive
5353
- name: "Import GPG Key"
5454
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef #v6.0

.trunk/trunk.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ lint:
4040
ignore:
4141
- linters: [ALL]
4242
paths:
43-
- feature/legacy/**
4443
- gradlew
4544
- linters:
4645
- checkov
47-
paths:
48-
- core/network/**/*.json
4946
actions:
5047
enabled:
5148
- trunk-announce

android-core/src/androidTest/java/com/mparticle/internal/MParticleJSInterfaceITest.java

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -69,98 +69,98 @@ public class MParticleJSInterfaceITest extends BaseCleanStartedEachTest {
6969
private static String bridgeToken = new RandomUtils().getAlphaString(5);
7070
private static String bridgeVersion = "2";
7171

72-
private static final String jsStartupMParticle = "window.mParticle = {\n"
73-
" config: {\n"
74-
" isDevelopmentMode: true,\n"
75-
" useCookieStorage: true,\n"
76-
" identifyRequest: {\n"
77-
" userIdentities: { email: 'email@example.com', customerid: '123456' }\n"
78-
" },\n "
79-
" requiredWebviewBridgeName: \"" + bridgeToken + "\",\n"
80-
" minWebviewBridgeVersion:\"" + bridgeVersion + "\"\n"
81-
" }\n"
82-
" };"
83-
" window.mParticle = window.mParticle || {};\n"
84-
" window.mParticle.config = window.mParticle.config || {};\n"
85-
" window.mParticle.config.rq = [];\n"
86-
" window.mParticle.ready = function (f) {\n"
87-
" window.mParticle.config.rq.push(f);\n"
88-
" console.log(\"pushed f\");\n"
72+
private static final String jsStartupMParticle = "window.mParticle = {\n" +
73+
" config: {\n" +
74+
" isDevelopmentMode: true,\n" +
75+
" useCookieStorage: true,\n" +
76+
" identifyRequest: {\n" +
77+
" userIdentities: { email: 'email@example.com', customerid: '123456' }\n" +
78+
" },\n " +
79+
" requiredWebviewBridgeName: \"" + bridgeToken + "\",\n" +
80+
" minWebviewBridgeVersion:\"" + bridgeVersion + "\"\n" +
81+
" }\n" +
82+
" };" +
83+
" window.mParticle = window.mParticle || {};\n" +
84+
" window.mParticle.config = window.mParticle.config || {};\n" +
85+
" window.mParticle.config.rq = [];\n" +
86+
" window.mParticle.ready = function (f) {\n" +
87+
" window.mParticle.config.rq.push(f);\n" +
88+
" console.log(\"pushed f\");\n" +
8989
" };\n";
9090

9191
private static final String jsTestWrapper =
92-
" mParticle.init();\n"
93-
" mParticle.isDebug = true;\n"
94-
" console.log(\"testing started\")\n "
95-
" window.mParticle.ready(function () {\n"
96-
" console.log(\"mparticle started in JS land\");\n"
97-
"%s\n"
92+
" mParticle.init();\n" +
93+
" mParticle.isDebug = true;\n" +
94+
" console.log(\"testing started\")\n " +
95+
" window.mParticle.ready(function () {\n" +
96+
" console.log(\"mparticle started in JS land\");\n" +
97+
"%s\n" +
9898
" })\n";
9999

100-
private static final String jsSetMpidFunction = "function getCookieDomain() {\n"
101-
" var rootDomain = getDomain(document, location.hostname);\n"
102-
" if (rootDomain === '') {\n"
103-
" return '';\n"
104-
" } else {\n"
105-
" return '.' + rootDomain;\n"
106-
" }\n"
107-
"}\n"
108-
"\n"
109-
"function getDomain(doc, locationHostname) {\n"
110-
" var i,\n"
111-
" testParts,\n"
112-
" mpTest = 'mptest=cookie',\n"
113-
" hostname = locationHostname.split('.');\n"
114-
" for (i = hostname.length - 1; i >= 0; i--) {\n"
115-
" testParts = hostname.slice(i).join('.');\n"
116-
" doc.cookie = mpTest + ';domain=.' + testParts + ';';\n"
117-
" if (doc.cookie.indexOf(mpTest) > -1){\n"
118-
" doc.cookie = mpTest.split('=')[0] + '=;domain=.' + testParts + ';expires=Thu, 01 Jan 1970 00:00:01 GMT;';\n"
119-
" return testParts;\n"
120-
" }\n"
121-
" }\n"
122-
" return '';\n"
123-
"}\n"
124-
"\n"
125-
"\n"
126-
"function setCookie(cname, data, raw) {\n"
127-
" var date = new Date(),\n"
128-
" expires = new Date(date.getTime() +\n"
129-
" (365 * 24 * 60 * 60 * 1000)).toGMTString(),\n"
130-
" domain, cookieDomain,\n"
131-
" value;\n"
132-
"\n"
133-
" value = data;\n"
134-
"\n"
135-
" cookieDomain = getCookieDomain();\n"
136-
"\n"
137-
" if (cookieDomain === '') {\n"
138-
" domain = '';\n"
139-
" } else {\n"
140-
" domain = ';domain=' + cookieDomain;\n"
141-
" }\n"
142-
"\n"
143-
"var cookie = encodeURIComponent(cname) + '=' + value +\n"
144-
" ';expires=' + expires;\n"
145-
" // +\n"
146-
" // ';path=/' + domain;\n"
147-
" console.log(\"SETTNG COOKIE: \" + cookie);\n"
148-
" window.document.cookie = cookie;\n"
149-
" console.log(\"RETRIEVING cookie: \" + window.document.cookie);\n"
100+
private static final String jsSetMpidFunction = "function getCookieDomain() {\n" +
101+
" var rootDomain = getDomain(document, location.hostname);\n" +
102+
" if (rootDomain === '') {\n" +
103+
" return '';\n" +
104+
" } else {\n" +
105+
" return '.' + rootDomain;\n" +
106+
" }\n" +
107+
"}\n" +
108+
"\n" +
109+
"function getDomain(doc, locationHostname) {\n" +
110+
" var i,\n" +
111+
" testParts,\n" +
112+
" mpTest = 'mptest=cookie',\n" +
113+
" hostname = locationHostname.split('.');\n" +
114+
" for (i = hostname.length - 1; i >= 0; i--) {\n" +
115+
" testParts = hostname.slice(i).join('.');\n" +
116+
" doc.cookie = mpTest + ';domain=.' + testParts + ';';\n" +
117+
" if (doc.cookie.indexOf(mpTest) > -1){\n" +
118+
" doc.cookie = mpTest.split('=')[0] + '=;domain=.' + testParts + ';expires=Thu, 01 Jan 1970 00:00:01 GMT;';\n" +
119+
" return testParts;\n" +
120+
" }\n" +
121+
" }\n" +
122+
" return '';\n" +
123+
"}\n" +
124+
"\n" +
125+
"\n" +
126+
"function setCookie(cname, data, raw) {\n" +
127+
" var date = new Date(),\n" +
128+
" expires = new Date(date.getTime() +\n" +
129+
" (365 * 24 * 60 * 60 * 1000)).toGMTString(),\n" +
130+
" domain, cookieDomain,\n" +
131+
" value;\n" +
132+
"\n" +
133+
" value = data;\n" +
134+
"\n" +
135+
" cookieDomain = getCookieDomain();\n" +
136+
"\n" +
137+
" if (cookieDomain === '') {\n" +
138+
" domain = '';\n" +
139+
" } else {\n" +
140+
" domain = ';domain=' + cookieDomain;\n" +
141+
" }\n" +
142+
"\n" +
143+
"var cookie = encodeURIComponent(cname) + '=' + value +\n" +
144+
" ';expires=' + expires;\n" +
145+
" // +\n" +
146+
" // ';path=/' + domain;\n" +
147+
" console.log(\"SETTNG COOKIE: \" + cookie);\n" +
148+
" window.document.cookie = cookie;\n" +
149+
" console.log(\"RETRIEVING cookie: \" + window.document.cookie);\n" +
150150
"}";
151151

152-
private static final String htmlWrapper = "\n"
153-
"<html>\n"
154-
"<head>\n"
155-
" <meta charset=\"utf-8\">\n"
156-
" <title>Mocha Tests</title>\n"
157-
"</head>\n"
158-
"<body>\n"
159-
" <div id=\"mocha\"></div>\n"
160-
"<script type=\"text/javascript\">\n"
161-
"%s"
162-
"\n</script>"
163-
"</body>\n"
152+
private static final String htmlWrapper = "\n" +
153+
"<html>\n" +
154+
"<head>\n" +
155+
" <meta charset=\"utf-8\">\n" +
156+
" <title>Mocha Tests</title>\n" +
157+
"</head>\n" +
158+
"<body>\n" +
159+
" <div id=\"mocha\"></div>\n" +
160+
"<script type=\"text/javascript\">\n" +
161+
"%s" +
162+
"\n</script>" +
163+
"</body>\n" +
164164
"</html>";
165165

166166
@BeforeClass
@@ -170,16 +170,16 @@ public static void beforeClass() {
170170
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(R.raw.mparticle_js_sdk);
171171
//add in all the basic configuration stuff the server would send with a production sdk fetch from the url
172172
jsSdk = new StringBuilder()
173-
.append("window.mParticle = window.mParticle || {};;\n"
174-
"window.mParticle.config = window.mParticle.config || {};;\n"
175-
"window.mParticle.config.serviceUrl = 'jssdk.mparticle.com/v2/JS/';;\n"
176-
"window.mParticle.config.secureServiceUrl = 'jssdks.mparticle.com/v2/JS/';;\n"
177-
"window.mParticle.config.minWebviewBridgeVersion = 1;\n"
178-
"window.mParticle.config.aliasMaxWindow = 90;\n"
179-
"window.mParticle.config.kitConfigs = window.mParticle.config.kitConfigs || [];;\n"
173+
.append("window.mParticle = window.mParticle || {};;\n" +
174+
"window.mParticle.config = window.mParticle.config || {};;\n" +
175+
"window.mParticle.config.serviceUrl = 'jssdk.mparticle.com/v2/JS/';;\n" +
176+
"window.mParticle.config.secureServiceUrl = 'jssdks.mparticle.com/v2/JS/';;\n" +
177+
"window.mParticle.config.minWebviewBridgeVersion = 1;\n" +
178+
"window.mParticle.config.aliasMaxWindow = 90;\n" +
179+
"window.mParticle.config.kitConfigs = window.mParticle.config.kitConfigs || [];;\n" +
180180
"window.mParticle.config.pixelConfigs = window.mParticle.config.pixelConfigs || [];;")
181181
.append(toString(inputStream))
182-
.append("window.mParticle.config.requestConfig = false;;\n"
182+
.append("window.mParticle.config.requestConfig = false;;\n" +
183183
"mParticle.init(null, window.mParticle.config);;")
184184
.toString();
185185
} else {
@@ -312,9 +312,9 @@ public void setUserAttribute(String json) {
312312
public void testLogEvent() throws Exception {
313313
final JSONObject customAttributes = MPUtility.mapToJson(mRandomUtils.getRandomAttributes(10));
314314
final JSONObject customFlagsJSON = MPUtility.mapToJson(getCustomFlags());
315-
String testJavascript = String.format("mParticle.logEvent('Play Movie Tapped',\n"
316-
" mParticle.EventType.Navigation,\n"
317-
" %s,\n"
315+
String testJavascript = String.format("mParticle.logEvent('Play Movie Tapped'," +
316+
" mParticle.EventType.Navigation," +
317+
" %s," +
318318
" %s);", customAttributes.toString(4), customFlagsJSON.toString(4));
319319
final MutableBoolean called = new MutableBoolean(false);
320320
final CountDownLatch latch = new MPLatch(2);
@@ -369,22 +369,22 @@ public void logEvent(String json) {
369369
public void testLogCommerceEvent() throws Exception {
370370
final JSONObject customAttributes = MPUtility.mapToJson(mRandomUtils.getRandomAttributes(10));
371371
final JSONObject customFlags = MPUtility.mapToJson(getCustomFlags());
372-
String testJavascript = String.format("// 1. Create the product\n"
373-
"var product = mParticle.eCommerce.createProduct(\n"
374-
" 'Double Room - Econ Rate', //\n"
375-
" 'econ-1', \n"
376-
" 100.00, \n"
377-
" 4\n"
378-
");\n"
379-
"\n"
380-
"// 2. Summarize the transaction\n"
381-
"var transactionAttributes = {\n"
382-
" Id: 'foo-transaction-id',\n"
383-
" Revenue: 430.00,\n"
384-
" Tax: 30\n"
385-
"};\n"
386-
"\n"
387-
"// 3. Log the purchase event\n"
372+
String testJavascript = String.format("// 1. Create the product\n" +
373+
"var product = mParticle.eCommerce.createProduct(\n" +
374+
" 'Double Room - Econ Rate', //\n" +
375+
" 'econ-1', \n" +
376+
" 100.00, \n" +
377+
" 4\n" +
378+
");\n" +
379+
"\n" +
380+
"// 2. Summarize the transaction\n" +
381+
"var transactionAttributes = {\n" +
382+
" Id: 'foo-transaction-id',\n" +
383+
" Revenue: 430.00,\n" +
384+
" Tax: 30\n" +
385+
"};\n" +
386+
"\n" +
387+
"// 3. Log the purchase event\n" +
388388
"mParticle.eCommerce.logPurchase(transactionAttributes, product, true, %s, %s);", customAttributes.toString(4), customFlags);
389389

390390
final MutableBoolean called = new MutableBoolean(false);

android-core/src/androidTest/kotlin/com.mparticle/PushRegistrationTest.kt

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,10 @@ class PushRegistrationTest : BaseCleanStartedEachTest() {
6565
val fetchedSenderId = fetchedPushValue.senderId
6666
val fetchedInstanceId = fetchedPushValue.instanceId
6767
if (pushRegistration.senderId != fetchedSenderId) {
68-
Assert.fail(
69-
"Mismatch! When push value of \"" + pushRegistration.senderId + "\" is set with: " + setPush.name
70-
". A different value \""
71-
fetchedSenderId
72-
"\" is returned with:"
73-
getPush.name,
74-
)
68+
Assert.fail("Mismatch! When push value of \"" + pushRegistration.senderId + "\" is set with: " + setPush.name + ". A different value \"" + fetchedSenderId + "\" is returned with:" + getPush.name)
7569
}
7670
if (pushRegistration.instanceId != fetchedInstanceId) {
77-
Assert.fail(
78-
"Mismatch! When push value of \"" + pushRegistration.instanceId + "\" is set with: " + setPush.name
79-
". A different value \""
80-
fetchedInstanceId
81-
"\" is returned with:"
82-
getPush.name,
83-
)
71+
Assert.fail("Mismatch! When push value of \"" + pushRegistration.instanceId + "\" is set with: " + setPush.name + ". A different value \"" + fetchedInstanceId + "\" is returned with:" + getPush.name)
8472
}
8573
}
8674
}
@@ -100,13 +88,7 @@ class PushRegistrationTest : BaseCleanStartedEachTest() {
10088
for (getPush in getPushes) {
10189
val fetchedPushRegistration = getPush.pushRegistration
10290
if (fetchedPushRegistration.instanceId != null && fetchedPushRegistration.senderId != null) {
103-
Assert.fail(
104-
"Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name
105-
", and cleared with: "
106-
clearPush.name
107-
", the value is not null when fetched with:"
108-
getPush.name,
109-
)
91+
Assert.fail("Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name + ", and cleared with: " + clearPush.name + ", the value is not null when fetched with:" + getPush.name)
11092
}
11193
}
11294
}
@@ -124,24 +106,14 @@ class PushRegistrationTest : BaseCleanStartedEachTest() {
124106
setPush.setPushRegistration(pushRegistration)
125107
for (pushEnabled in pushEnableds) {
126108
if (!pushEnabled.isPushEnabled) {
127-
Assert.fail(
128-
"Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name
129-
", push IS NOT enabled with:"
130-
pushEnabled.name,
131-
)
109+
Assert.fail("Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name + ", push IS NOT enabled with:" + pushEnabled.name)
132110
}
133111
}
134112
for (clearPush in clearPushes) {
135113
clearPush.clearPush()
136114
for (pushEnabled in pushEnableds) {
137115
if (pushEnabled.isPushEnabled) {
138-
Assert.fail(
139-
"Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name
140-
", and cleared with: "
141-
clearPush.name
142-
", push IS enabled with:"
143-
pushEnabled.name,
144-
)
116+
Assert.fail("Mismatch! When push value of \"" + pushRegistration + "\" is set with: " + setPush.name + ", and cleared with: " + clearPush.name + ", push IS enabled with:" + pushEnabled.name)
145117
}
146118
}
147119
}

android-core/src/androidTest/kotlin/com.mparticle/internal/database/UpgradeMessageTableTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ class UpgradeMessageTableTest : BaseTableTest() {
4848

4949
companion object {
5050
const val CREATE_MESSAGES_DDL =
51-
"CREATE TABLE IF NOT EXISTS " + MessageTable.MessageTableColumns.TABLE_NAME + " (" + BaseColumns._ID
52-
" INTEGER PRIMARY KEY AUTOINCREMENT, "
53-
MessageTable.MessageTableColumns.SESSION_ID + " STRING NOT NULL, "
54-
MessageTable.MessageTableColumns.API_KEY + " STRING NOT NULL, "
55-
MessageTable.MessageTableColumns.MESSAGE + " TEXT, "
56-
MessageTable.MessageTableColumns.STATUS + " INTEGER, "
57-
MessageTable.MessageTableColumns.CREATED_AT + " INTEGER NOT NULL, "
58-
MessageTable.MessageTableColumns.MESSAGE_TYPE + " TEXT, "
59-
MessageTable.MessageTableColumns.CF_UUID + " TEXT, "
60-
MessageTable.MessageTableColumns.MP_ID + " INTEGER"
51+
"CREATE TABLE IF NOT EXISTS " + MessageTable.MessageTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
52+
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
53+
MessageTable.MessageTableColumns.SESSION_ID + " STRING NOT NULL, " +
54+
MessageTable.MessageTableColumns.API_KEY + " STRING NOT NULL, " +
55+
MessageTable.MessageTableColumns.MESSAGE + " TEXT, " +
56+
MessageTable.MessageTableColumns.STATUS + " INTEGER, " +
57+
MessageTable.MessageTableColumns.CREATED_AT + " INTEGER NOT NULL, " +
58+
MessageTable.MessageTableColumns.MESSAGE_TYPE + " TEXT, " +
59+
MessageTable.MessageTableColumns.CF_UUID + " TEXT, " +
60+
MessageTable.MessageTableColumns.MP_ID + " INTEGER" +
6161
");"
6262
}
6363
}

0 commit comments

Comments
 (0)