-
-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Lint code #2834
base: dev
Are you sure you want to change the base?
chore: Lint code #2834
Conversation
This commit also changes the API, but these changes are considered fixes.
# Conflicts: # src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/HideAdsPatch.kt
@LisoUseInAIKyrios If there are other rules you want to add to |
Can the trailing commas for kotlin be turned off? I think it looks a little messy when there's trailing commas for a variable argument function with a single parameter. I cannot get Android Studio to add trailing commas to any code when using the code reformat function. Should a lint task be added to the gradle config? So at least there's a unified way to run lint? |
Ktlint is used for linting. An Android Studio plugin for it iirc exists. On save, the lint rules will be applied. Ktlint also has a Gradle plugin that we can add. It will check for lining errors on build. |
I am not entirely sure, but the version was set to 11 because of the assumption that 17 would compile incompatible bytecode for Android. Before Android 11, I believe, Java 11 was used as the target bytecode level. |
@oSumAtrIX Try running organize imports on If it makes changes to the imports, then the lint rules need adjusting otherwise imports will keep changing between Intellij and Android Studio usage. |
This is the output when I format the code: Index: src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt
--- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt (revision ab0af3ec572251b3d8f2b4c699460ed29794ac57)
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt (date 1709572468593)
@@ -31,7 +31,7 @@
IntegrationsPatch::class,
LithoFilterPatch::class,
HideShortsComponentsResourcePatch::class,
- ResourceMappingPatch::class
+ ResourceMappingPatch::class,
],
compatiblePackages = [
CompatiblePackage(
@@ -49,10 +49,10 @@
"19.02.39",
"19.03.35",
"19.03.36",
- "19.04.37"
- ]
- )
- ]
+ "19.04.37",
+ ],
+ ),
+ ],
)
@Suppress("unused")
object HideShortsComponentsPatch : BytecodePatch(
@@ -61,8 +61,8 @@
ReelConstructorFingerprint,
BottomNavigationBarFingerprint,
RenderBottomNavigationBarParentFingerprint,
- SetPivotBarVisibilityParentFingerprint
- )
+ SetPivotBarVisibilityParentFingerprint,
+ ),
) {
private const val FILTER_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/components/ShortsFilter;"
@@ -80,7 +80,7 @@
insertIndex,
viewRegister,
FILTER_CLASS_DESCRIPTOR,
- "hideShortsShelf"
+ "hideShortsShelf",
)
}
} // Do not throw an exception if not resolved.
@@ -117,7 +117,7 @@
addInstruction(
insertIndex,
"sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->pivotBar:" +
- "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;"
+ "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;",
)
}
}
@@ -144,7 +144,7 @@
addInstruction(
insertIndex,
"invoke-static { v$viewRegister }, $FILTER_CLASS_DESCRIPTOR->" +
- "hideNavigationBar(Landroid/view/View;)Landroid/view/View;"
+ "hideNavigationBar(Landroid/view/View;)Landroid/view/View;",
)
}
} ?: throw BottomNavigationBarFingerprint.exception
@@ -155,7 +155,7 @@
private enum class ShortsButtons(private val resourceName: String, private val methodName: String) {
COMMENTS("reel_dyn_comment", "hideShortsCommentsButton"),
REMIX("reel_dyn_remix", "hideShortsRemixButton"),
- SHARE("reel_dyn_share", "hideShortsShareButton")
+ SHARE("reel_dyn_share", "hideShortsShareButton"),
;
fun injectHideCall(method: MutableMethod) {
I am not sure if the ktlint plugin is actually respecting the editorconfig file. |
The ktlint plugin for Android Studio is working for me. If I remove or change the trailing line settings in editorconfig and then do ktlint format, it will add or remove the trailing commas as specified by the config. Because not everyone will have ktlint installed, the Gradle build task could run ktlint format on all code. |
Maybe It will make intellij use formatting that is closer to Android Studio, and I think that automatic turns off trailing commas (which are not recommended for kotlin android). |
Oh my bad, I am using IntelliJ IDEA exclusively, even for Integrations. Possibly we should have both, intellij idea as well as android studio linting rules for integrations |
As far as I know, Android studio does not have any lint code format warnings or checks. It only has code formatter settings. If |
For me Android Studio is formatting code correctly, and ktlint is correctly removing trailing commas. @oSumAtrIX Try on your end with intellij and see if it formats and does not use trailing commas. |
# [2.188.0-dev.17](ReVanced/revanced-patches@v2.188.0-dev.16...v2.188.0-dev.17) (2023-08-21) ### Features * **YouTube:** Add `Alternative thumbnails` patch ([ReVanced#2834](ReVanced/revanced-patches#2834)) ([8a4277c](ReVanced/revanced-patches@8a4277c))
# [2.188.0](ReVanced/revanced-patches@v2.187.0...v2.188.0) (2023-08-26) ### Bug Fixes * allow using `PreferenceScreen` outside of current module ([fe94013](ReVanced/revanced-patches@fe94013)) * **Client spoof:** Remove exception from option ([9c69f87](ReVanced/revanced-patches@9c69f87)) * **Enable android debugging:** Update patch description ([ReVanced#2869](ReVanced/revanced-patches#2869)) ([d9f0d08](ReVanced/revanced-patches@d9f0d08)) * improve wording ([26f9b05](ReVanced/revanced-patches@26f9b05)) * **Reddit is Fun - Spoof client:** Use a more convincing user agent ([236a18f](ReVanced/revanced-patches@236a18f)) * remove newline ([545388b](ReVanced/revanced-patches@545388b)) * **Tiktok - Show seekbar:** Bump compatibility ([ReVanced#2737](ReVanced/revanced-patches#2737)) ([08413bd](ReVanced/revanced-patches@08413bd)) * **YouTube - Client spoof:** Adjust spoof signature settings description ([ReVanced#2760](ReVanced/revanced-patches#2760)) ([f71d893](ReVanced/revanced-patches@f71d893)) * **YouTube Music - Remove upgrade button:** Remove the correct navigation bar item ([fd3813f](ReVanced/revanced-patches@fd3813f)) ### Features * Add `Override certificate pinning` patch ([ReVanced#2781](ReVanced/revanced-patches#2781)) ([94ed738](ReVanced/revanced-patches@94ed738)) * **Change package name:** Append `.revanced` to package name by default ([ReVanced#2750](ReVanced/revanced-patches#2750)) ([e83e62f](ReVanced/revanced-patches@e83e62f)) * **Duolingo:** Add `Unlock Duolingo Super` patch ([ReVanced#2862](ReVanced/revanced-patches#2862)) ([61a7533](ReVanced/revanced-patches@61a7533)) * Exclude `Custom branding` patch by default ([d6de957](ReVanced/revanced-patches@d6de957)) * **Lightroom:** Add `Disable mandatory login` patch ([ReVanced#2738](ReVanced/revanced-patches#2738)) ([896a713](ReVanced/revanced-patches@896a713)) * **Lightroom:** Add `Unlock premium` patch ([ReVanced#2740](ReVanced/revanced-patches#2740)) ([e18a9bc](ReVanced/revanced-patches@e18a9bc)) * **Nova Launcher:** Remove `Unlock prime` patch ([bbde91c](ReVanced/revanced-patches@bbde91c)) * Publicize resource utility functions ([20aff26](ReVanced/revanced-patches@20aff26)) * **Solid Explorer:** Add `Remove file size limit` patch ([01c617d](ReVanced/revanced-patches@01c617d)) * **Strava:** Add `Subscription features` patch ([ReVanced#2872](ReVanced/revanced-patches#2872)) ([387eb29](ReVanced/revanced-patches@387eb29)) * **Tasker:** Remove `Unlock trial` patch ([8354a87](ReVanced/revanced-patches@8354a87)) * Use an extension property to create new exception when failing to resolve a fingerprint ([47eac14](ReVanced/revanced-patches@47eac14)) * **YouTube - Debug:** Logging of layout proto buffer strings ([ReVanced#2759](ReVanced/revanced-patches#2759)) ([189f719](ReVanced/revanced-patches@189f719)) * **YouTube - External downloads:** Recommend Seal instead of PowerTube ([ReVanced#2803](ReVanced/revanced-patches#2803)) ([082e067](ReVanced/revanced-patches@082e067)) * **YouTube - Hide video action buttons:** Hide individual action buttons ([ReVanced#2723](ReVanced/revanced-patches#2723)) ([220f694](ReVanced/revanced-patches@220f694)) * **YouTube Music - Exclusive audio playback:** Support latest version ([0861991](ReVanced/revanced-patches@0861991)) * **YouTube Music:** Add `Permanent repeat` patch ([ReVanced#2722](ReVanced/revanced-patches#2722)) ([506d49c](ReVanced/revanced-patches@506d49c)) * **YouTube Music:** Add `Permanent Shuffle` patch ([ReVanced#2730](ReVanced/revanced-patches#2730)) ([86a271c](ReVanced/revanced-patches@86a271c)) * **YouTube:** Add `Alternative thumbnails` patch ([ReVanced#2834](ReVanced/revanced-patches#2834)) ([8a4277c](ReVanced/revanced-patches@8a4277c)) * **YouTube:** Add `Custom player overlay opacity` patch ([ReVanced#2721](ReVanced/revanced-patches#2721)) ([2622b00](ReVanced/revanced-patches@2622b00)) * **YouTube:** Add `Enable tablet layout` patch ([c89b2aa](ReVanced/revanced-patches@c89b2aa)) * **YouTube:** Support version `18.29.38` ([c1b9eef](ReVanced/revanced-patches@c1b9eef)) * **YouTube:** Support version `18.32.39` ([7b503e2](ReVanced/revanced-patches@7b503e2))
# Conflicts: # api/revanced-patches.api # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/HideTimelineAdsPatch.kt # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/fingerprints/IsAdCheckTwoFingerprint.kt # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/fingerprints/MediaFingerprint.kt # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/fingerprints/ads/MediaAdFingerprint.kt # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/fingerprints/ads/PaidPartnershipAdFingerprint.kt # src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/fingerprints/ads/ShoppingAdFingerprint.kt # src/main/kotlin/app/revanced/patches/music/ad/video/MusicVideoAdsPatch.kt # src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsConstructorFingerprint.kt # src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsFingerprint.kt # src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback.kt # src/main/kotlin/app/revanced/patches/music/layout/compactheader/CompactHeaderPatch.kt # src/main/kotlin/app/revanced/patches/music/layout/compactheader/fingerprints/ConstructCategoryBarFingerprint.kt # src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/MinimizedPlaybackPatch.kt # src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt # src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt # src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumParentFingerprint.kt # src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/RemoveUpgradeButtonPatch.kt # src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt # src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch.kt # src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt # src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt # src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt # src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt # src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt # src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt # src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt # src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt # src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsBytecodePatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/ResolvePivotBarFingerprintsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/PivotBarButtonsViewFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/PivotBarCreateButtonViewFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/fingerprints/PivotBarEnumFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/utils/InjectionUtils.kt # src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt # src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/fingerprints/UserAgentHeaderBuilderFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/fingerprints/ComponentContextParserFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/navigation/fingerprints/InitializeButtonsFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/PlayerOverlaysHookPatch.kt # src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/fingerprint/PlayerOverlaysOnFinishInflateFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt # src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt # src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt # src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt
I tried IntelliJ, for me it is no longer adding trailing commas when reformatting code. @oSumAtrIX If it's still adding trailing commas for you, then maybe it's a installation specific setting. |
I have been using the dev branch instead of this one, so I'll verify again in a bit |
For me, running |
Perhaps we are using different plugins? My plugin still insists on adding trailing commas. More info I found about this: https://youtrack.jetbrains.com/issue/IDEA-336571 |
# Conflicts: # gradle.properties # src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt # src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt # src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt
…ntellij / Android Studio plugin behavior
I'm using the same plugin (works with both Intellij and Android Studio). I think it's figured out now.
All the plugins now work correctly for me. IntelliJ ktlint format, Android Studio ktlint format, and gradle If it's still behaving differently for you, check if you have local project specific format settings turned on, as that might be changing the behavior. |
|
afe4ce9
to
c644950
Compare
Organize import now gives the same results between both editors. @oSumAtrIX Try using ktlint format and IntelliJ organize imports, and no changes should be made. |
c644950
to
50623d4
Compare
feefb56
to
a371631
Compare
c0cd9d2
to
2ace07d
Compare
This commit also changes the API, but these changes are considered fixes.