Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Use `"""` instead of `"` to avoid `\"`

Open Arthur-Milchior opened this issue 2 years ago • 6 comments

One usual issue in reading code inside of code (e.g. string containing html, css, or js) is that they contains quote, which you must escape. Worst is when you want to have actual quote in the inside language. Kotlin offers one solution, triple quote. You can do """ this is a simple quote ".""" or """<img src="test.jpg"> """ and don't have to escape the inside quote. It would be nice to look for all " in the code base and remove then when possible.

Simultaneously, you can add @Language("HTML") or any other relevant language, to ensure proper syntax coloring

It's cleanup, it's a matter of taste and not of absolute rules. If in some case you believe the result would be worse than the original, feel free to not make a change. As an example, we have some part in the code "\"", the string containing a single double-quote. You should probably leave it alone, because """"""" (7 double-quote), which is a valid template for the string containing a single double-quote, is far far less readable. Each change should take less than a minute to make. If you do a PR by change, they should be merged almost immediately, so the risk of conflict and wasted work is low. You can just look below to see if someone did what you are about to do. This mean that you don't have to ask permission to work on it.

Once it is done, an extra task would be to consider adding a lint issue for escaped quote.

Arthur-Milchior avatar May 29 '22 18:05 Arthur-Milchior

Hey @Arthur-Milchior, greeting. Can you please assign this issue to me? I have just started with android development and would love to get my hands-on some beginner level issue like this, in order to improve my skills.

SaranshBaniyal avatar Jun 05 '22 06:06 SaranshBaniyal

Hey @Arthur-Milchior, greeting. Can you please assign this issue to me? I have just started with android development and would love to get my hands-on some beginner level issue like this, in order to improve my skills.

Done! Let us know if you need help

david-allison avatar Jun 05 '22 10:06 david-allison

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Aug 04 '22 13:08 github-actions[bot]

any news @SaranshBaniyal ? Are you still working on it?

Arthur-Milchior avatar Aug 04 '22 13:08 Arthur-Milchior

I'm sorry guys for my inactivity, I have been off for some time and was totally unaware that I was allotted this issue. I would still like to contribute if you guys can allow me a little more time, or if you decide to allocate this issue to someone else, that would be fine. I again apologize for my inactivity and negligence.

SaranshBaniyal avatar Aug 04 '22 14:08 SaranshBaniyal

Thanks for your answer @SaranshBaniyal. And please don’t worry. If it were an emergency, we would have pinged you earlier or just done it ourself. We are all volunteers, nobody has any obligation. And even if indeed it’s nice to look at github notification and see when people answered your message, it’s not big deal and there is no need to apologize multiple times.

I’m looking forward for your PR.

Arthur-Milchior avatar Aug 04 '22 15:08 Arthur-Milchior

@Arthur-Milchior sir, I sincerely apologize but I am having a tough time understanding how to proceed on this issue after cloning the repository. I am a beginner in android dev and lack experience in real-life working projects. I would be grateful if you can just brief me on the direction to proceed or maybe you can unassign this issue and reassign it to someone else

SaranshBaniyal avatar Aug 15 '22 16:08 SaranshBaniyal

Can ou please come on the discord, where you may get real-time help? I don't even know what is your issue. Whether you can or can't compile. Whether you can't find the place to improve. Whether you found them but fail to improve them. etc.

Arthur-Milchior avatar Aug 15 '22 18:08 Arthur-Milchior

What is your discord?

sparkyniner avatar Aug 19 '22 16:08 sparkyniner

https://discord.gg/qjzcRTx You can find it from the app too

Arthur-Milchior avatar Aug 19 '22 17:08 Arthur-Milchior

@sparkyniner AstroITNinja#3803

SaranshBaniyal avatar Aug 21 '22 04:08 SaranshBaniyal

@Arthur-Milchior I have cloned the files, so should I start looking for " in all the Kotlin files of the codebase from start till end?

SaranshBaniyal avatar Aug 21 '22 04:08 SaranshBaniyal

@SaranshBaniyal the comment is valid for you too. If you have question about how to proceed, I strongly suggest you to come on our discord. Because this way you can find people to answer your question very quickly instead of having to wait half a day or more that someone looking at this particular PR see you.

And no, I would not ask anyone to look at codebase from start till end. That would be an impossible amount of work to do for almost anything. Instead, I was implicitly expecting that a dev that will attack this issue would:

  1. have android studio installled and be able to compile,
  2. probably have knowledge of at least basic tools such as "search in the repository" (ctrl-shift-f)
  3. search for occurence of \" in the code and
  4. see whether it makes sense to replace quotes by triple quote, (in some case, maybe it's less readable to do the change. If so, let's not make it)

Arthur-Milchior avatar Aug 21 '22 19:08 Arthur-Milchior

@Arthur-Milchior thanks for all the help, I have joined the discord server. Looking forward to a great learning experience with you all.

SaranshBaniyal avatar Aug 22 '22 06:08 SaranshBaniyal

Hey @Arthur-Milchior, greeting. Can you please assign this issue to me?

Aditya8840 avatar Sep 08 '22 11:09 Aditya8840

@Arthur-Milchior I m still learning and am unable to resolve this issue yet, I don't mind if you assign this issue to @Aditya8840 . Thanks for all the help, I wish to catch up soon and contribute to ankidroid in any way possible

SaranshBaniyal avatar Sep 08 '22 11:09 SaranshBaniyal

Greeting @Aditya8840 . Done

Arthur-Milchior avatar Sep 08 '22 22:09 Arthur-Milchior

Is this issue still open? I would love to contribute to getting my hands free on good first issue

SanjaySargam avatar Nov 01 '22 14:11 SanjaySargam

@SanjaySargam Welcome, It's still open. As far as I know, @Aditya8840 has not contacted us since the issue was assigned to them, so you certainly can go work on it.

Arthur-Milchior avatar Nov 02 '22 19:11 Arthur-Milchior

@Arthur-Milchior we have to do changes only in HTML,CSS ,JS files right?

SanjaySargam avatar Nov 03 '22 10:11 SanjaySargam

Oh no. We have very very few HTML, CSS and JS pages actually. What I meant is that sometime, we write some HTML directly inside of Kotlin code. And this code, may be cleaned. I just edited the first message in this issue to add an example. For example https://github.com/ankidroid/Anki-Android/blob/8d4083e1ddbad8f0633679997a4b5b44ee88dc72/api/src/main/java/com/ichi2/anki/api/BasicModel.kt is a line that should be corrected

Arthur-Milchior avatar Nov 04 '22 03:11 Arthur-Milchior

Oh no. We have very very few HTML, CSS and JS pages actually. What I meant is that sometime, we write some HTML directly inside of Kotlin code. And this code, may be cleaned. I just edited the first message in this issue to add an example. For example https://github.com/ankidroid/Anki-Android/blob/8d4083e1ddbad8f0633679997a4b5b44ee88dc72/api/src/main/java/com/ichi2/anki/api/BasicModel.kt is a line that should be corrected

Thank You for ur explanation ☺️@Arthur-Milchior

SanjaySargam avatar Nov 04 '22 05:11 SanjaySargam

If this is going to be done, I believe that a lint rule should be used, otherwise this will be a open-ended issue that may never be completed because people may not remember to use """ on new PRs.

And, to be honest, I bet that the time cost on pushing/reviewing all usages of \" will be way bigger than the spared time spent on deciphering that \" = " (which may be instantaneous for any developer used enough to it). So, I don't suggest spending time on this

BrayanDSO avatar Nov 17 '22 18:11 BrayanDSO

Please close this issue! Thanks

Sagar0-0 avatar Dec 03 '22 15:12 Sagar0-0