0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00
Commit Graph

64 Commits

Author SHA1 Message Date
David Allison
21c5bcdc8e feat(lint): Verify Positional Format Strings
AAPT displayed these issues as build as warnings, but CI passed

Add lint to make sure this is caught.

We take AAPT's C++ code and convert it to Kotlin.

Tested on commit d392498050

Errors looks like:

AnkiDroid\src\main\res\values\04-network.xml:84:
Multiple substitutions specified in non-positional format.
Convert "%s" to "%1$s"
[NonPositionalFormatSubstitutions from com.ichi2.anki.lint]

Fixes 10347
2022-02-20 17:20:51 -05:00
Akshit Sinha
1b597dfc96 Fixed Typo in KotlinMigrationBrokenEmails 2022-02-12 07:14:07 -05:00
Akshit Sinha
29eb51518a Added a Lint Check for line-break tag issue in kotlin migration 2022-02-12 07:14:07 -05:00
Mike Hardy
b430879e54
Dependency updates 20220201 (#10296)
* Bump mockito-inline from 4.3.0 to 4.3.1

Bumps [mockito-inline](https://github.com/mockito/mockito) from 4.3.0 to 4.3.1.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v4.3.0...v4.3.1)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-inline
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* test(lint): only run default TestModes for prefer is empty check

if the extra whitespace mode runs, it perturbs the diff and the check fails

* Bump lint_version from 30.0.4 to 30.1.0

Bumps `lint_version` from 30.0.4 to 30.1.0.

Updates `lint-api` from 30.0.4 to 30.1.0

Updates `lint` from 30.0.4 to 30.1.0

Updates `lint-tests` from 30.0.4 to 30.1.0

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump fragment-testing from 1.4.0 to 1.4.1

Bumps fragment-testing from 1.4.0 to 1.4.1.

---
updated-dependencies:
- dependency-name: androidx.fragment:fragment-testing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump preference-ktx from 1.1.1 to 1.2.0

Bumps preference-ktx from 1.1.1 to 1.2.0.

---
updated-dependencies:
- dependency-name: androidx.preference:preference-ktx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* test(layout): do not attempt to inflate preference_category_material

* Bump fragment-ktx from 1.4.0 to 1.4.1

Bumps fragment-ktx from 1.4.0 to 1.4.1.

---
updated-dependencies:
- dependency-name: androidx.fragment:fragment-ktx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump protobuf-java from 3.19.3 to 3.19.4

Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.19.3 to 3.19.4.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.19.3...v3.19.4)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-01 08:43:44 -05:00
David Allison
14898fa14f lint: kotlin conversion corrupting emails
The Java -> Kotlin migration converts <...> into html tags
if the comment is /** instead of /*

This often catches the copyright header of files, which is bad
as it corrupts the emails in the copyright.

Pickup the email `<http:></http:>` and report this
2021-10-30 08:25:25 -05:00
David Allison
174ae14237 feat(lint-GPL): Steps for GPL compatible licenses
https://www.gnu.org/licenses/license-list.en.html#GPLCompatibleLicenses

https://softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html#x1-40002.2

Fixes 9260
2021-10-18 13:02:21 -05:00
David Allison
b0fd892c1f lint: enable 'missing copyright' on tests
Previous commits have resolved the current warnings, this stops
it from occurring for new users

Issue 9538 - enable lint warnings on tests
2021-10-09 09:40:08 -05:00
David Allison
ee962c2d19 lint: check NonPublicNonStaticFieldName in tests
Issue 9538
2021-09-22 11:00:22 -05:00
Nicola Dardanis
c6f5d3f3ea lint: Use isEmpty instead of comparing size to zero 2021-08-27 08:19:38 -05:00
Nicola Dardanis
51ac9055db lint: Avoid use of field prefixes for variable names 2021-08-27 08:15:20 -05:00
David Allison
5a951f13de lint: Only enforce variable naming in java
We want to move away from AOSP naming for Kotlin

As it makes getters and primary constructors less useful
as the naming conflicts with other policies we want to enforce
AOSP naming is also against Google suggestions

Fixes 9377
2021-08-05 21:33:20 -05:00
dependabot[bot]
a8681b3486 build(deps): bump lint_version from 27.2.2 to 30.0.0
Fix errors which were introduced:

* api is now required
* Unicode Handling changed
* Compilation errors from missing imports were introduced
  * a2d0a4ca4d

Bumps `lint_version` from 27.2.2 to 30.0.0.

Updates `lint-api` from 27.2.2 to 30.0.0

Updates `lint` from 27.2.2 to 30.0.0

Updates `lint-tests` from 27.2.2 to 30.0.0

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-29 13:33:45 -05:00
David Allison
619c8d0b00 nf: NonNull annotation 2021-07-09 11:13:44 -05:00
David Allison
7cf2ea7850 fix[lint]: allow Kotlin companion objects
`ConstantFieldName` lint was triggered by auto-generated Kotlin
companion objects named "Companion" (expected: COMPANION)

As these are auto-generated, allow constants called "Companion"

Fixes 9223
2021-07-09 11:13:44 -05:00
David Allison
95ddf9bdbb gradle: consolidate lint library version
Reduce GitHub notification spam (previously we get 3 update PRs)
as the library updates in lockstep

Fixes 9179
2021-07-01 13:38:23 -05:00
almas33
bc7c2b98bb Lint: Ensure Copyright Header Exists
This is a common issue in code reviews
The lint check explains how to fix the issue
so reduces review load and helps onboarding

Fixes 8359
2021-06-24 10:28:56 -05:00
David Allison
1a08c583f3 Extract Kotlin version to variable
Review comment: keeps all Kotlin modules in sync

Note: adding this to the `ext { }` section didn't work for the main
build.gradle, but would be a better solution

Using
https://stackoverflow.com/questions/64834818/android-studio-could-not-get-unknown-property-kotlin-version
2021-06-23 23:16:23 -05:00
Shridhar
4f21060f5e Use compileOnly for Kotlin dependency in lint-rules 2021-05-28 20:12:33 +02:00
Shridhar
49a98af859 Migrate UiUtil to Kotlin 2021-05-28 20:12:33 +02:00
Mike Hardy
bd37e05495
Dependency updates 20210522 (#8906)
* Bump junit-vintage-engine from 5.7.1 to 5.7.2

Bumps [junit-vintage-engine](https://github.com/junit-team/junit5) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.7.1...r5.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

* Bump fragment from 1.3.3 to 1.3.4

Bumps fragment from 1.3.3 to 1.3.4.

Signed-off-by: dependabot[bot] <support@github.com>

* Bump fragment-testing from 1.3.3 to 1.3.4

Bumps fragment-testing from 1.3.3 to 1.3.4.

Signed-off-by: dependabot[bot] <support@github.com>

* Bump annotations from 20.1.0 to 21.0.0

Bumps [annotations](https://github.com/JetBrains/java-annotations) from 20.1.0 to 21.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/20.1.0...21.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* chore(dependencies): bump appcompat (rc01->stable) and some test only deps

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-22 12:19:03 -05:00
Arthur Milchior
6c0d3b77fa NF: remove JetBrains Nullable 2021-05-22 09:28:39 -05:00
Arthur Milchior
dcbed8f5cf NF: remove jetbrains NotNull 2021-05-22 09:28:39 -05:00
Mike Hardy
9c90cc52e5
Dependency updates 20210514 (#8840)
* Bump lint-api from 27.2.0 to 27.2.1
* Bump lint-tests from 27.2.0 to 27.2.1
* Bump gradle from 4.2.0 to 4.2.1
* Bump lint from 27.2.0 to 27.2.1
* Bump jackson-databind from 2.12.0 to 2.12.3
* Bump protobuf-java from 3.15.8 to 3.17.0
2021-05-14 17:42:59 -05:00
Mike Hardy
49edb49e17 build: android-gradle-plugin 4.2.0 + others
- remove jcenter (deprecated, thankfully no longer needed)
- remove r8 workaround for previous issue, AGP 4.2.0 has fix built-in
- bump Triple-T / Play Publisher plugin to match AGP 4.2.0
- remove java 1_8 source/target compat annotation, it is default in 4.2
- add noinspection for commons-compress - has to wait until API26
- lint to 27.2.0
- fragment to 1.2.3
2021-05-07 17:16:00 -05:00
David Allison
5fbb8801e8 docs: improve lint error
Was ambiguous about adding the attribute to just one string
2021-04-26 05:02:29 +02:00
Prateek Singh
11667f9de6 Updated Fixed Title length lint rule 2021-04-24 02:38:37 +02:00
Mike Hardy
61cb6c3f05 Update to gradle 7.0
- API publishing needed a complete overhaul, tested locally, works
- JCenter is still needed for AnkiDroid as noted unfortunately...couple months to go
- Some artifact resolution performance complaints but local testing shows every single thing works
2021-04-15 23:21:34 -05:00
Mrudul Tora
557eff4dc8
Lint: Lint rule for use of UIUtils.showSnackbar instead of Snackbar.make (#8625)
* Added lint rule for use of UIUtils.showSnackbar instead of Snackbar.make
* Fixed the lint errors related to Snackbar.make
* Fixed inconsistent spacing

Co-authored-by: David Allison <62114487+david-allison-1@users.noreply.github.com>
2021-04-15 22:44:46 -05:00
David Allison
3541c210d8 Add lint rule to enforce constant field naming
For: `public static final` variables

Lint Id: ConstantFieldName

Automation: Means that we don't need to enforce this in code reviews

Constant (final variables) names must be all uppercase using underscore
 to separate words.

https://github.com/ankidroid/Anki-Android/wiki/Code-style#constant-final-variables-names-must-be-all-uppercase-using-underscore-to-separate-words

Note: The wording is imprecise: so only flag public constants
2021-04-14 12:43:52 -05:00
David Allison
f1e37dc557 Add lint rule to enforce 'm' variable prefix
For: Non-Static, Non-Public variables

Lint Id: NonPublicNonStaticFieldName

Automation: Means that we don't need to enforce this in code reviews

https://github.com/ankidroid/Anki-Android/wiki/Code-style#non-public-non-static-field-names-should-start-with-m
2021-04-14 12:43:52 -05:00
Nicola Dardanis
901260bed6 lint: Reorder rules lexicographically in IssueRegistry 2021-04-14 11:15:14 -05:00
Nicola Dardanis
f8135927d1 lint: Add DirectToastMakeTextUsage rule 2021-04-14 11:15:14 -05:00
David Allison
89a7679839 Add lint rule: PrintStackTraceUsage
Speed up code review by ensuring that e.printStackTrace() isn't used

Also includes AnkiDroid's first "Auto-Fix" for lint
2021-04-08 10:08:22 -05:00
dependabot-preview[bot]
b7537af36a Bump lint-api from 27.1.2 to 27.1.3
Bumps lint-api from 27.1.2 to 27.1.3.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Bump lint-tests from 27.1.2 to 27.1.3

Bumps lint-tests from 27.1.2 to 27.1.3.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Bump lint from 27.1.2 to 27.1.3 (#303)

* Bump lint from 27.1.2 to 27.1.3

Bumps lint from 27.1.2 to 27.1.3.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Update lint-rules/build.gradle

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
2021-03-19 15:31:02 -05:00
Mike Hardy
fdf12ea82d
Dependency updates 20210302 (#8135)
* Bump junit from 4.13.1 to 4.13.2

Bumps [junit](https://github.com/junit-team/junit4) from 4.13.1 to 4.13.2.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.13.1...r4.13.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump protobuf-java from 3.14.0 to 3.15.1

Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.14.0 to 3.15.1.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.14.0...v3.15.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump mockito-inline from 3.7.7 to 3.8.0

Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.7.7 to 3.8.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.7.7...v3.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump protobuf-java from 3.15.1 to 3.15.2

Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.15.1 to 3.15.2.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.15.1...v3.15.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump protobuf-java from 3.15.2 to 3.15.3

Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.15.2 to 3.15.3.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.15.2...v3.15.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-02 11:35:18 -05:00
Mike Hardy
a25cb062a4
Dependency updates 20210120 (#8029)
* Bump mockito-inline from 3.6.28 to 3.7.0

Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.6.28 to 3.7.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.6.28...v3.7.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump mockito-inline from 3.7.0 to 3.7.7

Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.7.0 to 3.7.7.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.7.0...v3.7.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump gradle from 4.1.1 to 4.1.2

Bumps gradle from 4.1.1 to 4.1.2.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump lint-tests from 27.1.1 to 27.1.2

Bumps lint-tests from 27.1.1 to 27.1.2.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump sqlite-android from 3.33.0 to 3.34.0

Bumps [sqlite-android](https://github.com/requery/sqlite-android) from 3.33.0 to 3.34.0.
- [Release notes](https://github.com/requery/sqlite-android/releases)
- [Changelog](https://github.com/requery/sqlite-android/blob/master/CHANGELOG.md)
- [Commits](https://github.com/requery/sqlite-android/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump lint-api from 27.1.1 to 27.1.2

Bumps lint-api from 27.1.1 to 27.1.2.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump lint to 27.1.2 to match other lint artifacts

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-01-20 10:03:14 -05:00
David Allison
db82ab008a InconsistentAnnotationUsage: Improve Explanation
There is also a hierarchy in the inspections panel.
Display this so the developer can find it in the list without the search

Improves on 7020
2020-12-29 11:42:50 -05:00
David Allison
220bf39aaa Duplicate CrowdIn Strings: Automate PR Step
Now handled by code, +1 for automation

Fixed by: 7582
2020-11-20 07:46:54 -05:00
David Allison
1543f0f900 Duplicate CrowdIn Strings: Cleanup
Kill some dead code, and add quotes for console output.

Related: 7582
2020-11-20 07:46:54 -05:00
David Allison
1eab35e040 Duplicate CrowdIn Strings: Explain fixes
Explained user should add a comment attribute if the change is legit

Related: 7582
2020-11-20 07:46:54 -05:00
David Allison
6caf7a9be6 Duplicate CrowdIn Strings: Allow str with comment
If all instances of a string have comments - ignore it.

Related: 7582
2020-11-20 07:46:54 -05:00
David Allison
c51bbc004f NF: Duplicate CrowdIn Strings - Invert if
Massive improvement in readability

Related: 7582
2020-11-20 07:46:54 -05:00
David Allison
4c140c6f24 Duplicate CrowdIn Strings: Ignore translated
We only want to check and warn for duplicates in our new strings

Related: 7582
2020-11-20 07:46:54 -05:00
David Allison
60b7c8ec1d Add DuplicateCrowdInStrings lint check
Converted from Kotlin to Java from AOSP

Convert: StringCasingDetector.kt to java
Use methods from: StringFormatDetector.java

Related: 7582
2020-11-20 07:46:54 -05:00
Mike Hardy
54bb9c96f9 Bump main lint dependency to 27.1.1 to match lint sub-dependencies 2020-11-11 14:12:53 -05:00
dependabot-preview[bot]
3d28e9d5d4 Bump lint from 27.1.0 to 27.1.1
Bumps lint from 27.1.0 to 27.1.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-11 14:12:53 -05:00
dependabot-preview[bot]
6543c39231 Bump lint-api from 27.1.0 to 27.1.1
Bumps lint-api from 27.1.0 to 27.1.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-11 14:12:53 -05:00
dependabot-preview[bot]
9af6693fb5 Bump lint-tests from 27.1.0 to 27.1.1
Bumps lint-tests from 27.1.0 to 27.1.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-11 14:12:53 -05:00
dependabot-preview[bot]
a922f16eb6 Bump lint from 27.0.2 to 27.1.0
Bumps lint from 27.0.2 to 27.1.0.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-14 16:21:41 -05:00
dependabot-preview[bot]
0821379bb5 Bump lint-tests from 27.0.2 to 27.1.0
Bumps lint-tests from 27.0.2 to 27.1.0.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-14 06:06:10 -05:00