diff --git a/.editorconfig b/.editorconfig index 6d07950c9..d1d074477 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,42 @@ [*] max_line_length = 150 -[*.{kt, kts}] -ktlint_disabled_rules=argument-list-wrapping,wrapping,multiline-if-else,no-consecutive-blank-lines,no-wildcard-imports,import-ordering,max-line-length,import-ordering,no-blank-line-before-rbrace,final-newline,indent,no-multi-spaces,comment-spacing,parameter-list-wrapping +ktlint_standard = enabled # Disable all rules from the `standard` rule set provided by KtLint +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_no-blank-line-before-rbrace = disabled +ktlint_standard_no-wildcard-imports = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_property-naming = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_blank-line-before-declaration = disabled +ktlint_standard_function-expression-body = disabled +ktlint_standard_no-consecutive-blank-lines = disabled +ktlint_standard_string-template-indent = disabled +ktlint_standard_wrapping = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-ktlint_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_trailing-trailing-comma-on-call-site = disabled +ktlint_standard_final-newline = enabled +ktlint_standard_comment-spacing = disabled +ktlint_standard_argument-list-wrapping = disabled +ktlint_standard_indent = disabled +ktlint_standard_if-else-bracing = disabled +ktlint_standard_if-else-wrapping = disabled +ktlint_standard_import-ordering = disabled +ktlint_standard_multiline-if-else = disabled +ktlint_standard_parameter-list-wrapping = disabled +ktlint_standard_discouraged-comment-location = disabled +ktlint_standard_enum-wrapping = disabled +ktlint_standard_annotation = disabled +ktlint_standard_no-consecutive-comments = disabled +ktlint_standard_block-comment-initial-star-alignment = disabled +ktlint_standard_parameter-list-spacing = disabled +ktlint_standard_comment-wrapping = disabled +ktlint_experimental = enabled # Enable rules marked as experimental for all rule sets that are enabled +ktlint_standard_some-experimental-rule = disabled # Disables the (experimental) `some-experimental-rule` in the `standard` rule set provided by KtLint +ktlint_custom-rule-set = enabled # Enable all rules in the `custom-rule-set` rule set (not provided by KtLint) +ktlint_custom-rule-set_custom-rule = disabled # Disables the `custom-rule` rule in the `custom-rule-set` rule set (not provided by KtLint) + diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml deleted file mode 100644 index 8b0bb685c..000000000 --- a/.github/workflows/gradle-wrapper-validation.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: "Validate Gradle Wrapper" - -on: [ pull_request ] - -jobs: - validation: - name: "Validation" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 003c895c0..6f62ddc06 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -29,6 +29,7 @@ jobs: with: distribution: 'adopt' java-version: 17 + - uses: gradle/wrapper-validation-action@v1 - name: Install Android SDK uses: hannesa2/action-android/install-sdk@0.1.4.10 - name: Run tests @@ -83,4 +84,6 @@ jobs: if: ${{ always() }} with: name: MQTT-Lint-report - path: ./**/build/reports/lint-results*.html + path: | + ./**/build/reports/lint-results*.html + ./**/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.txt diff --git a/basicSample/src/main/java/info/mqtt/java/example/MQTTExampleActivity.kt b/basicSample/src/main/java/info/mqtt/java/example/MQTTExampleActivity.kt index f1661c97a..a429ddda4 100644 --- a/basicSample/src/main/java/info/mqtt/java/example/MQTTExampleActivity.kt +++ b/basicSample/src/main/java/info/mqtt/java/example/MQTTExampleActivity.kt @@ -124,4 +124,4 @@ class MQTTExampleActivity : AppCompatActivity() { private const val publishMessage = "Hello World" private var clientId = "BasicSample" } -} \ No newline at end of file +} diff --git a/build.gradle b/build.gradle index 1250bfe67..87c483974 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { classpath 'com.android.tools.build:gradle:8.2.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.1" + classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.0" } } diff --git a/extendedSample/src/androidTest/java/info/mqtt/android/extsample/activity/ExtendedPublishTest.kt b/extendedSample/src/androidTest/java/info/mqtt/android/extsample/activity/ExtendedPublishTest.kt index 042662ca7..e105da923 100644 --- a/extendedSample/src/androidTest/java/info/mqtt/android/extsample/activity/ExtendedPublishTest.kt +++ b/extendedSample/src/androidTest/java/info/mqtt/android/extsample/activity/ExtendedPublishTest.kt @@ -26,7 +26,6 @@ import org.junit.rules.TestName import org.junit.runner.RunWith import timber.log.Timber - @RunWith(AndroidJUnit4::class) class ExtendedPublishTest { @@ -56,7 +55,7 @@ class ExtendedPublishTest { onView(withId(R.id.disConnectSwitch)).perform(click()) onView(withId(3)).perform(click()) - //onView(withTagValue(`is`("Subscribe" as Any))).perform(click()) + // onView(withTagValue(`is`("Subscribe" as Any))).perform(click()) onView(withId(R.id.subscribe_button)).perform(click()) onView(withId(R.id.subscription_topic_edit_text)).perform(typeText(TOPIC)) diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/StrictApplication.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/StrictApplication.kt index 4958028a4..79be55fc8 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/StrictApplication.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/StrictApplication.kt @@ -18,4 +18,4 @@ class StrictApplication : LoggingApplication() { .build() ) } -} \ No newline at end of file +} diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/HomeFragment.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/HomeFragment.kt index cae07ea8e..74ee7d5a5 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/HomeFragment.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/HomeFragment.kt @@ -11,4 +11,4 @@ class HomeFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_home, container, false) } -} \ No newline at end of file +} diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt index 4f820e583..f8a971ae5 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt @@ -78,4 +78,4 @@ class PublishFragment : Fragment() { companion object { var DEFAULT_TOPIC = "/test" } -} \ No newline at end of file +} diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt index bce7f1675..684d52f64 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt @@ -80,4 +80,4 @@ class SubscriptionFragment : Fragment() { alert.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) alert.show() } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceTest.kt b/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceTest.kt index 8b42275f8..857161dc6 100755 --- a/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceTest.kt +++ b/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceTest.kt @@ -774,4 +774,4 @@ class AndroidServiceTest : IMqttActionListener { private val classSimpleName = this::class.java.simpleName private val TAG = classSimpleName } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceWithActionListenerTest.kt b/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceWithActionListenerTest.kt index be5908b11..1289e2ef7 100644 --- a/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceWithActionListenerTest.kt +++ b/serviceLibrary/src/androidTest/java/info/mqtt/android/AndroidServiceWithActionListenerTest.kt @@ -498,4 +498,4 @@ class AndroidServiceWithActionListenerTest { private val classCanonicalName = this::class.java.canonicalName private val TAG = classCanonicalName } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/androidTest/java/info/mqtt/android/MqttReceiver.kt b/serviceLibrary/src/androidTest/java/info/mqtt/android/MqttReceiver.kt index 5e1aa758d..aec59c171 100644 --- a/serviceLibrary/src/androidTest/java/info/mqtt/android/MqttReceiver.kt +++ b/serviceLibrary/src/androidTest/java/info/mqtt/android/MqttReceiver.kt @@ -83,4 +83,4 @@ class MqttReceiver(mqttClient: IMqttAsyncClient) : MqttCallback { data class ReceivedMessage(var topic: String, var message: MqttMessage) data class ValidateResult(val ok: Boolean, var message: String) -} \ No newline at end of file +} diff --git a/serviceLibrary/src/androidTest/java/info/mqtt/android/TestProperties.kt b/serviceLibrary/src/androidTest/java/info/mqtt/android/TestProperties.kt index 3e4f8c03e..61756f0d6 100644 --- a/serviceLibrary/src/androidTest/java/info/mqtt/android/TestProperties.kt +++ b/serviceLibrary/src/androidTest/java/info/mqtt/android/TestProperties.kt @@ -74,4 +74,4 @@ internal class TestProperties(private val context: Context) { private val KEY_SERVER_SSL_URI = "SERVER_SSL_URI" private val KEY_WAIT_FOR_COMPLETION_TIME = "WAIT_FOR_COMPLETION_TIME" } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/Ack.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/Ack.kt index 54aed80e2..64887e4d8 100644 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/Ack.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/Ack.kt @@ -14,4 +14,4 @@ enum class Ack { * to [MqttAndroidClient] using [MqttAndroidClient.acknowledgeMessage] */ MANUAL_ACK -} \ No newline at end of file +} diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/MqttConnectTokenAndroid.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/MqttConnectTokenAndroid.kt index c722eb265..3b8818980 100644 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/MqttConnectTokenAndroid.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/MqttConnectTokenAndroid.kt @@ -56,4 +56,4 @@ internal class MqttConnectTokenAndroid(private val sessionPresent: Boolean) : IM override fun getResponse(): MqttWireMessage? { return null } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/MqttServiceConstants.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/MqttServiceConstants.kt index fa7c7841b..dabf308e8 100755 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/MqttServiceConstants.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/MqttServiceConstants.kt @@ -16,7 +16,7 @@ internal interface MqttServiceConstants { const val MESSAGE_ID = "messageId" const val SESSION_PRESENT = "sessionPresent" - /* Tags for actions passed between the Activity and the Service */ + // Tags for actions passed between the Activity and the Service const val SEND_ACTION = "send" const val UNSUBSCRIBE_ACTION = "unsubscribe" const val SUBSCRIBE_ACTION = "subscribe" @@ -28,10 +28,10 @@ internal interface MqttServiceConstants { const val ON_CONNECTION_LOST_ACTION = "onConnectionLost" const val TRACE_ACTION = "trace" - /* Identifies an Intent which calls back to the Activity */ + // Identifies an Intent which calls back to the Activity const val CALLBACK_TO_ACTIVITY = ".callbackToActivity.$VERSION" - /* Identifiers for extra data on Intents broadcast to the Activity */ + // Identifiers for extra data on Intents broadcast to the Activity const val CALLBACK_ACTION = ".callbackAction" const val CALLBACK_STATUS = ".callbackStatus" const val CALLBACK_CLIENT_HANDLE = ".$CLIENT_HANDLE" diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/ParcelableMqttMessage.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/ParcelableMqttMessage.kt index d01dce494..a972cf29f 100755 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/ParcelableMqttMessage.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/ParcelableMqttMessage.kt @@ -57,4 +57,4 @@ class ParcelableMqttMessage : MqttMessage, Parcelable { return arrayOfNulls(size) } } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/QoS.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/QoS.kt index 0d8462a5a..c0ef04f36 100644 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/QoS.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/QoS.kt @@ -9,8 +9,8 @@ enum class QoS(val value: Int) { companion object { @JvmStatic fun valueOf(qos: Int): QoS { - return values()[qos] + return entries[qos] } } -} \ No newline at end of file +} diff --git a/serviceLibrary/src/main/java/info/mqtt/android/service/extension/BundleExt.kt b/serviceLibrary/src/main/java/info/mqtt/android/service/extension/BundleExt.kt index a6f39187a..c5361774e 100644 --- a/serviceLibrary/src/main/java/info/mqtt/android/service/extension/BundleExt.kt +++ b/serviceLibrary/src/main/java/info/mqtt/android/service/extension/BundleExt.kt @@ -9,11 +9,11 @@ import android.os.Parcelable @Suppress("DEPRECATION") inline fun Bundle.parcelable(key: String): T? = when { SDK_INT >= 33 -> getParcelable(key, T::class.java) - else -> getParcelable(key) as? T + else -> getParcelable(key) as? T } @Suppress("DEPRECATION") inline fun Bundle.serializable(key: String): T? = when { SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java) - else -> getSerializable(key) as? T -} \ No newline at end of file + else -> getSerializable(key) as? T +}