Make use of linting
On Android, you can use Android Lint to improve the quality of your code.
Android Lint is bundled with Android Studio and enabled by default. It automatically performs checks for Kotlin, Java and XML source files.
You can suppress lint warning by using the @SuppressLint annotation. This can be useful in situations where a lint check is not relevant, or it is the only possible way to implement the desired behavior.
To manually run configured lint and other IDE inspections, select Code > Inspect Code. The results of the inspection appear in the Inspection Results window.
kotlin
// Suppressing java script enabled warning
val webView: WebView
@SuppressLint("SetJavaScriptEnabled")
webView.settings.javaScriptEnabled = true On Jetpack Compose, you can use Android Lint to improve the quality of your code.
Android Lint is bundled with Android Studio and enabled by default. It automatically performs checks for Kotlin, Java and XML source files.
You can suppress lint warning by using the @SuppressLint annotation. This can be useful in situations where a lint check is not relevant, or it is the only possible way to implement the desired behavior.
To manually run configured lint and other IDE inspections, select Code > Inspect Code. The results of the inspection appear in the Inspection Results window.
kotlin
// Suppress warning for experimental compose api
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun ApptFocusRequester(modifier: Modifier = Modifier) {
val (first, second, third, fourth) = remember { FocusRequester.createRefs() }
// Composable content ...
} On iOS you can use SwiftLint to improve the quality of your code.
Avoid errors with automated testing. On iOS you can use the XCTest framework.
swift
swiftlint lint For SwiftUI projects, you can use SwiftLint to maintain and improve the quality of your code.
To prevent errors and ensure your SwiftUI code works as expected, use automated testing with the XCTest framework.
swift
swiftlint lint Flutter ships with a built-in linter named flutter_lints. Run flutter analyze . in the root of a project to return all usages of deprecated code.
If possible, always update Flutter to the newest version.
Avoid errors with automated testing. Follow the How to test a Flutter App - Codelab to get started.
dart
flutter analyze . React Native ships a built-in linter named ESLint.
If possible, always update React Native to the newest version.
Avoid errors with automated testing. Follow the Testing guide to get started.
jsx
npx eslint "project/**" In MAUI, there is no linting tool itself, but the .NET build command (included in Visual Studio, Visual Studio for Mac, Visual Studio Code, and many other IDEs and text editors) always provides warning messages when code may have potential errors.
csharp
// No code required With Xamarin, you can can use a lint tool with Xamarin.Android projects. Set the property AndroidLintEnabled to true in your .csproj.
Unfortunately, there is no built-in lint tool for Xamarin.iOS projects.
xml
<AndroidLintEnabled>true</AndroidLintEnabled>