-
Notifications
You must be signed in to change notification settings - Fork 739
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
Code Style Change #5644
Code Style Change #5644
Conversation
9f13d0d
to
94099f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.editorconfig
Outdated
end_of_line = crlf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was true, I think it should stay true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -20,7 +20,7 @@ import android.view.View | |||
import im.vector.lib.attachmentviewer.databinding.ItemAnimatedImageAttachmentBinding | |||
|
|||
class AnimatedImageViewHolder constructor(itemView: View) : | |||
BaseViewHolder(itemView) { | |||
BaseViewHolder(itemView) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it the "continuation indent" thing?
I do not like the new format :/
class AnimatedImageViewHolder constructor(itemView: View) :
BaseViewHolder(itemView) {
val views = ItemAnimatedImageAttachmentBinding.bind(itemView)
is more confusing than
class AnimatedImageViewHolder constructor(itemView: View) :
BaseViewHolder(itemView) {
val views = ItemAnimatedImageAttachmentBinding.bind(itemView)
if I am reading it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed. The ideal formatting here should be as follows:
class AnimatedImageViewHolder constructor(
itemView: View,
) : BaseViewHolder(itemView) {
val views = ItemAnimatedImageAttachmentBinding.bind(itemView)
I'll investigate if I can get the formatter to achieve this
R.layout.item_video_attachment -> VideoViewHolder(itemView) | ||
else -> UnsupportedViewHolder(itemView) | ||
R.layout.item_video_attachment -> VideoViewHolder(itemView) | ||
else -> UnsupportedViewHolder(itemView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will not convince me that the new format is easier to read. (but I know the advantages).
Applicable to nearly all the when
statements.
Probably because to me code readability is top priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mine too, but personally I find this easier to read than if they're all aligned. It also may well be the case that this is easier or harder to read based on what you're used to and falls into the realm of subjective, hence, the earlier poll
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".AttachmentViewerActivity"> | ||
xmlns:tools="http://schemas.android.com/tools" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why we now have 8 spaces for an indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A mistake. Good spot!
Have you considered re-enabling disabled rules? See https://github.com/vector-im/element-android/blob/main/build.gradle#L107 |
8efcec4
to
1c2b55d
Compare
Thanks for pointing this out! We'd most probably want to |
Closing as we decided on the approach of tackling these changes one at a time. I'll make these changes on separate branches |
Draft until entire project is reformatted. See bottom of description for more detail
Open for discussion!
Proposal Doc
Summary:
We want to make changes to the code style for better readability and to stick closer to Kotlin code conventions.
The changes include:
when
branches in columnThese changes have been decided on through chats and polls.
The changes were made on a
.editorconfig
file which automatically generates aproject.xml
file for projects that include it, which then automatically applies the code style to the IDE. This will then affect the style applied when auto formatting code.The aforementioned
.editorconfig
file was generated through selecting all the necessary options in Android Studio's kotlin code style and exporting it as such. The exported file did also include style config for other languages (Java, C++, etc.) but I removed those from the config as we don't have a concensus on that yet.I'm currently testing if this works too with the linter, both locally as well as through the CIEdit: This affects the CI linter so the entire project needs to be reformatted. Turning this PR into a draft until that's done