The following issues were found

picasso/src/oldTests/java/com/squareup/picasso3/BitmapHunterTest.java
456 issues
Avoid throwing null pointer exceptions.
Design

Line: 981

                @Test public void crashingOnTransformationThrows() {
    Transformation badTransformation = new Transformation() {
      @Override public RequestHandler.Result transform(RequestHandler.Result source) {
        throw new NullPointerException("hello");
      }

      @Override public String key() {
        return "test";
      }

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 100

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);

            

Reported by PMD.

The class 'BitmapHunterTest' has a total cyclomatic complexity of 84 (highest 2).
Design

Line: 100

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);

            

Reported by PMD.

Possible God Class (WMC=84, ATFD=232, TCC=17.916%)
Design

Line: 100

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);

            

Reported by PMD.

Avoid really long classes.
Design

Line: 100

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 102

              @RunWith(RobolectricTestRunner.class)
public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);
  @Mock Dispatcher dispatcher;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 103

              public final class BitmapHunterTest {

  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);
  @Mock Dispatcher dispatcher;

  final Bitmap bitmap = makeBitmap();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 104

              
  @Mock Context context;
  @Mock Picasso picasso;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  final Stats stats = new Stats(cache);
  @Mock Dispatcher dispatcher;

  final Bitmap bitmap = makeBitmap();


            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/RequestCreatorTest.java
222 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.app.Notification;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.app.Notification;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;

            

Reported by PMD.

The class 'RequestCreatorTest' has a total cyclomatic complexity of 130 (highest 5).
Design

Line: 78

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {

  @Mock Picasso picasso;
  @Captor ArgumentCaptor<Action> actionCaptor;

  final Bitmap bitmap = makeBitmap();

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 78

              import static org.robolectric.Shadows.shadowOf;

@RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {

  @Mock Picasso picasso;
  @Captor ArgumentCaptor<Action> actionCaptor;

  final Bitmap bitmap = makeBitmap();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 80

              @RunWith(RobolectricTestRunner.class)
public class RequestCreatorTest {

  @Mock Picasso picasso;
  @Captor ArgumentCaptor<Action> actionCaptor;

  final Bitmap bitmap = makeBitmap();

  @Before public void shutUp() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 81

              public class RequestCreatorTest {

  @Mock Picasso picasso;
  @Captor ArgumentCaptor<Action> actionCaptor;

  final Bitmap bitmap = makeBitmap();

  @Before public void shutUp() {
    initMocks(this);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 83

                @Mock Picasso picasso;
  @Captor ArgumentCaptor<Action> actionCaptor;

  final Bitmap bitmap = makeBitmap();

  @Before public void shutUp() {
    initMocks(this);
    when(picasso.transformRequest(any(Request.class))).thenAnswer(TRANSFORM_REQUEST_ANSWER);
  }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 87

              
  @Before public void shutUp() {
    initMocks(this);
    when(picasso.transformRequest(any(Request.class))).thenAnswer(TRANSFORM_REQUEST_ANSWER);
  }

  @Test
  public void getOnMainCrashes() throws IOException {
    try {

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 94

                public void getOnMainCrashes() throws IOException {
    try {
      new RequestCreator(picasso, URI_1, 0).get();
      fail("Calling get() on main thread should throw exception");
    } catch (IllegalStateException ignored) {
    }
  }

  @Test public void loadWithShutdownCrashes() {

            

Reported by PMD.

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 103

                  picasso.shutdown = true;
    try {
      new RequestCreator(picasso, URI_1, 0).fetch();
      fail("Should have crashed with a shutdown picasso.");
    } catch (IllegalStateException ignored) {
    }
  }

  @Test public void getReturnsNullIfNullUriAndResourceId() throws InterruptedException {

            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/PicassoTest.java
211 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 75

              
@RunWith(RobolectricTestRunner.class)
@Config(sdk = 23) // Works around https://github.com/robolectric/robolectric/issues/2566.
public final class PicassoTest {
  private static final int NUM_BUILTIN_HANDLERS = 8;
  private static final int NUM_BUILTIN_TRANSFORMERS = 0;

  @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
  @Mock Context context;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 79

                private static final int NUM_BUILTIN_HANDLERS = 8;
  private static final int NUM_BUILTIN_TRANSFORMERS = 0;

  @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
  @Mock Context context;
  @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 80

                private static final int NUM_BUILTIN_TRANSFORMERS = 0;

  @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
  @Mock Context context;
  @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 81

              
  @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
  @Mock Context context;
  @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

  private Picasso picasso;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 82

                @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();
  @Mock Context context;
  @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

  private Picasso picasso;
  private EventRecorder eventRecorder = new EventRecorder();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 83

                @Mock Context context;
  @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

  private Picasso picasso;
  private EventRecorder eventRecorder = new EventRecorder();
  final Bitmap bitmap = makeBitmap();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 84

                @Mock Dispatcher dispatcher;
  @Mock RequestHandler requestHandler;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

  private Picasso picasso;
  private EventRecorder eventRecorder = new EventRecorder();
  final Bitmap bitmap = makeBitmap();


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 86

                final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Listener listener;

  private Picasso picasso;
  private EventRecorder eventRecorder = new EventRecorder();
  final Bitmap bitmap = makeBitmap();

  @Before public void setUp() {
    initMocks(this);

            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/DispatcherTest.java
178 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 70

              import static org.mockito.MockitoAnnotations.initMocks;

@RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
  @Mock Context context;
  @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 71

              
@RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
  @Mock Context context;
  @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 72

              @RunWith(RobolectricTestRunner.class)
public class DispatcherTest {
  @Mock Context context;
  @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 73

              public class DispatcherTest {
  @Mock Context context;
  @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 74

                @Mock Context context;
  @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;

  final Bitmap bitmap1 = makeBitmap();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 75

                @Mock ConnectivityManager connectivityManager;
  @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;

  final Bitmap bitmap1 = makeBitmap();
  final Bitmap bitmap2 = makeBitmap();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 76

                @Mock PicassoExecutorService service;
  @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;

  final Bitmap bitmap1 = makeBitmap();
  final Bitmap bitmap2 = makeBitmap();


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 77

                @Mock ExecutorService serviceMock;
  final PlatformLruCache cache = new PlatformLruCache(2048);
  @Mock Stats stats;
  private Dispatcher dispatcher;

  final Bitmap bitmap1 = makeBitmap();
  final Bitmap bitmap2 = makeBitmap();

  @Before public void setUp() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 79

                @Mock Stats stats;
  private Dispatcher dispatcher;

  final Bitmap bitmap1 = makeBitmap();
  final Bitmap bitmap2 = makeBitmap();

  @Before public void setUp() {
    initMocks(this);
    dispatcher = createDispatcher();

            

Reported by PMD.

picasso/src/main/java/com/squareup/picasso3/Picasso.java
89 issues
Avoid reassigning parameters such as 'request'
Design

Line: 511

                  return requestHandlers;
  }

  Request transformRequest(Request request) {
    for (int i = 0, size = requestTransformers.size(); i < size; i++) {
      RequestTransformer transformer = requestTransformers.get(i);
      Request transformed = transformer.transformRequest(request);
      if (transformed == null) {
        throw new IllegalStateException("Request transformer "

            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 601

                    // Resumed action is cached, complete immediately.
      deliverAction(new Result.Bitmap(bitmap, MEMORY), action, null);
      if (loggingEnabled) {
        log(OWNER_MAIN, VERB_COMPLETED, action.request.logId(), "from " + MEMORY);
      }
    } else {
      // Re-submit the action to the executor.
      enqueueAndSubmit(action);
      if (loggingEnabled) {

            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 623

                  if (result != null) {
      action.complete(result);
      if (loggingEnabled) {
        log(OWNER_MAIN, VERB_COMPLETED, action.request.logId(), "from " + result.loadedFrom);
      }
    } else {
      Exception exception = checkNotNull(e, "e == null");
      action.error(exception);
      if (loggingEnabled) {

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 68

               * Use {@see PicassoProvider#get()} for a global singleton instance
 * or construct your own instance with {@link Builder}.
 */
public class Picasso implements LifecycleObserver {

  /** Callbacks for Picasso events. */
  public interface Listener {
    /**
     * Invoked when an image has failed to load. This is useful for reporting image failures to a

            

Reported by PMD.

Possible God Class (WMC=98, ATFD=46, TCC=11.150%)
Design

Line: 68

               * Use {@see PicassoProvider#get()} for a global singleton instance
 * or construct your own instance with {@link Builder}.
 */
public class Picasso implements LifecycleObserver {

  /** Callbacks for Picasso events. */
  public interface Listener {
    /**
     * Invoked when an image has failed to load. This is useful for reporting image failures to a

            

Reported by PMD.

Too many fields
Design

Line: 68

               * Use {@see PicassoProvider#get()} for a global singleton instance
 * or construct your own instance with {@link Builder}.
 */
public class Picasso implements LifecycleObserver {

  /** Callbacks for Picasso events. */
  public interface Listener {
    /**
     * Invoked when an image has failed to load. This is useful for reporting image failures to a

            

Reported by PMD.

The class 'Picasso' has a total cyclomatic complexity of 98 (highest 7).
Design

Line: 68

               * Use {@see PicassoProvider#get()} for a global singleton instance
 * or construct your own instance with {@link Builder}.
 */
public class Picasso implements LifecycleObserver {

  /** Callbacks for Picasso events. */
  public interface Listener {
    /**
     * Invoked when an image has failed to load. This is useful for reporting image failures to a

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 117

                    switch (msg.what) {
        case HUNTER_COMPLETE: {
          BitmapHunter hunter = (BitmapHunter) msg.obj;
          hunter.picasso.complete(hunter);
          break;
        }
        case REQUEST_BATCH_RESUME:
          @SuppressWarnings("unchecked") List<Action> batch = (List<Action>) msg.obj;
          //noinspection ForLoopReplaceableByForEach

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 123

                      case REQUEST_BATCH_RESUME:
          @SuppressWarnings("unchecked") List<Action> batch = (List<Action>) msg.obj;
          //noinspection ForLoopReplaceableByForEach
          for (int i = 0, n = batch.size(); i < n; i++) {
            Action action = batch.get(i);
            action.picasso.resumeAction(action);
          }
          break;
        default:

            

Reported by PMD.

picasso-pollexor/src/test/java/com/squareup/picasso3/pollexor/PollexorRequestTransformerTest.java
79 issues
This class has too many methods, consider refactoring it.
Design

Line: 22

                  sdk = 17,
    manifest = NONE
)
public class PollexorRequestTransformerTest {
  private static final String HOST = "http://example.com/";
  private static final String KEY = "omgsecretpassword";
  private static final String IMAGE = "http://google.com/logo.png";
  private static final Uri IMAGE_URI = Uri.parse(IMAGE);


            

Reported by PMD.

Private field 'transformer' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 28

                private static final String IMAGE = "http://google.com/logo.png";
  private static final Uri IMAGE_URI = Uri.parse(IMAGE);

  private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 28

                private static final String IMAGE = "http://google.com/logo.png";
  private static final Uri IMAGE_URI = Uri.parse(IMAGE);

  private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 29

                private static final Uri IMAGE_URI = Uri.parse(IMAGE);

  private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {
    Request input = new Request.Builder(12).build();

            

Reported by PMD.

Private field 'secureTransformer' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 29

                private static final Uri IMAGE_URI = Uri.parse(IMAGE);

  private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {
    Request input = new Request.Builder(12).build();

            

Reported by PMD.

Private field 'alwaysResizeTransformer' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 31

                private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {
    Request input = new Request.Builder(12).build();
    Request output = transformer.transformRequest(input);
    assertThat(output).isSameAs(input);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 31

                private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
  private RequestTransformer secureTransformer =
      new PollexorRequestTransformer(Thumbor.create(HOST, KEY));
  private RequestTransformer alwaysResizeTransformer = new PollexorRequestTransformer(Thumbor.create(HOST), true);

  @Test public void resourceIdRequestsAreNotTransformed() {
    Request input = new Request.Builder(12).build();
    Request output = transformer.transformRequest(input);
    assertThat(output).isSameAs(input);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 36

                @Test public void resourceIdRequestsAreNotTransformed() {
    Request input = new Request.Builder(12).build();
    Request output = transformer.transformRequest(input);
    assertThat(output).isSameAs(input);
  }

  @Test public void resourceIdRequestsAreNotTransformedWhenAlwaysTransformIsTrue() {
    Request input = new Request.Builder(12).build();
    Request output = alwaysResizeTransformer.transformRequest(input);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 42

                @Test public void resourceIdRequestsAreNotTransformedWhenAlwaysTransformIsTrue() {
    Request input = new Request.Builder(12).build();
    Request output = alwaysResizeTransformer.transformRequest(input);
    assertThat(output).isSameAs(input);
  }

  @Test public void nonHttpRequestsAreNotTransformed() {
    Request input = new Request.Builder(IMAGE_URI).build();
    Request output = transformer.transformRequest(input);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 48

                @Test public void nonHttpRequestsAreNotTransformed() {
    Request input = new Request.Builder(IMAGE_URI).build();
    Request output = transformer.transformRequest(input);
    assertThat(output).isSameAs(input);
  }

  @Test public void nonResizedRequestsAreNotTransformed() {
    Request input = new Request.Builder(IMAGE_URI).build();
    Request output = transformer.transformRequest(input);

            

Reported by PMD.

picasso/src/main/java/com/squareup/picasso3/Dispatcher.java
75 issues
Logger calls should be surrounded by log level guards.
Design

Line: 174

                  if (pausedTags.contains(action.getTag())) {
      pausedActions.put(action.getTarget(), action);
      if (action.picasso.loggingEnabled) {
        log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(),
            "because tag '" + action.getTag() + "' is paused");
      }
      return;
    }


            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 257

                      hunter.detach(single);
        pausedActions.put(single.getTarget(), single);
        if (loggingEnabled) {
          log(OWNER_DISPATCHER, VERB_PAUSED, single.request.logId(),
              "because tag '" + tag + "' was paused");
        }
      }

      if (joined != null) {

            

Reported by PMD.

Logger calls should be surrounded by log level guards.
Design

Line: 272

                        hunter.detach(action);
          pausedActions.put(action.getTarget(), action);
          if (loggingEnabled) {
            log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(),
                "because tag '" + tag + "' was paused");
          }
        }
      }


            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;

            

Reported by PMD.

Possible God Class (WMC=85, ATFD=63, TCC=19.077%)
Design

Line: 61

              import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;

class Dispatcher {
  private static final int RETRY_DELAY = 500;
  private static final int AIRPLANE_MODE_ON = 1;
  private static final int AIRPLANE_MODE_OFF = 0;

  static final int REQUEST_SUBMIT = 1;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 61

              import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;

class Dispatcher {
  private static final int RETRY_DELAY = 500;
  private static final int AIRPLANE_MODE_ON = 1;
  private static final int AIRPLANE_MODE_OFF = 0;

  static final int REQUEST_SUBMIT = 1;

            

Reported by PMD.

The class 'Dispatcher' has a total cyclomatic complexity of 85 (highest 14).
Design

Line: 61

              import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;

class Dispatcher {
  private static final int RETRY_DELAY = 500;
  private static final int AIRPLANE_MODE_ON = 1;
  private static final int AIRPLANE_MODE_OFF = 0;

  static final int REQUEST_SUBMIT = 1;

            

Reported by PMD.

The class 'Dispatcher' has a Standard Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 61

              import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;

class Dispatcher {
  private static final int RETRY_DELAY = 500;
  private static final int AIRPLANE_MODE_ON = 1;
  private static final int AIRPLANE_MODE_OFF = 0;

  static final int REQUEST_SUBMIT = 1;

            

Reported by PMD.

The class 'Dispatcher' has a Modified Cyclomatic Complexity of 3 (Highest = 12).
Design

Line: 61

              import static com.squareup.picasso3.Utils.hasPermission;
import static com.squareup.picasso3.Utils.log;

class Dispatcher {
  private static final int RETRY_DELAY = 500;
  private static final int AIRPLANE_MODE_ON = 1;
  private static final int AIRPLANE_MODE_OFF = 0;

  static final int REQUEST_SUBMIT = 1;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 79

              
  private static final String DISPATCHER_THREAD_NAME = "Dispatcher";

  final DispatcherThread dispatcherThread;
  final Context context;
  final ExecutorService service;
  final Map<String, BitmapHunter> hunterMap;
  final Map<Object, Action> failedActions;
  final Map<Object, Action> pausedActions;

            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/NetworkRequestHandlerTest.java
66 issues
A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

               * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.squareup.picasso3;

import android.net.NetworkInfo;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.squareup.picasso3.RequestHandler.Result;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 55

              import static org.mockito.MockitoAnnotations.initMocks;

@RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
  final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
  final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();

  @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 56

              
@RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
  final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
  final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();

  @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 57

              @RunWith(RobolectricTestRunner.class)
public class NetworkRequestHandlerTest {
  final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
  final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();

  @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;

  private NetworkRequestHandler networkHandler;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 59

                final BlockingDeque<Response> responses = new LinkedBlockingDeque<>();
  final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();

  @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;

  private NetworkRequestHandler networkHandler;

  @Before public void setUp() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 60

                final BlockingDeque<okhttp3.Request> requests = new LinkedBlockingDeque<>();

  @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;

  private NetworkRequestHandler networkHandler;

  @Before public void setUp() {
    initMocks(this);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 62

                @Mock Picasso picasso;
  @Mock Dispatcher dispatcher;

  private NetworkRequestHandler networkHandler;

  @Before public void setUp() {
    initMocks(this);
    networkHandler = new NetworkRequestHandler(new Call.Factory() {
      @Override public Call newCall(Request request) {

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 78

                  });
  }

  @Test public void doesNotForceLocalCacheOnlyWithAirplaneModeOffAndRetryCount() throws Exception {
    responses.add(responseOf(ResponseBody.create(null, new byte[10])));
    Action action = TestUtils.mockAction(URI_KEY_1, URI_1);
    final CountDownLatch latch = new CountDownLatch(1);
    networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
      @Override public void onSuccess(Result result) {

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 78

                  });
  }

  @Test public void doesNotForceLocalCacheOnlyWithAirplaneModeOffAndRetryCount() throws Exception {
    responses.add(responseOf(ResponseBody.create(null, new byte[10])));
    Action action = TestUtils.mockAction(URI_KEY_1, URI_1);
    final CountDownLatch latch = new CountDownLatch(1);
    networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
      @Override public void onSuccess(Result result) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 85

                  networkHandler.load(picasso, action.request, new RequestHandler.Callback() {
      @Override public void onSuccess(Result result) {
        try {
          assertThat(requests.takeFirst().cacheControl().toString()).isEmpty();
          latch.countDown();
        } catch (InterruptedException e) {
          throw new AssertionError(e);
        }
      }

            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/TestUtils.java
62 issues
Avoid throwing raw exception types.
Design

Line: 121

                  try {
      doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
    doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
    return context;
  }


            

Reported by PMD.

High amount of different objects as members denotes a high coupling
Design

Line: 16

              * See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;

import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;

            

Reported by PMD.

A high number of imports can indicate a high degree of coupling within an object.
Design

Line: 16

              * See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.picasso3;

import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 60

              import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

class TestUtils {
  static final Answer<Object> TRANSFORM_REQUEST_ANSWER = new Answer<Object>() {
    @Override public Object answer(InvocationOnMock invocation) throws Throwable {
      return invocation.getArguments()[0];
    }
  };

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 117

                  PackageManager pm = mock(PackageManager.class);
    Resources res = mock(Resources.class);

    doReturn(pm).when(context).getPackageManager();
    try {
      doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 117

                  PackageManager pm = mock(PackageManager.class);
    Resources res = mock(Resources.class);

    doReturn(pm).when(context).getPackageManager();
    try {
      doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 119

              
    doReturn(pm).when(context).getPackageManager();
    try {
      doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
    doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
    return context;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 119

              
    doReturn(pm).when(context).getPackageManager();
    try {
      doReturn(res).when(pm).getResourcesForApplication(RESOURCE_PACKAGE);
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
    doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
    return context;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 123

                  } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
    doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
    return context;
  }

  static Resources mockResources(final String resValueString) {
    Resources resources = mock(Resources.class);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 123

                  } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
    doReturn(RESOURCE_ID_1).when(res).getIdentifier(RESOURCE_NAME, RESOURCE_TYPE, RESOURCE_PACKAGE);
    return context;
  }

  static Resources mockResources(final String resValueString) {
    Resources resources = mock(Resources.class);

            

Reported by PMD.

picasso/src/oldTests/java/com/squareup/picasso3/PlatformLruCacheTest.java
48 issues
This class has too many methods, consider refactoring it.
Design

Line: 33

              import static junit.framework.Assert.fail;

@RunWith(RobolectricTestRunner.class)
public class PlatformLruCacheTest {
  // The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
  private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 35

              @RunWith(RobolectricTestRunner.class)
public class PlatformLruCacheTest {
  // The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
  private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 36

              public class PlatformLruCacheTest {
  // The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
  private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 37

                // The use of ALPHA_8 simplifies the size math in tests since only one byte is used per-pixel.
  private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;
  private int expectedHitCount;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

                private final Bitmap A = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

                private final Bitmap B = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap C = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;
  private int expectedEvictionCount;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 41

                private final Bitmap D = Bitmap.createBitmap(1, 1, ALPHA_8);
  private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;
  private int expectedEvictionCount;

  @Test public void testStatistics() {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 42

                private final Bitmap E = Bitmap.createBitmap(1, 1, ALPHA_8);

  private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;
  private int expectedEvictionCount;

  @Test public void testStatistics() {
    PlatformLruCache cache = new PlatformLruCache(3);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

              
  private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;
  private int expectedEvictionCount;

  @Test public void testStatistics() {
    PlatformLruCache cache = new PlatformLruCache(3);
    assertStatistics(cache);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 44

                private int expectedPutCount;
  private int expectedHitCount;
  private int expectedMissCount;
  private int expectedEvictionCount;

  @Test public void testStatistics() {
    PlatformLruCache cache = new PlatformLruCache(3);
    assertStatistics(cache);


            

Reported by PMD.