ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.11k stars 2.17k forks source link

[Cleanup]: Fix Android Studio Warnings #13282

Open david-allison opened 1 year ago

david-allison commented 1 year ago

This task is designed as a small, useful task to onboard new users to the codebase who are unsure about what to work on.

[!IMPORTANT] Unique constraint to this issue Multiple pull requests from the same author will not be accepted, unless the refactoring is part of a larger piece of work

[!TIP] You do not need to be assigned this issue to work on it

Android Studio flags a number of warnings in the AnkiDroid project.

If a file which contains these warnings is committed, then Android Studio will warn the author. If the warning was not introduced by the author's commit, then the author is unnecessarily slowed down by having to confirm that they did not introduce more warnings into the codebase (which inevitably leads them to disabling the warning, as they're low value).

The list of warnings can be obtained via:

Screenshot 2023-02-16 at 21 38 16

The aim of this task is to introduce new contributors to the code with an 'easy' first issue to resolve.

  1. Run Code -> Inspect Code on the solution (it will be slow)
  2. Select one file which has warnings (under the Kotlin header is easiest.- many of the Java warnings are not flagged by the IDE)
  3. Fix all the errors, warnings + weak warnings in the file, automatically if this is offered by the IDE, or manually otherwise.
  4. Produce a Pull Request

If you have completed this and desire to do more work, please select one of our accepted issues, or fix some @NeedsTest annotations in the codebase.

Once this issue has been completed, we can use CI to run Android Studio in headless mode to ensure that the codebase gets to, and stays at 0 warnings.

atakanserifoglu commented 1 year ago

You can assign me to this issue please.

edit: for other people, I started working on this issue.

lukstbit commented 1 year ago

@atakanserifoglu Please read carefully the constraints mentioned above:

Multiple pull requests from the same author for this issue will not be accepted (this is a constraint unique to this issue).

atakanserifoglu commented 1 year ago

The project's naming convention has a lot of underscores whereas all of the issues related to this topic suggests camel case convention. Should I adapt all of these functions, classes and variable names or look for a different solution?

david-allison commented 1 year ago

The project's naming convention has a lot of underscores whereas all of the issues related to this topic suggests camel case convention. Should I adapt all of these functions, classes and variable names or look for a different solution?

If they're in libanki, ignore + suppress naming conventions. Otherwise they're candidates to be removed

Prachi-Jamdade commented 1 year ago

Hey @david-allison, can I start working on this issue ?

david-allison commented 1 year ago

Feel free to!

deekshatw commented 1 year ago

@david-allison Can I work on this issue?

lukstbit commented 1 year ago

@deekshatw and others. Go ahead, there's no need to ask for permission to work on this issue. Follow the steps above, pick a file that you want to fix, check the active PRs list to see if that specific file doesn't already have a PR associated, make your own PR, be happy.

Prachi-Jamdade commented 1 year ago

I was trying to fix some of the warnings. But then I'm facing the build issue while pushing my code. I haven't made any production code changes. @david-allison could you please guide me on this

Here is the screenshot of what went wrong -

image

david-allison commented 1 year ago

Add an issue, and come to Discord

TusharBhatia34 commented 11 months ago

is this issue still open ? can i work on it?

lukstbit commented 11 months ago

is this issue still open ?

Yes, it is. You can make a PR fixing one of the many reported issues.

vreoo commented 9 months ago

Hi @BrayanDSO ,

I noticed that my recent PR, which was merged a few days ago, automatically closed this issue as I mentioned it fixes this ticket. However, it seems this issue should remain open, as it has been tagged with "Keep Open." Could you kindly consider reopening it? Thank you!

neeldoshii commented 6 months ago

The list of warnings can be obtained via:

Analyze -> Inspect Code

image

In newer version of Android Studio it has been changed from Analyze ---> Inspect Code to Code ---> Inspect Code.

I think it's good to add in description of the issue for people who's using newer version of the Android Studio.