The following issues were found
picasso/src/main/java/com/squareup/picasso3/RequestCreator.java
46 issues
Line: 471
Bitmap bitmap = picasso.quickMemoryCacheCheck(request.key);
if (bitmap != null) {
if (picasso.loggingEnabled) {
log(OWNER_MAIN, VERB_COMPLETED, request.plainId(), "from " + MEMORY);
}
if (callback != null) {
callback.onSuccess();
}
return;
Reported by PMD.
Line: 728
Result result = new Result.Bitmap(bitmap, MEMORY);
setResult(target, picasso.context, result, noFade, picasso.indicatorsEnabled);
if (picasso.loggingEnabled) {
log(OWNER_MAIN, VERB_COMPLETED, request.plainId(), "from " + MEMORY);
}
if (callback != null) {
callback.onSuccess();
}
return;
Reported by PMD.
Line: 772
transformed.started = started;
if (loggingEnabled) {
log(OWNER_MAIN, VERB_CHANGED, transformed.logId(), "into " + transformed);
}
}
return transformed;
}
Reported by PMD.
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.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Reported by PMD.
Line: 58
/** Fluent API for building an image download request. */
@SuppressWarnings("UnusedDeclaration") // Public API.
public class RequestCreator {
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
Reported by PMD.
Line: 58
/** Fluent API for building an image download request. */
@SuppressWarnings("UnusedDeclaration") // Public API.
public class RequestCreator {
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
Reported by PMD.
Line: 58
/** Fluent API for building an image download request. */
@SuppressWarnings("UnusedDeclaration") // Public API.
public class RequestCreator {
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
Reported by PMD.
Line: 58
/** Fluent API for building an image download request. */
@SuppressWarnings("UnusedDeclaration") // Public API.
public class RequestCreator {
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
Reported by PMD.
Line: 61
public class RequestCreator {
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
private boolean noFade;
private boolean deferred;
private boolean setPlaceholder = true;
Reported by PMD.
Line: 62
private static final AtomicInteger nextId = new AtomicInteger();
private final Picasso picasso;
private final Request.Builder data;
private boolean noFade;
private boolean deferred;
private boolean setPlaceholder = true;
private int placeholderResId;
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/DeferredRequestCreatorTest.java
41 issues
Line: 44
@RunWith(RobolectricTestRunner.class)
public class DeferredRequestCreatorTest {
@Captor ArgumentCaptor<Action> actionCaptor;
@Before public void setUp() {
initMocks(this);
}
Reported by PMD.
Line: 52
@Test public void initWhileAttachedAddsAttachAndPreDrawListener() {
ImageView target = mockFitImageViewTarget(true);
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(observer).addOnPreDrawListener(request);
}
Reported by PMD.
Line: 55
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(observer).addOnPreDrawListener(request);
}
@Test public void initWhileDetachedAddsAttachListenerWhichDefersPreDrawListener() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWindowToken()).thenReturn(null);
Reported by PMD.
Line: 60
@Test public void initWhileDetachedAddsAttachListenerWhichDefersPreDrawListener() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWindowToken()).thenReturn(null);
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(target).addOnAttachStateChangeListener(request);
verifyNoMoreInteractions(observer);
Reported by PMD.
Line: 60
@Test public void initWhileDetachedAddsAttachListenerWhichDefersPreDrawListener() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWindowToken()).thenReturn(null);
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(target).addOnAttachStateChangeListener(request);
verifyNoMoreInteractions(observer);
Reported by PMD.
Line: 61
@Test public void initWhileDetachedAddsAttachListenerWhichDefersPreDrawListener() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWindowToken()).thenReturn(null);
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(target).addOnAttachStateChangeListener(request);
verifyNoMoreInteractions(observer);
Reported by PMD.
Line: 64
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request =
new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(target).addOnAttachStateChangeListener(request);
verifyNoMoreInteractions(observer);
// Attach and ensure we defer to the pre-draw listener.
request.onViewAttachedToWindow(target);
verify(observer).addOnPreDrawListener(request);
Reported by PMD.
Line: 69
// Attach and ensure we defer to the pre-draw listener.
request.onViewAttachedToWindow(target);
verify(observer).addOnPreDrawListener(request);
// Detach and ensure we remove the pre-draw listener from the original VTO.
request.onViewDetachedFromWindow(target);
verify(observer).removeOnPreDrawListener(request);
}
Reported by PMD.
Line: 73
// Detach and ensure we remove the pre-draw listener from the original VTO.
request.onViewDetachedFromWindow(target);
verify(observer).removeOnPreDrawListener(request);
}
@Test public void cancelWhileAttachedRemovesAttachListener() {
ImageView target = mockFitImageViewTarget(true);
DeferredRequestCreator request = new DeferredRequestCreator(mock(RequestCreator.class), target, null);
Reported by PMD.
Line: 79
@Test public void cancelWhileAttachedRemovesAttachListener() {
ImageView target = mockFitImageViewTarget(true);
DeferredRequestCreator request = new DeferredRequestCreator(mock(RequestCreator.class), target, null);
verify(target).addOnAttachStateChangeListener(request);
request.cancel();
verify(target).removeOnAttachStateChangeListener(request);
}
@Test public void cancelClearsCallback() {
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/MatrixTransformation.java
41 issues
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
Line: 34
import static com.squareup.picasso3.BitmapUtils.shouldResize;
import static com.squareup.picasso3.RequestHandler.Result;
final class MatrixTransformation implements Transformation {
private final Request data;
MatrixTransformation(Request data) {
this.data = data;
}
Reported by PMD.
Line: 34
import static com.squareup.picasso3.BitmapUtils.shouldResize;
import static com.squareup.picasso3.RequestHandler.Result;
final class MatrixTransformation implements Transformation {
private final Request data;
MatrixTransformation(Request data) {
this.data = data;
}
Reported by PMD.
Line: 34
import static com.squareup.picasso3.BitmapUtils.shouldResize;
import static com.squareup.picasso3.RequestHandler.Result;
final class MatrixTransformation implements Transformation {
private final Request data;
MatrixTransformation(Request data) {
this.data = data;
}
Reported by PMD.
Line: 35
import static com.squareup.picasso3.RequestHandler.Result;
final class MatrixTransformation implements Transformation {
private final Request data;
MatrixTransformation(Request data) {
this.data = data;
}
Reported by PMD.
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
Line: 54
}
@VisibleForTesting
static Bitmap transformResult(Request data, Bitmap result, int exifOrientation) {
int inWidth = result.getWidth();
int inHeight = result.getHeight();
boolean onlyScaleDown = data.onlyScaleDown;
int drawX = 0;
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/BitmapUtilsTest.java
33 issues
Line: 32
import static com.squareup.picasso3.TestUtils.URI_1;
@RunWith(RobolectricTestRunner.class)
public class BitmapUtilsTest {
@Test public void bitmapConfig() {
for (Bitmap.Config config : Bitmap.Config.values()) {
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
Reported by PMD.
Line: 34
@RunWith(RobolectricTestRunner.class)
public class BitmapUtilsTest {
@Test public void bitmapConfig() {
for (Bitmap.Config config : Bitmap.Config.values()) {
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
Reported by PMD.
Line: 35
public class BitmapUtilsTest {
@Test public void bitmapConfig() {
for (Bitmap.Config config : Bitmap.Config.values()) {
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
Reported by PMD.
Line: 36
@Test public void bitmapConfig() {
for (Bitmap.Config config : Bitmap.Config.values()) {
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
}
Reported by PMD.
Line: 39
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
}
}
@Test public void requiresComputeInSampleSize() {
Reported by PMD.
Line: 39
Request data = new Request.Builder(URI_1).config(config).build();
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
}
}
@Test public void requiresComputeInSampleSize() {
Reported by PMD.
Line: 40
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
}
}
@Test public void requiresComputeInSampleSize() {
assertThat(requiresInSampleSize(null)).isFalse();
Reported by PMD.
Line: 40
Request copy = data.newBuilder().build();
assertThat(createBitmapOptions(data).inPreferredConfig).isSameAs(config);
assertThat(createBitmapOptions(copy).inPreferredConfig).isSameAs(config);
}
}
@Test public void requiresComputeInSampleSize() {
assertThat(requiresInSampleSize(null)).isFalse();
Reported by PMD.
Line: 44
}
}
@Test public void requiresComputeInSampleSize() {
assertThat(requiresInSampleSize(null)).isFalse();
final BitmapFactory.Options defaultOptions = new BitmapFactory.Options();
assertThat(requiresInSampleSize(defaultOptions)).isFalse();
final BitmapFactory.Options justBounds = new BitmapFactory.Options();
justBounds.inJustDecodeBounds = true;
Reported by PMD.
Line: 45
}
@Test public void requiresComputeInSampleSize() {
assertThat(requiresInSampleSize(null)).isFalse();
final BitmapFactory.Options defaultOptions = new BitmapFactory.Options();
assertThat(requiresInSampleSize(defaultOptions)).isFalse();
final BitmapFactory.Options justBounds = new BitmapFactory.Options();
justBounds.inJustDecodeBounds = true;
assertThat(requiresInSampleSize(justBounds)).isTrue();
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/Utils.java
31 issues
Line: 102
public static @NonNull <T> T checkNotNull(@Nullable T value, @Nullable String message) {
if (value == null) {
throw new NullPointerException(message);
}
return value;
}
static void checkNotMain() {
Reported by PMD.
Line: 147
log(owner, verb, logId, "");
}
static void log(String owner, String verb, String logId, @Nullable String extras) {
if (extras == null) {
extras = "";
}
Log.d(TAG, format("%1$-11s %2$-12s %3$s %4$s", owner, verb, logId, extras));
}
Reported by PMD.
Line: 49
import static com.squareup.picasso3.Picasso.TAG;
import static java.lang.String.format;
final class Utils {
static final String THREAD_PREFIX = "Picasso-";
static final String THREAD_IDLE_NAME = THREAD_PREFIX + "Idle";
private static final String PICASSO_CACHE = "picasso-cache";
private static final int MIN_DISK_CACHE_SIZE = 5 * 1024 * 1024; // 5MB
private static final int MAX_DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
Reported by PMD.
Line: 58
static final int THREAD_LEAK_CLEANING_MS = 1000;
/** Thread confined to main thread for key creation. */
static final StringBuilder MAIN_THREAD_KEY_BUILDER = new StringBuilder();
/** Logging */
static final String OWNER_MAIN = "Main";
static final String OWNER_DISPATCHER = "Dispatcher";
static final String OWNER_HUNTER = "Hunter";
Reported by PMD.
Line: 120
}
static boolean isMain() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
static String getLogIdsForHunter(BitmapHunter hunter) {
return getLogIdsForHunter(hunter, "");
}
Reported by PMD.
Line: 131
StringBuilder builder = new StringBuilder(prefix);
Action action = hunter.getAction();
if (action != null) {
builder.append(action.request.logId());
}
List<Action> actions = hunter.getActions();
if (actions != null) {
for (int i = 0, count = actions.size(); i < count; i++) {
if (i > 0 || action != null) builder.append(", ");
Reported by PMD.
Line: 135
}
List<Action> actions = hunter.getActions();
if (actions != null) {
for (int i = 0, count = actions.size(); i < count; i++) {
if (i > 0 || action != null) builder.append(", ");
builder.append(actions.get(i).request.logId());
}
}
return builder.toString();
Reported by PMD.
Line: 137
if (actions != null) {
for (int i = 0, count = actions.size(); i < count; i++) {
if (i > 0 || action != null) builder.append(", ");
builder.append(actions.get(i).request.logId());
}
}
return builder.toString();
}
Reported by PMD.
Line: 137
if (actions != null) {
for (int i = 0, count = actions.size(); i < count; i++) {
if (i > 0 || action != null) builder.append(", ");
builder.append(actions.get(i).request.logId());
}
}
return builder.toString();
}
Reported by PMD.
Line: 155
}
static File createDefaultCacheDir(Context context) {
File cache = new File(context.getApplicationContext().getCacheDir(), PICASSO_CACHE);
if (!cache.exists()) {
//noinspection ResultOfMethodCallIgnored
cache.mkdirs();
}
return cache;
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/MediaStoreRequestHandlerTest.java
24 issues
Line: 1
package com.squareup.picasso3;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.squareup.picasso3.RequestHandler.Result;
import java.util.Objects;
Reported by PMD.
Line: 39
@Config(shadows = { Shadows.ShadowVideoThumbnails.class, Shadows.ShadowImageThumbnails.class })
public class MediaStoreRequestHandlerTest {
@Mock Context context;
@Before public void setUp() {
initMocks(this);
}
Reported by PMD.
Line: 45
initMocks(this);
}
@Test public void decodesVideoThumbnailWithVideoMimeType() {
final Bitmap bitmap = makeBitmap();
Request request =
new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, ARGB_8888)
.stableKey(MEDIA_STORE_CONTENT_KEY_1).resize(100, 100).build();
Action action = mockAction(request);
Reported by PMD.
Line: 63
});
}
@Test public void decodesImageThumbnailWithImageMimeType() {
final Bitmap bitmap = makeBitmap(20, 20);
Request request =
new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, ARGB_8888)
.stableKey(MEDIA_STORE_CONTENT_KEY_1).resize(100, 100).build();
Action action = mockAction(request);
Reported by PMD.
Line: 81
});
}
@Test public void getPicassoKindMicro() {
assertThat(getPicassoKind(96, 96)).isEqualTo(MICRO);
assertThat(getPicassoKind(95, 95)).isEqualTo(MICRO);
}
@Test public void getPicassoKindMini() {
Reported by PMD.
Line: 82
}
@Test public void getPicassoKindMicro() {
assertThat(getPicassoKind(96, 96)).isEqualTo(MICRO);
assertThat(getPicassoKind(95, 95)).isEqualTo(MICRO);
}
@Test public void getPicassoKindMini() {
assertThat(getPicassoKind(512, 384)).isEqualTo(MINI);
Reported by PMD.
Line: 83
@Test public void getPicassoKindMicro() {
assertThat(getPicassoKind(96, 96)).isEqualTo(MICRO);
assertThat(getPicassoKind(95, 95)).isEqualTo(MICRO);
}
@Test public void getPicassoKindMini() {
assertThat(getPicassoKind(512, 384)).isEqualTo(MINI);
assertThat(getPicassoKind(100, 100)).isEqualTo(MINI);
Reported by PMD.
Line: 86
assertThat(getPicassoKind(95, 95)).isEqualTo(MICRO);
}
@Test public void getPicassoKindMini() {
assertThat(getPicassoKind(512, 384)).isEqualTo(MINI);
assertThat(getPicassoKind(100, 100)).isEqualTo(MINI);
}
@Test public void getPicassoKindFull() {
Reported by PMD.
Line: 87
}
@Test public void getPicassoKindMini() {
assertThat(getPicassoKind(512, 384)).isEqualTo(MINI);
assertThat(getPicassoKind(100, 100)).isEqualTo(MINI);
}
@Test public void getPicassoKindFull() {
assertThat(getPicassoKind(513, 385)).isEqualTo(FULL);
Reported by PMD.
Line: 88
@Test public void getPicassoKindMini() {
assertThat(getPicassoKind(512, 384)).isEqualTo(MINI);
assertThat(getPicassoKind(100, 100)).isEqualTo(MINI);
}
@Test public void getPicassoKindFull() {
assertThat(getPicassoKind(513, 385)).isEqualTo(FULL);
assertThat(getPicassoKind(1000, 1000)).isEqualTo(FULL);
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/MediaStoreRequestHandler.java
17 issues
Line: 56
@Override public boolean canHandleRequest(@NonNull Request data) {
final Uri uri = data.uri;
return uri != null
&& SCHEME_CONTENT.equals(uri.getScheme())
&& MediaStore.AUTHORITY.equals(uri.getAuthority());
}
@Override
public void load(@NonNull Picasso picasso, @NonNull Request request, @NonNull Callback callback) {
Reported by PMD.
Line: 57
final Uri uri = data.uri;
return uri != null
&& SCHEME_CONTENT.equals(uri.getScheme())
&& MediaStore.AUTHORITY.equals(uri.getAuthority());
}
@Override
public void load(@NonNull Picasso picasso, @NonNull Request request, @NonNull Callback callback) {
boolean signaledCallback = false;
Reported by PMD.
Line: 57
final Uri uri = data.uri;
return uri != null
&& SCHEME_CONTENT.equals(uri.getScheme())
&& MediaStore.AUTHORITY.equals(uri.getAuthority());
}
@Override
public void load(@NonNull Picasso picasso, @NonNull Request request, @NonNull Callback callback) {
boolean signaledCallback = false;
Reported by PMD.
Line: 68
Uri requestUri = checkNotNull(request.uri, "request.uri == null");
int exifOrientation = getExifOrientation(requestUri);
String mimeType = contentResolver.getType(requestUri);
boolean isVideo = mimeType != null && mimeType.startsWith("video/");
if (request.hasSize()) {
PicassoKind picassoKind = getPicassoKind(request.targetWidth, request.targetHeight);
if (!isVideo && picassoKind == FULL) {
Reported by PMD.
Line: 69
int exifOrientation = getExifOrientation(requestUri);
String mimeType = contentResolver.getType(requestUri);
boolean isVideo = mimeType != null && mimeType.startsWith("video/");
if (request.hasSize()) {
PicassoKind picassoKind = getPicassoKind(request.targetWidth, request.targetHeight);
if (!isVideo && picassoKind == FULL) {
Source source = getSource(requestUri);
Reported by PMD.
Line: 96
// Since MediaStore doesn't provide the full screen kind thumbnail, we use the mini kind
// instead which is the largest thumbnail size can be fetched from MediaStore.
int kind = (picassoKind == FULL) ? Video.Thumbnails.MINI_KIND : picassoKind.androidKind;
bitmap = Video.Thumbnails.getThumbnail(contentResolver, id, kind, options);
} else {
bitmap =
Images.Thumbnails.getThumbnail(contentResolver, id, picassoKind.androidKind, options);
}
Reported by PMD.
Line: 99
bitmap = Video.Thumbnails.getThumbnail(contentResolver, id, kind, options);
} else {
bitmap =
Images.Thumbnails.getThumbnail(contentResolver, id, picassoKind.androidKind, options);
}
if (bitmap != null) {
signaledCallback = true;
callback.onSuccess(new Result.Bitmap(bitmap, DISK, exifOrientation));
Reported by PMD.
Line: 113
Bitmap bitmap = decodeStream(source, request);
signaledCallback = true;
callback.onSuccess(new Result.Bitmap(bitmap, DISK, exifOrientation));
} catch (Exception e) {
if (!signaledCallback) {
callback.onError(e);
}
}
}
Reported by PMD.
Line: 134
Cursor cursor = null;
try {
ContentResolver contentResolver = context.getContentResolver();
cursor = contentResolver.query(uri, CONTENT_ORIENTATION, null, null, null);
if (cursor == null || !cursor.moveToFirst()) {
return 0;
}
return cursor.getInt(0);
} catch (RuntimeException ignored) {
Reported by PMD.
Line: 139
return 0;
}
return cursor.getInt(0);
} catch (RuntimeException ignored) {
// If the orientation column doesn't exist, assume no rotation.
return 0;
} finally {
if (cursor != null) {
cursor.close();
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/UtilsTest.java
15 issues
Line: 36
@RunWith(RobolectricTestRunner.class)
public class UtilsTest {
@Test public void matchingRequestsHaveSameKey() {
Request request = new Request.Builder(URI_1).build();
Request request2 = new Request.Builder(URI_1).build();
assertThat(request.key).isEqualTo(request2.key);
Transformation t1 = new TestTransformation("foo", null);
Reported by PMD.
Line: 39
@Test public void matchingRequestsHaveSameKey() {
Request request = new Request.Builder(URI_1).build();
Request request2 = new Request.Builder(URI_1).build();
assertThat(request.key).isEqualTo(request2.key);
Transformation t1 = new TestTransformation("foo", null);
Transformation t2 = new TestTransformation("foo", null);
Request requestTransform1 = new Request.Builder(URI_1).transform(t1).build();
Request requestTransform2 = new Request.Builder(URI_1).transform(t2).build();
Reported by PMD.
Line: 41
Request request2 = new Request.Builder(URI_1).build();
assertThat(request.key).isEqualTo(request2.key);
Transformation t1 = new TestTransformation("foo", null);
Transformation t2 = new TestTransformation("foo", null);
Request requestTransform1 = new Request.Builder(URI_1).transform(t1).build();
Request requestTransform2 = new Request.Builder(URI_1).transform(t2).build();
assertThat(requestTransform1.key).isEqualTo(requestTransform2.key);
Reported by PMD.
Line: 45
Transformation t2 = new TestTransformation("foo", null);
Request requestTransform1 = new Request.Builder(URI_1).transform(t1).build();
Request requestTransform2 = new Request.Builder(URI_1).transform(t2).build();
assertThat(requestTransform1.key).isEqualTo(requestTransform2.key);
Transformation t3 = new TestTransformation("foo", null);
Transformation t4 = new TestTransformation("bar", null);
Request requestTransform3 = new Request.Builder(URI_1).transform(t3).transform(t4).build();
Request requestTransform4 = new Request.Builder(URI_1).transform(t3).transform(t4).build();
Reported by PMD.
Line: 51
Transformation t4 = new TestTransformation("bar", null);
Request requestTransform3 = new Request.Builder(URI_1).transform(t3).transform(t4).build();
Request requestTransform4 = new Request.Builder(URI_1).transform(t3).transform(t4).build();
assertThat(requestTransform3.key).isEqualTo(requestTransform4.key);
Transformation t5 = new TestTransformation("foo", null);
Transformation t6 = new TestTransformation("bar", null);
Request requestTransform5 = new Request.Builder(URI_1).transform(t5).transform(t6).build();
Request requestTransform6 = new Request.Builder(URI_1).transform(t6).transform(t5).build();
Reported by PMD.
Line: 57
Transformation t6 = new TestTransformation("bar", null);
Request requestTransform5 = new Request.Builder(URI_1).transform(t5).transform(t6).build();
Request requestTransform6 = new Request.Builder(URI_1).transform(t6).transform(t5).build();
assertThat(requestTransform5.key).isNotEqualTo(requestTransform6.key);
}
@Test public void detectedWebPFile() throws Exception {
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxWEBP"))).isTrue();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxxWEBP"))).isFalse();
Reported by PMD.
Line: 60
assertThat(requestTransform5.key).isNotEqualTo(requestTransform6.key);
}
@Test public void detectedWebPFile() throws Exception {
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxWEBP"))).isTrue();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxxWEBP"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("ABCDxxxxWEBP"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxABCD"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxWEBP"))).isFalse();
Reported by PMD.
Line: 60
assertThat(requestTransform5.key).isNotEqualTo(requestTransform6.key);
}
@Test public void detectedWebPFile() throws Exception {
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxWEBP"))).isTrue();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxxWEBP"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("ABCDxxxxWEBP"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxxxABCD"))).isFalse();
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxWEBP"))).isFalse();
Reported by PMD.
Line: 68
assertThat(isWebPFile(new Buffer().writeUtf8("RIFFxxWEBP"))).isFalse();
}
@Test public void ensureBuilderIsCleared() {
new Request.Builder(RESOURCE_ID_URI).build();
assertThat(Utils.MAIN_THREAD_KEY_BUILDER.length()).isEqualTo(0);
new Request.Builder(URI_1).build();
assertThat(Utils.MAIN_THREAD_KEY_BUILDER.length()).isEqualTo(0);
}
Reported by PMD.
Line: 70
@Test public void ensureBuilderIsCleared() {
new Request.Builder(RESOURCE_ID_URI).build();
assertThat(Utils.MAIN_THREAD_KEY_BUILDER.length()).isEqualTo(0);
new Request.Builder(URI_1).build();
assertThat(Utils.MAIN_THREAD_KEY_BUILDER.length()).isEqualTo(0);
}
@Test public void getResourceById() throws IOException {
Reported by PMD.
picasso/src/oldTests/java/com/squareup/picasso3/PicassoDrawableTest.java
15 issues
Line: 35
@RunWith(RobolectricTestRunner.class)
public class PicassoDrawableTest {
private final Context context = RuntimeEnvironment.application;
private final Drawable placeholder = new ColorDrawable(RED);
private final Bitmap bitmap = makeBitmap();
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
Reported by PMD.
Line: 36
@RunWith(RobolectricTestRunner.class)
public class PicassoDrawableTest {
private final Context context = RuntimeEnvironment.application;
private final Drawable placeholder = new ColorDrawable(RED);
private final Bitmap bitmap = makeBitmap();
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
Reported by PMD.
Line: 37
public class PicassoDrawableTest {
private final Context context = RuntimeEnvironment.application;
private final Drawable placeholder = new ColorDrawable(RED);
private final Bitmap bitmap = makeBitmap();
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isNull();
Reported by PMD.
Line: 39
private final Drawable placeholder = new ColorDrawable(RED);
private final Bitmap bitmap = makeBitmap();
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isNull();
assertThat(pd.animating).isTrue();
}
Reported by PMD.
Line: 41
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isNull();
assertThat(pd.animating).isTrue();
}
@Test public void createWithPlaceholderAnimation() {
Reported by PMD.
Line: 42
@Test public void createWithNoPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isNull();
assertThat(pd.animating).isTrue();
}
@Test public void createWithPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, DISK, false, false);
Reported by PMD.
Line: 43
PicassoDrawable pd = new PicassoDrawable(context, bitmap, null, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isNull();
assertThat(pd.animating).isTrue();
}
@Test public void createWithPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
Reported by PMD.
Line: 46
assertThat(pd.animating).isTrue();
}
@Test public void createWithPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isSameAs(placeholder);
assertThat(pd.animating).isTrue();
}
Reported by PMD.
Line: 48
@Test public void createWithPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isSameAs(placeholder);
assertThat(pd.animating).isTrue();
}
@Test public void createWithBitmapCacheHit() {
Reported by PMD.
Line: 49
@Test public void createWithPlaceholderAnimation() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, DISK, false, false);
assertThat(pd.getBitmap()).isSameAs(bitmap);
assertThat(pd.placeholder).isSameAs(placeholder);
assertThat(pd.animating).isTrue();
}
@Test public void createWithBitmapCacheHit() {
PicassoDrawable pd = new PicassoDrawable(context, bitmap, placeholder, MEMORY, false, false);
Reported by PMD.
picasso/src/main/java/com/squareup/picasso3/DeferredRequestCreator.java
14 issues
Line: 41
// Only add the pre-draw listener if the view is already attached.
// See: https://github.com/square/picasso/issues/1321
if (target.getWindowToken() != null) {
onViewAttachedToWindow(target);
}
}
@Override public void onViewAttachedToWindow(View view) {
view.getViewTreeObserver().addOnPreDrawListener(this);
Reported by PMD.
Line: 27
import androidx.annotation.VisibleForTesting;
class DeferredRequestCreator implements OnPreDrawListener, OnAttachStateChangeListener {
private final RequestCreator creator;
@VisibleForTesting final ImageView target;
@VisibleForTesting @Nullable Callback callback;
DeferredRequestCreator(RequestCreator creator, ImageView target, @Nullable Callback callback) {
this.creator = creator;
Reported by PMD.
Line: 28
class DeferredRequestCreator implements OnPreDrawListener, OnAttachStateChangeListener {
private final RequestCreator creator;
@VisibleForTesting final ImageView target;
@VisibleForTesting @Nullable Callback callback;
DeferredRequestCreator(RequestCreator creator, ImageView target, @Nullable Callback callback) {
this.creator = creator;
this.target = target;
Reported by PMD.
Line: 29
class DeferredRequestCreator implements OnPreDrawListener, OnAttachStateChangeListener {
private final RequestCreator creator;
@VisibleForTesting final ImageView target;
@VisibleForTesting @Nullable Callback callback;
DeferredRequestCreator(RequestCreator creator, ImageView target, @Nullable Callback callback) {
this.creator = creator;
this.target = target;
this.callback = callback;
Reported by PMD.
Line: 46
}
@Override public void onViewAttachedToWindow(View view) {
view.getViewTreeObserver().addOnPreDrawListener(this);
}
@Override public void onViewDetachedFromWindow(View view) {
view.getViewTreeObserver().removeOnPreDrawListener(this);
}
Reported by PMD.
Line: 50
}
@Override public void onViewDetachedFromWindow(View view) {
view.getViewTreeObserver().removeOnPreDrawListener(this);
}
@Override public boolean onPreDraw() {
ImageView target = this.target;
Reported by PMD.
Line: 56
@Override public boolean onPreDraw() {
ImageView target = this.target;
ViewTreeObserver vto = target.getViewTreeObserver();
if (!vto.isAlive()) {
return true;
}
int width = target.getWidth();
Reported by PMD.
Line: 57
ImageView target = this.target;
ViewTreeObserver vto = target.getViewTreeObserver();
if (!vto.isAlive()) {
return true;
}
int width = target.getWidth();
int height = target.getHeight();
Reported by PMD.
Line: 61
return true;
}
int width = target.getWidth();
int height = target.getHeight();
if (width <= 0 || height <= 0) {
return true;
}
Reported by PMD.
Line: 62
}
int width = target.getWidth();
int height = target.getHeight();
if (width <= 0 || height <= 0) {
return true;
}
Reported by PMD.