Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Update to ktlint 0.21.0 #747

Merged
merged 5 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ subprojects {
}

dependencies {
ktlint 'com.github.shyiko:ktlint:0.14.0'
ktlint 'com.github.shyiko:ktlint:0.21.0'
}

task ktlint(type: JavaExec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class MockedStack_JetpackTunnelTest : MockedStack_Base() {
},
BaseErrorListener {
error -> run {
throw AssertionError("Unexpected BaseNetworkError: "
+ (error as WPComGsonNetworkError).apiError + " - " + error.message)
throw AssertionError("Unexpected BaseNetworkError: " +
(error as WPComGsonNetworkError).apiError + " - " + error.message)
}
})

Expand Down Expand Up @@ -105,8 +105,8 @@ class MockedStack_JetpackTunnelTest : MockedStack_Base() {
},
BaseErrorListener {
error -> run {
throw AssertionError("Unexpected BaseNetworkError: "
+ (error as WPComGsonNetworkError).apiError + " - " + error.message)
throw AssertionError("Unexpected BaseNetworkError: " +
(error as WPComGsonNetworkError).apiError + " - " + error.message)
}
})

Expand All @@ -115,9 +115,12 @@ class MockedStack_JetpackTunnelTest : MockedStack_Base() {
}

@Singleton
class JetpackTunnelClientForTests @Inject constructor(appContext: Context, dispatcher: Dispatcher,
requestQueue: RequestQueue, accessToken: AccessToken,
userAgent: UserAgent
class JetpackTunnelClientForTests @Inject constructor(
appContext: Context,
dispatcher: Dispatcher,
requestQueue: RequestQueue,
accessToken: AccessToken,
userAgent: UserAgent
) : BaseWPComRestClient(appContext, dispatcher, requestQueue, accessToken, userAgent) {
/**
* Wraps and exposes the protected [add] method so that tests can add requests directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ class MainFragment : Fragment() {
}
if (siteStore.hasSite()) {
val firstSite = siteStore.sites[0]
prependToLog("First site name: " + firstSite.name + " - Total sites: " + siteStore.sitesCount
+ " - rowsAffected: " + event.rowsAffected)
prependToLog("First site name: " + firstSite.name + " - Total sites: " + siteStore.sitesCount +
" - rowsAffected: " + event.rowsAffected)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class ThreeEditTextDialog : DialogFragment() {

companion object {
@JvmStatic
fun newInstance(onClickListener: Listener, text1Hint: String, text2Hint: String, text3Hint: String
fun newInstance(
onClickListener: Listener,
text1Hint: String,
text2Hint: String,
text3Hint: String
): ThreeEditTextDialog {
val fragment = ThreeEditTextDialog()
fragment.setListener(onClickListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ object JetpackTunnelGsonRequest {
*
* @param T the expected response object from the WP-API endpoint
*/
fun <T : Any> buildGetRequest(wpApiEndpoint: String, siteId: Long, params: Map<String, String>,
type: Type, listener: (T?) -> Unit, errorListener: BaseErrorListener
fun <T : Any> buildGetRequest(
wpApiEndpoint: String,
siteId: Long,
params: Map<String, String>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val wrappedParams = createTunnelParams(params, wpApiEndpoint)

Expand All @@ -126,8 +131,13 @@ object JetpackTunnelGsonRequest {
*
* @param T the expected response object from the WP-API endpoint
*/
fun <T : Any> buildPostRequest(wpApiEndpoint: String, siteId: Long, body: Map<String, Any>,
type: Type, listener: (T?) -> Unit, errorListener: BaseErrorListener
fun <T : Any> buildPostRequest(
wpApiEndpoint: String,
siteId: Long,
body: Map<String, Any>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val wrappedBody = createTunnelBody(method = "post", body = body, path = wpApiEndpoint)
return buildWrappedPostRequest(siteId, wrappedBody, type, listener, errorListener)
Expand All @@ -145,8 +155,13 @@ object JetpackTunnelGsonRequest {
*
* @param T the expected response object from the WP-API endpoint
*/
fun <T : Any> buildPatchRequest(wpApiEndpoint: String, siteId: Long, body: Map<String, Any>,
type: Type, listener: (T?) -> Unit, errorListener: BaseErrorListener
fun <T : Any> buildPatchRequest(
wpApiEndpoint: String,
siteId: Long,
body: Map<String, Any>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val wrappedBody = createTunnelBody(method = "patch", body = body, path = wpApiEndpoint)
return buildWrappedPostRequest(siteId, wrappedBody, type, listener, errorListener)
Expand All @@ -164,8 +179,13 @@ object JetpackTunnelGsonRequest {
*
* @param T the expected response object from the WP-API endpoint
*/
fun <T : Any> buildPutRequest(wpApiEndpoint: String, siteId: Long, body: Map<String, Any>,
type: Type, listener: (T?) -> Unit, errorListener: BaseErrorListener
fun <T : Any> buildPutRequest(
wpApiEndpoint: String,
siteId: Long,
body: Map<String, Any>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val wrappedBody = createTunnelBody(method = "put", body = body, path = wpApiEndpoint)
return buildWrappedPostRequest(siteId, wrappedBody, type, listener, errorListener)
Expand All @@ -183,15 +203,24 @@ object JetpackTunnelGsonRequest {
*
* @param T the expected response object from the WP-API endpoint
*/
fun <T : Any> buildDeleteRequest(wpApiEndpoint: String, siteId: Long, params: Map<String, String>,
type: Type, listener: (T?) -> Unit, errorListener: BaseErrorListener
fun <T : Any> buildDeleteRequest(
wpApiEndpoint: String,
siteId: Long,
params: Map<String, String>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val wrappedBody = createTunnelBody(method = "delete", params = params, path = wpApiEndpoint)
return buildWrappedPostRequest(siteId, wrappedBody, type, listener, errorListener)
}

private fun <T : Any> buildWrappedPostRequest(siteId: Long, wrappedBody: Map<String, Any>, type: Type,
listener: (T?) -> Unit, errorListener: BaseErrorListener
private fun <T : Any> buildWrappedPostRequest(
siteId: Long,
wrappedBody: Map<String, Any>,
type: Type,
listener: (T?) -> Unit,
errorListener: BaseErrorListener
): WPComGsonRequest<JetpackTunnelResponse<T>>? {
val tunnelRequestUrl = getTunnelApiUrl(siteId)
val wrappedType = TypeToken.getParameterized(JetpackTunnelResponse::class.java, type).type
Expand All @@ -212,8 +241,12 @@ object JetpackTunnelGsonRequest {
return finalParams
}

private fun createTunnelBody(method: String, body: Map<String, Any> = mapOf(),
params: Map<String, String> = mapOf(), path: String): MutableMap<String, Any> {
private fun createTunnelBody(
method: String,
body: Map<String, Any> = mapOf(),
params: Map<String, String> = mapOf(),
path: String
): MutableMap<String, Any> {
val finalBody = mutableMapOf<String, Any>()
with(finalBody) {
put("path", buildRestApiPath(path, params, method))
Expand All @@ -226,7 +259,7 @@ object JetpackTunnelGsonRequest {
}

private fun buildRestApiPath(path: String, params: Map<String, String>, method: String): String {
var result = path + "&_method=" + method
var result = "$path&_method=$method"
if (params.isNotEmpty()) {
for (param in params) {
result += "&" + URLEncoder.encode(param.key, "UTF-8") + "=" + URLEncoder.encode(param.value, "UTF-8")
Expand Down