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

Add Lint check to ensure all .java files have Copyright Headers

Open david-allison opened this issue 5 years ago • 11 comments

With more new contributors, we should automate ensuring that each new file has a copyright header, rather than leaving this to code review.

We can do this via a lint check. For example: https://github.com/ankidroid/Anki-Android/blob/db82ab008a90ff89e77c5c5637b2e33be17ab04a/lint-rules/src/main/java/com/ichi2/anki/lint/rules/InconsistentAnnotationUsage.java

It would be ideal if the lint check guided users to the correct setting screen in Android Studio to set up the copyright:

This can be done via an explanation: https://github.com/ankidroid/Anki-Android/blob/db82ab008a90ff89e77c5c5637b2e33be17ab04a/lint-rules/src/main/java/com/ichi2/anki/lint/rules/InconsistentAnnotationUsage.java#L37-L39

image

It may also be useful to provide users with a template:

 Copyright (c) $today.year Your Name Here <[email protected]>

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 3 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE. See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 this program.  If not, see <http://www.gnu.org/licenses/>.

david-allison avatar Mar 14 '21 22:03 david-allison

Please note that this functionality may already exist in Android Studio's suite of lint tools, and we should confirm that this isn't the case before writing our own code.

david-allison avatar Mar 14 '21 22:03 david-allison

Can I work on this?

ChaxuGarg avatar Mar 14 '21 23:03 ChaxuGarg

I want to work on this

imaryandokania avatar Mar 14 '21 23:03 imaryandokania

Sorry @imaryandokania, I'll go with @ChaxuGarg as he commented first.

Normally we don't have two people going for the same issue - it's a nice problem to have

david-allison avatar Mar 15 '21 00:03 david-allison

Sorry @imaryandokania, I'll go with @ChaxuGarg as he commented first.

Normally we don't have two people going for the same issue - it's a nice problem to have

No problem 😀

imaryandokania avatar Mar 15 '21 00:03 imaryandokania

Hi @ChaxuGarg are you working on this? If not I would like to work on.

almas33 avatar Mar 22 '21 17:03 almas33

Please note that this functionality may already exist in Android Studio's suite of lint tools, and we should confirm that this isn't the case before writing our own code.

There doesn't seem to exist any lint check on this , regarding copyrights there is only one lint check which suggests to convert (c) to copyright symbol

almas33 avatar Mar 22 '21 20:03 almas33

Hi @ChaxuGarg are you working on this? If not I would like to work on.

I haven't started working on it yet, so sure @almas33 go ahead

ChaxuGarg avatar Mar 22 '21 20:03 ChaxuGarg

Please note that this functionality may already exist in Android Studio's suite of lint tools, and we should confirm that this isn't the case before writing our own code.

There doesn't seem to exist any lint check on this , regarding copyrights there is only one lint check which suggests to convert (c) to copyright symbol

We can write our own if one doesn't exist: https://github.com/ankidroid/Anki-Android/pull/7707

david-allison avatar Mar 23 '21 00:03 david-allison

IntelliJ Template:

 Copyright (c) $today.year Your Name Here <[email protected]>

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 3 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE. See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 this program.  If not, see <http://www.gnu.org/licenses/>.

david-allison avatar Apr 22 '21 23:04 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 Jun 22 '21 00:06 github-actions[bot]