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

[Cleanup]: Fix Android Studio Warnings

Open david-allison opened this issue 2 years ago • 14 comments

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:

  • Code -> Inspect Code

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.

david-allison avatar Feb 16 '23 21:02 david-allison

You can assign me to this issue please.

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

atakanserifoglu avatar Feb 17 '23 09:02 atakanserifoglu

@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).

lukstbit avatar Feb 17 '23 11:02 lukstbit

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?

atakanserifoglu avatar Feb 17 '23 12:02 atakanserifoglu

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

david-allison avatar Feb 17 '23 14:02 david-allison

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

Prachi-Jamdade avatar Feb 18 '23 01:02 Prachi-Jamdade

Feel free to!

david-allison avatar Feb 18 '23 01:02 david-allison

@david-allison Can I work on this issue?

deekshatw avatar Feb 22 '23 09:02 deekshatw

@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.

lukstbit avatar Feb 22 '23 09:02 lukstbit

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

Prachi-Jamdade avatar Mar 04 '23 10:03 Prachi-Jamdade

Add an issue, and come to Discord

  • Almost certainly related to: https://github.com/ankidroid/Anki-Android/pull/13280

david-allison avatar Mar 04 '23 16:03 david-allison

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

TusharBhatia34 avatar Aug 04 '23 09:08 TusharBhatia34

is this issue still open ?

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

lukstbit avatar Aug 05 '23 03:08 lukstbit

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!

vreoo avatar Sep 24 '23 05:09 vreoo

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.

neeldoshii avatar Dec 25 '23 17:12 neeldoshii