mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Add new notification system.
This commit is contained in:
committed by
Greyson Parrelli
parent
c8f17e2ab0
commit
e796968d19
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.uast.UCallExpression;
|
||||
import org.jetbrains.uast.UExpression;
|
||||
import org.jetbrains.uast.java.JavaUSimpleNameReferenceExpression;
|
||||
import org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -73,7 +74,7 @@ public final class SignalLogDetector extends Detector implements Detector.UastSc
|
||||
if (evaluator.isMemberInClass(method, "org.signal.core.util.logging.Log")) {
|
||||
List<UExpression> arguments = call.getValueArguments();
|
||||
UExpression tag = arguments.get(0);
|
||||
if (!(tag instanceof JavaUSimpleNameReferenceExpression)) {
|
||||
if (!(tag instanceof JavaUSimpleNameReferenceExpression || tag instanceof KotlinUSimpleReferenceExpression)) {
|
||||
context.report(INLINE_TAG, call, context.getLocation(call), "Not using a tag constant");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static com.android.tools.lint.checks.infrastructure.TestFiles.java;
|
||||
import static com.android.tools.lint.checks.infrastructure.TestFiles.kotlin;
|
||||
import static com.android.tools.lint.checks.infrastructure.TestLintTask.lint;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -133,6 +134,24 @@ public final class LogDetectorTest {
|
||||
.expectClean();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void log_uses_tag_constant_kotlin() {
|
||||
lint()
|
||||
.files(appLogStub,
|
||||
kotlin("package foo\n" +
|
||||
"import org.signal.core.util.logging.Log\n" +
|
||||
"class Example {\n" +
|
||||
" const val TAG: String = Log.tag(Example::class.java)\n" +
|
||||
" fun log() {\n" +
|
||||
" Log.d(TAG, \"msg\")\n" +
|
||||
" }\n" +
|
||||
"}")
|
||||
)
|
||||
.issues(SignalLogDetector.INLINE_TAG)
|
||||
.run()
|
||||
.expectClean();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void log_uses_inline_tag() {
|
||||
lint()
|
||||
@@ -154,6 +173,26 @@ public final class LogDetectorTest {
|
||||
.expectFixDiffs("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void log_uses_inline_tag_kotlin() {
|
||||
lint()
|
||||
.files(appLogStub,
|
||||
kotlin("package foo\n" +
|
||||
"import org.signal.core.util.logging.Log\n" +
|
||||
"class Example {\n" +
|
||||
" fun log() {\n" +
|
||||
" Log.d(\"TAG\", \"msg\")\n" +
|
||||
" }\n" +
|
||||
"}"))
|
||||
.issues(SignalLogDetector.INLINE_TAG)
|
||||
.run()
|
||||
.expect("src/foo/Example.kt:5: Error: Not using a tag constant [LogTagInlined]\n" +
|
||||
" Log.d(\"TAG\", \"msg\")\n" +
|
||||
" ~~~~~~~~~~~~~~~~~~~\n" +
|
||||
"1 errors, 0 warnings")
|
||||
.expectFixDiffs("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void glideLogUsed_LogNotSignal_2_args() {
|
||||
lint()
|
||||
|
||||
Reference in New Issue
Block a user