File AbstractTest.java
has 369 lines of code (exceeds 250 allowed). Consider refactoring.
package puscas.mobilertapp;
import android.Manifest;
import android.app.Activity;
import android.app.ActivityManager;
Method executeShellCommand
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
private static void executeShellCommand(final String shellCommand) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final ParcelFileDescriptor parcelFileDescriptor = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(shellCommand);
parcelFileDescriptor.checkError();
Method executeShellCommand
has 33 lines of code (exceeds 25 allowed). Consider refactoring.
private static void executeShellCommand(final String shellCommand) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final ParcelFileDescriptor parcelFileDescriptor = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(shellCommand);
parcelFileDescriptor.checkError();
Method setUp
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
@Before
@CallSuper
public void setUp() {
final String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
logger.info(methodName + ": " + this.testName.getMethodName());
Method grantPermissions
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
private static void grantPermissions() {
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
Espresso.onIdle();
logger.info("Granting permissions to the MainActivity to be able to read files from an external storage.");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Method setUpAll
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
@BeforeClass
@CallSuper
public static void setUpAll() {
final String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
logger.info(methodName);
Method assertRenderScene
has 7 arguments (exceeds 4 allowed). Consider refactoring.
protected void assertRenderScene(final Scene scene,
final Shader shader,
final Accelerator accelerator,
final int spp,
final int spl,
Method isActivityRunning
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
@SuppressWarnings({"deprecation"})
private static boolean isActivityRunning(@NonNull final Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Use the built-in formatting to construct this argument.
logger.info(methodName + " finished");
Use the built-in formatting to construct this argument.
logger.info(methodName + ": Finishing the Activity.");
Use the built-in formatting to construct this argument.
logger.info(methodName + ": Will wait for the Activity triggered by the test to finish. Max timeout in secs: " + timeToWaitSecs);
Remove this unused private "dismissANRSystemDialog" method.
private static void dismissANRSystemDialog() {
Make the enclosing method "static" or remove this set.
oneTestFailed = true;
Define and throw a dedicated exception instead of using a generic one.
throw new RuntimeException("Permission '" + permission + "' NOT granted to the app: " + context.getPackageName());
Define and throw a dedicated exception instead of using a generic one.
throw new RuntimeException(ex);
Define and throw a dedicated exception instead of using a generic one.
throw new RuntimeException(ex);
Wrong lexicographical order for 'java.io.IOException' import. Should be before 'org.junit.runner.Description'.
import java.io.IOException;
Wrong lexicographical order for 'java.util.Deque' import. Should be before 'org.junit.runner.Description'.
import java.util.Deque;
Wrong lexicographical order for 'java.util.concurrent.TimeoutException' import. Should be before 'org.junit.runner.Description'.
import java.util.concurrent.TimeoutException;
Line is longer than 100 characters (found 134).
waitForPermission(InstrumentationRegistry.getInstrumentation().getContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE);
Line is longer than 100 characters (found 107).
protected void mockFileManagerReply(final boolean externalSdcard, @NonNull final String... filesPath) {
Line is longer than 100 characters (found 105).
Wrong lexicographical order for 'java.io.File' import. Should be before 'org.junit.runner.Description'.
import java.io.File;
Line is longer than 100 characters (found 117).
logger.info(this.testName.getMethodName() + ": Resetting Intents that were missing from previous test.");
Line is longer than 100 characters (found 115).
final ActivityScenario<MainActivity> newActivityScenario = ActivityScenario.launch(MainActivity.class);
Line is longer than 100 characters (found 128).
logger.info(methodName + ": Activity finished: " + !isActivityRunning(activity) + " (" + currentTimeSecs + "secs)");
Line is longer than 100 characters (found 161).
Line is longer than 100 characters (found 102).
* @param expectedSameValues Whether the {@link Bitmap} should have have only one color.
Extra separation in import group before 'androidx.annotation.CallSuper'
import androidx.annotation.CallSuper;
Wrong lexicographical order for 'java.util.Objects' import. Should be before 'org.junit.runner.Description'.
import java.util.Objects;
Line is longer than 100 characters (found 133).
InstrumentationRegistry.getInstrumentation().getContext().getPackageName(), Manifest.permission.READ_EXTERNAL_STORAGE
Line continuation have incorrect indentation level, expected level should be 4.
* tested application. This is done to avoid duplicated code.
Wrong lexicographical order for 'java.util.ArrayDeque' import. Should be before 'org.junit.runner.Description'.
import java.util.ArrayDeque;
Wrong lexicographical order for 'java.util.Collections' import. Should be before 'org.junit.runner.Description'.
import java.util.Collections;
Line is longer than 100 characters (found 137).
public static final ActivityScenarioRule<MainActivity> mainActivityActivityTestRule = new ActivityScenarioRule<>(MainActivity.class);
Line is longer than 100 characters (found 140).
waitForPermission(InstrumentationRegistry.getInstrumentation().getTargetContext(), Manifest.permission.MANAGE_EXTERNAL_STORAGE);
Line is longer than 100 characters (found 126).
throw new RuntimeException("Permission '" + permission + "' NOT granted to the app: " + context.getPackageName());
Extra separation in import group before 'java.io.BufferedReader'
import java.io.BufferedReader;
Extra separation in import group before 'puscas.mobilertapp.constants.Accelerator'
import puscas.mobilertapp.constants.Accelerator;
Line is longer than 100 characters (found 143).
if (taskRunning.baseActivity != null && Objects.equals(activity.getPackageName(), taskRunning.baseActivity.getPackageName())) {
Line is longer than 100 characters (found 132).
* @param showRenderWhenPressingButton Whether to show the {@link Constants#RENDER} text in the render button after pressing it.
Line is longer than 100 characters (found 165).
final ClipData clipData = new ClipData(new ClipDescription("Scene", new String[]{"*" + ConstantsUI.FILE_SEPARATOR + "*"}), new ClipData.Item(firstFile));
Abbreviation in name 'dismissANRSystemDialog' must contain no more than '2' consecutive capital letters.
private static void dismissANRSystemDialog() {
Line is longer than 100 characters (found 138).
waitForPermission(InstrumentationRegistry.getInstrumentation().getTargetContext(), Manifest.permission.READ_EXTERNAL_STORAGE);
Line is longer than 100 characters (found 109).
private static void waitForPermission(@NonNull final Context context, @NonNull final String permission) {
Line is longer than 100 characters (found 155).
final Intent resultIntent = MainActivity.createIntentToLoadFiles(InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName());
Line is longer than 100 characters (found 109).
throw new FailureException("Command '" + shellCommand + "' failed with: " + outputError);
Line is longer than 100 characters (found 128).
logger.info(this.testName.getMethodName() + ": " + methodName + " validating '" + intentsToVerify.size() + "' Intents");
Line is longer than 100 characters (found 122).
final ActivityManager activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
Line is longer than 100 characters (found 163).
final ParcelFileDescriptor parcelFileDescriptor = InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(shellCommand);
Wrong lexicographical order for 'java.util.List' import. Should be before 'org.junit.runner.Description'.
import java.util.List;
Wrong lexicographical order for 'java.util.concurrent.TimeUnit' import. Should be before 'org.junit.runner.Description'.
import java.util.concurrent.TimeUnit;
Wrong lexicographical order for 'java.util.logging.Logger' import. Should be before 'org.junit.runner.Description'.
import java.util.logging.Logger;
Line is longer than 100 characters (found 172).
InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand("pm grant puscas.mobilertapp.test android.permission.READ_EXTERNAL_STORAGE");
Line is longer than 100 characters (found 118).
UtilsPickerT.changePickerValue(ConstantsUI.PICKER_ACCELERATOR, R.id.pickerAccelerator, accelerator.ordinal());
Line is longer than 100 characters (found 105).
UtilsContextT.waitUntil(this.testName.getMethodName(), activity, Constants.STOP, State.BUSY);
Line is longer than 100 characters (found 114).
final Uri firstFile = Uri.fromFile(new File(storagePath + ConstantsUI.FILE_SEPARATOR + filesPath[0]));
Line is longer than 100 characters (found 101).
Intents.intended(IntentMatchers.filterEquals(expectedIntent), VerificationModes.times(1))
Line is longer than 100 characters (found 126).
logger.warning(this.testName.getMethodName() + ": The MainActivity didn't start as expected. Forcing a restart.");
Line is longer than 100 characters (found 167).
InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand("pm grant puscas.mobilertapp android.permission.READ_EXTERNAL_STORAGE");
Line continuation have incorrect indentation level, expected level should be 4.
* call it in the {@link #tearDown()} method after every test. This {@link Runnable} verifies
Line is longer than 100 characters (found 114).
resultIntent.setData(Uri.fromFile(new File(storagePath + ConstantsUI.FILE_SEPARATOR + filesPath[0])));
Wrong lexicographical order for 'java.io.BufferedReader' import. Should be before 'org.junit.runner.Description'.
import java.io.BufferedReader;
Line is longer than 100 characters (found 141).
logger.info(methodName + ": Will wait for the Activity triggered by the test to finish. Max timeout in secs: " + timeToWaitSecs);
Line is longer than 100 characters (found 139).
InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName(), Manifest.permission.READ_EXTERNAL_STORAGE
Line is longer than 100 characters (found 132).
waitForPermission(InstrumentationRegistry.getInstrumentation().getContext(), Manifest.permission.READ_EXTERNAL_STORAGE);
Line is longer than 100 characters (found 141).
while (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED && currentTimeMs < timeToWaitMs) {
Line is longer than 100 characters (found 106).
if (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
Line is longer than 100 characters (found 112).
* Click on device to dismiss any "Application Not Responding" (ANR) system dialog that might have appeared.
Line is longer than 100 characters (found 105).
final String errorMessage = testName.getMethodName() + ": " + exception.getMessage();
Line is longer than 100 characters (found 106).
InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity();
Line continuation have incorrect indentation level, expected level should be 4.
* whether the expected mocked {@link Intent} used by this method was really received by the
Line is longer than 100 characters (found 114).
final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
Wrong lexicographical order for 'java.io.InputStreamReader' import. Should be before 'org.junit.runner.Description'.
import java.io.InputStreamReader;
Line is longer than 100 characters (found 108).
protected void skipped(final AssumptionViolatedException exception, final Description description) {
'private' modifier out of order with the JLS suggestions.
final private Deque<Runnable> closeActions = new ArrayDeque<>();
Line is longer than 100 characters (found 121).
final int numCores = UtilsContext.getNumOfCores(InstrumentationRegistry.getInstrumentation().getTargetContext());
<p> tag should be placed immediately before the first word, with no space after.</p>
* <p>
Line is longer than 100 characters (found 122).
final List<ActivityManager.RunningTaskInfo> tasksRunning = activityManager.getRunningTasks(Integer.MAX_VALUE);
Line is longer than 100 characters (found 105).
? UtilsContext.getSdCardPath(InstrumentationRegistry.getInstrumentation().getTargetContext())
Line is longer than 100 characters (found 115).
: UtilsContext.getInternalStoragePath(InstrumentationRegistry.getInstrumentation().getTargetContext());
Line is longer than 100 characters (found 137).
clipData.addItem(new ClipData.Item(Uri.fromFile(new File(storagePath + ConstantsUI.FILE_SEPARATOR + filesPath[index]))));
Line is longer than 100 characters (found 123).
final Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultIntent);
Line is longer than 100 characters (found 123).
final BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
Wrong lexicographical order for 'java.nio.file.FileSystem' import. Should be before 'org.junit.runner.Description'.
import java.nio.file.FileSystem;
<p> tag should be preceded with an empty line.</p>
* <p>
Line is longer than 100 characters (found 130).
Matchers.anyOf(IntentMatchers.hasAction(Intent.ACTION_GET_CONTENT), IntentMatchers.hasAction(Intent.ACTION_MAIN)),
Line is longer than 100 characters (found 152).
Matchers.allOf(IntentMatchers.hasCategories(Collections.singleton(Intent.CATEGORY_LAUNCHER)), IntentMatchers.hasAction(Intent.ACTION_MAIN)),
Line is longer than 100 characters (found 107).
logger.info("Permission '" + permission + "' granted to the app: " + context.getPackageName());
Line is longer than 100 characters (found 119).
UtilsContextT.waitUntil(this.testName.getMethodName(), activity, Constants.RENDER, State.IDLE, State.FINISHED);
Extra separation in import group before 'org.hamcrest.Matchers'
import org.hamcrest.Matchers;
Line is longer than 100 characters (found 101).
mainActivityActivityTestRule.getScenario().onActivity(newActivity -> activity = newActivity);
Line is longer than 100 characters (found 115).
logger.info("Granting permissions to the MainActivity to be able to read files from an external storage.");
Line is longer than 100 characters (found 103).
UtilsPickerT.changePickerValue(ConstantsUI.PICKER_SHADER, R.id.pickerShader, shader.ordinal());
Line is longer than 100 characters (found 157).
final Intent expectedIntent = MainActivity.createIntentToLoadFiles(InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName());
Extra separation in import group before 'com.google.common.base.Preconditions'
import com.google.common.base.Preconditions;
Line is longer than 100 characters (found 129).
logger.info("Waiting for the permission '" + permission + "' to be granted to the app: " + context.getPackageName());
Line is longer than 100 characters (found 103).
UtilsPickerT.changePickerValue(ConstantsUI.PICKER_SAMPLES_PIXEL, R.id.pickerSamplesPixel, spp);
Line is longer than 100 characters (found 103).
UtilsPickerT.changePickerValue(ConstantsUI.PICKER_SAMPLES_LIGHT, R.id.pickerSamplesLight, spl);
There are no issues that match your filters.