Create a core-util module with some common utilities.

This commit is contained in:
Greyson Parrelli
2020-12-04 18:31:58 -05:00
parent 831cd2f297
commit 8e93bf9075
958 changed files with 1879 additions and 2035 deletions

View File

@@ -65,7 +65,7 @@ public final class SignalLogDetector extends Detector implements Detector.UastSc
context.report(LOG_NOT_APP, call, context.getLocation(call), "Using Signal server logger instead of app level Logger", fix);
}
if (evaluator.isMemberInClass(method, "org.thoughtcrime.securesms.logging.Log")) {
if (evaluator.isMemberInClass(method, "org.signal.core.util.logging.Log")) {
List<UExpression> arguments = call.getValueArguments();
UExpression tag = arguments.get(0);
if (!(tag instanceof JavaUSimpleNameReferenceExpression)) {
@@ -79,7 +79,7 @@ public final class SignalLogDetector extends Detector implements Detector.UastSc
String methodName = logCall.getMethodName();
UExpression tag = arguments.get(0);
String fixSource = "org.thoughtcrime.securesms.logging.Log.";
String fixSource = "org.signal.core.util.logging.Log.";
switch (arguments.size()) {
case 2:

View File

@@ -36,10 +36,10 @@ public final class LogDetectorTest {
" Log.d(\"TAG\", \"msg\");\n" +
" ~~~~~~~~~~~~~~~~~~~\n" +
"1 errors, 0 warnings")
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.thoughtcrime.securesms.logging.Log.d(\"TAG\", \"msg\"):\n" +
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.signal.core.util.logging.Log.d(\"TAG\", \"msg\"):\n" +
"@@ -5 +5\n" +
"- Log.d(\"TAG\", \"msg\");\n" +
"+ org.thoughtcrime.securesms.logging.Log.d(\"TAG\", \"msg\");");
"+ org.signal.core.util.logging.Log.d(\"TAG\", \"msg\");");
}
@Test
@@ -60,10 +60,10 @@ public final class LogDetectorTest {
" Log.w(\"TAG\", \"msg\", new Exception());\n" +
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
"1 errors, 0 warnings")
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.thoughtcrime.securesms.logging.Log.w(\"TAG\", \"msg\", new Exception()):\n" +
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.signal.core.util.logging.Log.w(\"TAG\", \"msg\", new Exception()):\n" +
"@@ -5 +5\n" +
"- Log.w(\"TAG\", \"msg\", new Exception());\n" +
"+ org.thoughtcrime.securesms.logging.Log.w(\"TAG\", \"msg\", new Exception());");
"+ org.signal.core.util.logging.Log.w(\"TAG\", \"msg\", new Exception());");
}
@Test
@@ -84,10 +84,10 @@ public final class LogDetectorTest {
" Log.d(\"TAG\", \"msg\");\n" +
" ~~~~~~~~~~~~~~~~~~~\n" +
"1 errors, 0 warnings")
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.thoughtcrime.securesms.logging.Log.d(\"TAG\", \"msg\"):\n" +
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.signal.core.util.logging.Log.d(\"TAG\", \"msg\"):\n" +
"@@ -5 +5\n" +
"- Log.d(\"TAG\", \"msg\");\n" +
"+ org.thoughtcrime.securesms.logging.Log.d(\"TAG\", \"msg\");");
"+ org.signal.core.util.logging.Log.d(\"TAG\", \"msg\");");
}
@Test
@@ -108,10 +108,10 @@ public final class LogDetectorTest {
" Log.w(\"TAG\", \"msg\", new Exception());\n" +
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
"1 errors, 0 warnings")
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.thoughtcrime.securesms.logging.Log.w(\"TAG\", \"msg\", new Exception()):\n" +
.expectFixDiffs("Fix for src/foo/Example.java line 5: Replace with org.signal.core.util.logging.Log.w(\"TAG\", \"msg\", new Exception()):\n" +
"@@ -5 +5\n" +
"- Log.w(\"TAG\", \"msg\", new Exception());\n" +
"+ org.thoughtcrime.securesms.logging.Log.w(\"TAG\", \"msg\", new Exception());");
"+ org.signal.core.util.logging.Log.w(\"TAG\", \"msg\", new Exception());");
}
@Test
@@ -119,7 +119,7 @@ public final class LogDetectorTest {
lint()
.files(appLogStub,
java("package foo;\n" +
"import org.thoughtcrime.securesms.logging.Log;\n" +
"import org.signal.core.util.logging.Log;\n" +
"public class Example {\n" +
" private static final String TAG = Log.tag(Example.class);\n" +
" public void log() {\n" +
@@ -137,7 +137,7 @@ public final class LogDetectorTest {
lint()
.files(appLogStub,
java("package foo;\n" +
"import org.thoughtcrime.securesms.logging.Log;\n" +
"import org.signal.core.util.logging.Log;\n" +
"public class Example {\n" +
" public void log() {\n" +
" Log.d(\"TAG\", \"msg\");\n" +

View File

@@ -1,4 +1,4 @@
package org.thoughtcrime.securesms.logging;
package org.signal.core.util.logging;
public class Log {