Skip to content
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

NF: improve the readability of some strings #17592

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

Arthur-Milchior
Copy link
Member

Specifically, the ones that represents json, sql or js. I found they used to be hard to read, and I expect to lower this issue.

"document.getElementsByTagName(\"h1\")[0].style.color=\"" + textColor + "\";" +
"x=document.getElementsByTagName(\"h2\"); for(i=0;i<x.length;i++){x[i].style.color=\"#E37068\";}" +
"document.body.style.setProperty(\"background\", \"" + background + "\");",
"""javascript:document.body.style.setProperty("color", "$textColor");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been tested?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can open the about page and still see the changes.
Appart from that, it's exactly the same code as before, except that it uses triple-quote and
2024-12-12-192807_2300x357_scrot

I'd suggest to use android studio commit tool instead of github one. Because this way you can easily check that everything removed were \ before the ", the " + and + " and everything added are $ before the variables.

The idea is really that we have the same string, but more readable

@@ -71,16 +71,27 @@ object MetaDB {

// Create tables if not exist
metaDb.execSQL(
"CREATE TABLE IF NOT EXISTS languages (" + " _id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"did INTEGER NOT NULL, ord INTEGER, " + "qa INTEGER, " + "language TEXT)",
"""CREATE TABLE IF NOT EXISTS languages (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have all the changes to this file been tested (or are they under coverage)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can at least start a new version of ankidroid on emulator, add and review a card. So it works at least in the sense that if there is a change, it's still compatible with the schema created here. Which seems quite improbable

Specifically, the ones that represents json, sql or js.
I found they used to be hard to read, and I expect to lower this issue.
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this introduces unnecessary risk: we're changing stable, untested code for no functionality improvements and minor readability improvements with very little testing

I'd be much happier if integration tests were added in future which impact the changed lines, as those both give evidence that the changes are correct, and improve the safety of the codebase

But... it's written, it's probably right, and we're at the start of an alpha cycle, let's get it in

@david-allison david-allison added Needs Author Reply Waiting for a reply from the original author Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author labels Dec 13, 2024
Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better, thanks!
I would have gone even further to improve the formatting for some of the sql strings(upper casing keywords, extra indentation).

@lukstbit lukstbit added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Dec 14, 2024
@lukstbit lukstbit added this pull request to the merge queue Dec 14, 2024
Merged via the queue into ankidroid:main with commit 47f6c8b Dec 14, 2024
9 checks passed
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Dec 14, 2024
@github-actions github-actions bot added this to the 2.21 release milestone Dec 14, 2024
@Arthur-Milchior Arthur-Milchior deleted the string branch December 25, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants