How to Automatically Fix Your Code Style With Ktlint - Android Studio Tutorial

  Рет қаралды 27,612

Philipp Lackner

Philipp Lackner

Күн бұрын

In this video you'll learn how you can use ktlint to automatically check and format your code to follow all your coding guidelines.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/...
💻 Let me be your mentor and become an industry-ready Android developer in 10 weeks:
pl-coding.com/...
Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/...
Join this channel to get access to perks:
/ @philipplackner
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/phi...
You like my free content? Here you can buy me a coffee:
www.buymeacoff...

Пікірлер: 67
@olegleonov1310
@olegleonov1310 Жыл бұрын
Why don't you use a more general solution, for example, detekt? It shows problems right in the IDE without build, has its own rules, can generate reports and can be added in Gradle build.
@Zefanya-Teki
@Zefanya-Teki Жыл бұрын
What are the downsides of using detekt straight in the IDE? We use it at work, but we only run it manually (usually before comitting)
@amrel-madah5277
@amrel-madah5277 Жыл бұрын
@@Zefanya-Teki U can use pre-commit or pre-pish as a githook to run that check automatically before every commit or push
@Zefanya-Teki
@Zefanya-Teki Жыл бұрын
@@amrel-madah5277 Thanks :)
@kotl4931
@kotl4931 Жыл бұрын
detekt has a wrapper for ktlint , it also allow to auto-correct if enabled .the advantage of using the wrapper is that you can see all the formatting rules in config.yaml instead of jumping to the reports files
@tonnie7079
@tonnie7079 Жыл бұрын
Reminds me of Police who maintain order, KtLint would be ideal to stop my code running berserk. Thanks for sharing.
@dotneko9059
@dotneko9059 Жыл бұрын
Oh yes. Ktlint is awesome. Great video as always, Phillip
@leosvxy
@leosvxy Жыл бұрын
Great tutorial Philipp ! , but there are somethings that are different now, could you do an updated video please? , that would be awesome, Thanks in advanced!
@maximooze3196
@maximooze3196 Жыл бұрын
Next SonarQube @Philipp 👍🏻, thank you for another good content.
@lakshminarayanacharan837
@lakshminarayanacharan837 Жыл бұрын
Wonderful stuff philipp Love from India
@minds_clear_02.23_
@minds_clear_02.23_ 4 ай бұрын
Perfect! It's really simple! Philipp, thank you!!!
@BapeRuLLZ
@BapeRuLLZ Жыл бұрын
How we did it when I worked with a team is that we agreed upon a code formatting style we all liked and then one of us configured it in android studio in the code auto-formatting options and then he shared the config file with the rest of the team and we imported it. Then you turn on auto formatting on save, or just get used to using ctrl+alt+L and there you go.
@aviksutar
@aviksutar Жыл бұрын
best!! falling in love with every tutorials of yours
@smart1hashi
@smart1hashi Жыл бұрын
Beautiful Explanation. Do you have playlist for beginners but not soon beginners to learn from Just saw your channel first time today and subscribed straight after this video
@Adam0001
@Adam0001 Жыл бұрын
On time 😊, Thanks Philipp 💐
@amirhosseinghafoorian9985
@amirhosseinghafoorian9985 Жыл бұрын
so useful video, I will definitely use it in my project
@vitalijuskolinko9011
@vitalijuskolinko9011 6 ай бұрын
Thank you, my master :) Nice plugin, but it works a little bit buggy - sometimes it doesn't show changes in COMMIT section after I run ./gradlew-ktlintFormat. Need to restart Android Studio :)
@Another0neTime
@Another0neTime Жыл бұрын
All your video are belong to us. But seriously, great video.
@dharamveergupta1305
@dharamveergupta1305 Жыл бұрын
It was a great guide, Can you make one set-up guide for SonarQube for SonarLint.
@taar1
@taar1 Жыл бұрын
Is this an official tool from JetBrains or Google or private third party?
@moumnalmunawy1806
@moumnalmunawy1806 Жыл бұрын
Why people use sealed class for navigation instead of enum?
@rhen4610
@rhen4610 Жыл бұрын
He already made his statement about that on another video
@purplehazer417
@purplehazer417 Жыл бұрын
enum on steroids
@UpLiftingU007
@UpLiftingU007 Жыл бұрын
How you will pase any paramter with enums?
@fernando_s97
@fernando_s97 Жыл бұрын
because of parameters
@moumnalmunawy1806
@moumnalmunawy1806 Жыл бұрын
@@UpLiftingU007 you can via the constructor
@alexandervlasik7178
@alexandervlasik7178 Жыл бұрын
Philipp, thank you very much. I really enjoy your videos. Do not stop, please. And why did you stop to make android news videos?
@PhilippLackner
@PhilippLackner Жыл бұрын
Thanks! In the past months there weren't any major changes worth to make a whole video about I felt like. I'll make them when something cool changes :)
@easybusinessou
@easybusinessou Жыл бұрын
Thanks
@masti437
@masti437 Жыл бұрын
Hi Philip ... I am a subscriber of your paid courses ... The content you add are amazing and valuable and I love it. I want to request a content ............... We use git with android studio right via terminal and via UI interface .... can you show all the stuff that you can do with the UI in android studio git functions(Not via terminal) .... there are no source materials on this on internet .... Thank you
@AhmedBenFadhel
@AhmedBenFadhel Жыл бұрын
Thank you for this video. I want to know what to do to make ktlint run on a specific buildType (for example debug BuildType) and having as a result only one report "KtlintDebugSourceSetCheck" ?
@marlonlom
@marlonlom Жыл бұрын
Ktlint is great! how to use it across all modules for the gradle project?
@e4basil
@e4basil Жыл бұрын
nicely explained
@safionweb
@safionweb Жыл бұрын
Great content 👑
@Daaaaaaavid
@Daaaaaaavid Жыл бұрын
"Task with path 'ktlintFormat' not found in project"?
@stanleykou5643
@stanleykou5643 Жыл бұрын
Awesome!
@ewomer100
@ewomer100 Жыл бұрын
Is there a way to get this to work if you refactor change the name of the source directory 'java' to 'kotlin' ? As it is now the formatting only works if the sub folder's name is java
@mustafaammar551
@mustafaammar551 Жыл бұрын
very cool vedeo you are the best
@abdulraafay5226
@abdulraafay5226 Жыл бұрын
Hi, could you make a video on how to cache images that were retrieved from a network request.
@simonwambua3710
@simonwambua3710 Жыл бұрын
Whats the difference in usage between ktlint and spotless?
@CHIchangching
@CHIchangching Жыл бұрын
Philipp, can you please share how to set ktlint for specific folder or path only? I tried with in Android block sourceSets { main { java.srcDirs = ['src/main/java'] res.srcDirs = ['src/main/res'] manifest.srcFile 'src/main/AndroidManifest.xml' } } but when i ran ktlint, it still by default runs for AndroidTests, and Test folder. Any ideas?
@purplehazer417
@purplehazer417 Жыл бұрын
thanks, just thought about that :)
@Leon-un2ii
@Leon-un2ii Жыл бұрын
Could you also make a tutorial on how to make an app lock screen with a password or pin, please?
@tonnie7079
@tonnie7079 Жыл бұрын
Any idea on how to do it using Kotlin DSL
@pr0adam
@pr0adam Жыл бұрын
sometimes android studio wont even know the lazy list syntax if you dont do the wildcard import lols
@mandroidx1474
@mandroidx1474 Жыл бұрын
How about sonarLint?
@medium010
@medium010 Жыл бұрын
./gradlew: Permission denied
@Theloftyt
@Theloftyt Жыл бұрын
works gj
@ArunKumar-vu5bd
@ArunKumar-vu5bd Жыл бұрын
When you prebuild ktlint error every time, doesn't it increase the build time?
@sachinmalik9574
@sachinmalik9574 Жыл бұрын
yes it does, other alternative is to run it precommit
@PhilippLackner
@PhilippLackner Жыл бұрын
Yep that works too 👍
@renzcarlosalanga1970
@renzcarlosalanga1970 Жыл бұрын
detekt is better in static code analysis
@sheikhs4896
@sheikhs4896 Жыл бұрын
In an Android developer i also want to work in Germany..
@sergioqcostas
@sergioqcostas Жыл бұрын
I love your videos but hate every lint out there, lol.
@wiiznokes2237
@wiiznokes2237 Жыл бұрын
There is a shortcut for doing that automaticaly i think
@PhilippLackner
@PhilippLackner Жыл бұрын
And who wants to go into every file manually and apply that shortcut? 😂
@flavouredflight8628
@flavouredflight8628 Жыл бұрын
ah yes! ctrl+alt+l
@wiiznokes2237
@wiiznokes2237 Жыл бұрын
@@flavouredflight8628 Yes! And you can select a directory, otherwise CTRL + SHIFT + ALT + L
@simpleuxapps8759
@simpleuxapps8759 Жыл бұрын
@@wiiznokes2237 That shortcut handles only formatting issues. It dosen't addresses other lint issues, such as unused imports.
@salvadorjohndeniel
@salvadorjohndeniel Жыл бұрын
@@simpleuxapps8759 It also removes unused imports
@alnoormajzoob2507
@alnoormajzoob2507 Жыл бұрын
I have learned a lot of because of u, thanks 🙏. Can we msg at whatsapp?
So Cute 🥰
00:17
dednahype
Рет қаралды 45 МЛН
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 72 МЛН
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 65 МЛН
~/.dotfiles in 100 Seconds
13:54
Fireship
Рет қаралды 417 М.
How to Automate Tasks Using Gradle - Android Studio Tutorial
18:55
Philipp Lackner
Рет қаралды 27 М.
Nothing is really cool in Kotlin
7:43
Sebastian Sellmair
Рет қаралды 4,2 М.
Don't Do These Fatal Mistakes With a Multi-Module Architecture
10:19
Philipp Lackner
Рет қаралды 41 М.
Игорь Таланкин - Custom Lint Rules
47:14
Mobius
Рет қаралды 1,2 М.
To Detekt 2.0, and beyond! by Nicola Corti
45:22
Kotlin by JetBrains
Рет қаралды 5 М.
The Most Legendary Programmers Of All Time
11:49
Aaron Jack
Рет қаралды 557 М.
Should You Use Compose State or StateFlow in Your ViewModels?
13:59
Philipp Lackner
Рет қаралды 76 М.
Building a Mobile App in 2024: The BEST Technologies
13:31
Dan Ilies
Рет қаралды 28 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 45 МЛН