The following issues were found

android/guava/src/com/google/common/io/Files.java
56 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 92

                public static BufferedReader newReader(File file, Charset charset) throws FileNotFoundException {
    checkNotNull(file);
    checkNotNull(charset);
    return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
  }

  /**
   * Returns a buffered writer that writes to a file using the given character set.
   *

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 111

                public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException {
    checkNotNull(file);
    checkNotNull(charset);
    return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));
  }

  /**
   * Returns a new {@link ByteSource} for reading bytes from the given file.
   *

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 133

              
    @Override
    public FileInputStream openStream() throws IOException {
      return new FileInputStream(file);
    }

    @Override
    public Optional<Long> sizeIfKnown() {
      if (file.isFile()) {

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 196

              
    @Override
    public FileOutputStream openStream() throws IOException {
      return new FileOutputStream(file, modes.contains(APPEND));
    }

    @Override
    public String toString() {
      return "Files.asByteSink(" + file + ", " + modes + ")";

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.io;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.FileWriteMode.APPEND;


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.io;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.FileWriteMode.APPEND;


            

Reported by PMD.

The class 'Files' has a Standard Cyclomatic Complexity of 2 (Highest = 10).
Design

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

Possible God Class (WMC=70, ATFD=15, TCC=0.000%)
Design

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

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

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

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

Line: 125

              
  private static final class FileByteSource extends ByteSource {

    private final File file;

    private FileByteSource(File file) {
      this.file = checkNotNull(file);
    }


            

Reported by PMD.

android/guava-testlib/src/com/google/common/collect/testing/google/BiMapPutTester.java
56 issues
The String literal 'unchecked' appears 9 times in this file; the first occurrence is on line 37
Error

Line: 37

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapPutTester<K, V> extends AbstractBiMapTester<K, V> {

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 37

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapPutTester<K, V> extends AbstractBiMapTester<K, V> {

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {

            

Reported by PMD.

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

Line: 41

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {
      getMap().put(k1(), v0());
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success

            

Reported by PMD.

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

Line: 43

                public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {
      getMap().put(k1(), v0());
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success
    }
    // verify that the bimap is unchanged

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 52

                  expectAdded(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());

            

Reported by PMD.

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

Line: 56

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());
    // verify that the bimap is changed, and that the old inverse mapping
    // from v1 -> v0 is deleted
    expectContents(Helpers.mapEntry(k0(), v1()));
  }

            

Reported by PMD.

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

Line: 57

                @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());
    // verify that the bimap is changed, and that the old inverse mapping
    // from v1 -> v0 is deleted
    expectContents(Helpers.mapEntry(k0(), v1()));
  }


            

Reported by PMD.

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

Line: 67

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void putDistinctKeysDistinctValues() {
    getMap().put(k0(), v0());
    getMap().put(k1(), v1());
    expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 68

                @CollectionSize.Require(ZERO)
  public void putDistinctKeysDistinctValues() {
    getMap().put(k0(), v0());
    getMap().put(k1(), v1());
    expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 72

                  expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ONE)
  public void testForcePutKeyPresent() {
    getMap().forcePut(k0(), v1());
    expectContents(Helpers.mapEntry(k0(), v1()));

            

Reported by PMD.

guava/src/com/google/common/io/Files.java
56 issues
Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 92

                public static BufferedReader newReader(File file, Charset charset) throws FileNotFoundException {
    checkNotNull(file);
    checkNotNull(charset);
    return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
  }

  /**
   * Returns a buffered writer that writes to a file using the given character set.
   *

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 111

                public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException {
    checkNotNull(file);
    checkNotNull(charset);
    return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));
  }

  /**
   * Returns a new {@link ByteSource} for reading bytes from the given file.
   *

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 133

              
    @Override
    public FileInputStream openStream() throws IOException {
      return new FileInputStream(file);
    }

    @Override
    public Optional<Long> sizeIfKnown() {
      if (file.isFile()) {

            

Reported by PMD.

Avoid instantiating FileInputStream, FileOutputStream, FileReader, or FileWriter
Performance

Line: 196

              
    @Override
    public FileOutputStream openStream() throws IOException {
      return new FileOutputStream(file, modes.contains(APPEND));
    }

    @Override
    public String toString() {
      return "Files.asByteSink(" + file + ", " + modes + ")";

            

Reported by PMD.

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

Line: 15

               * the License.
 */

package com.google.common.io;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.FileWriteMode.APPEND;


            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 15

               * the License.
 */

package com.google.common.io;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.FileWriteMode.APPEND;


            

Reported by PMD.

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

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

The class 'Files' has a Standard Cyclomatic Complexity of 2 (Highest = 10).
Design

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

Possible God Class (WMC=70, ATFD=15, TCC=0.000%)
Design

Line: 70

               */
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Files {

  /** Maximum loop count when creating temp directories. */
  private static final int TEMP_DIR_ATTEMPTS = 10000;

  private Files() {}

            

Reported by PMD.

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

Line: 125

              
  private static final class FileByteSource extends ByteSource {

    private final File file;

    private FileByteSource(File file) {
      this.file = checkNotNull(file);
    }


            

Reported by PMD.

android/guava/src/com/google/common/net/PercentEscaper.java
56 issues
Avoid reassigning parameters such as 'safeChars'
Design

Line: 87

                 * @param plusForSpace true if ASCII space should be escaped to {@code +} rather than {@code %20}
   * @throws IllegalArgumentException if any of the parameters were invalid
   */
  public PercentEscaper(String safeChars, boolean plusForSpace) {
    // TODO(dbeaumont): Switch to static factory methods for creation now that class is final.
    // TODO(dbeaumont): Support escapers where alphanumeric chars are not safe.
    checkNotNull(safeChars); // eager for GWT.
    // Avoid any misunderstandings about the behavior of this escaper
    if (safeChars.matches(".*[0-9A-Za-z].*")) {

            

Reported by PMD.

Avoid reassigning parameters such as 'index'
Design

Line: 130

                 * escaper from ~760ns to ~400ns as measured by {@link CharEscapersBenchmark}.
   */
  @Override
  protected int nextEscapeIndex(CharSequence csq, int index, int end) {
    checkNotNull(csq);
    for (; index < end; index++) {
      char c = csq.charAt(index);
      if (c >= safeOctets.length || !safeOctets[c]) {
        break;

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

guava/src/com/google/common/net/PercentEscaper.java
56 issues
Avoid reassigning parameters such as 'safeChars'
Design

Line: 87

                 * @param plusForSpace true if ASCII space should be escaped to {@code +} rather than {@code %20}
   * @throws IllegalArgumentException if any of the parameters were invalid
   */
  public PercentEscaper(String safeChars, boolean plusForSpace) {
    // TODO(dbeaumont): Switch to static factory methods for creation now that class is final.
    // TODO(dbeaumont): Support escapers where alphanumeric chars are not safe.
    checkNotNull(safeChars); // eager for GWT.
    // Avoid any misunderstandings about the behavior of this escaper
    if (safeChars.matches(".*[0-9A-Za-z].*")) {

            

Reported by PMD.

Avoid reassigning parameters such as 'index'
Design

Line: 130

                 * escaper from ~760ns to ~400ns as measured by {@link CharEscapersBenchmark}.
   */
  @Override
  protected int nextEscapeIndex(CharSequence csq, int index, int end) {
    checkNotNull(csq);
    for (; index < end; index++) {
      char c = csq.charAt(index);
      if (c >= safeOctets.length || !safeOctets[c]) {
        break;

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

Avoid reassigning parameters such as 'cp'
Design

Line: 161

                /** Escapes the given Unicode code point in UTF-8. */
  @Override
  @CheckForNull
  protected char[] escape(int cp) {
    // We should never get negative values here but if we do it will throw an
    // IndexOutOfBoundsException, so at least it will get spotted.
    if (cp < safeOctets.length && safeOctets[cp]) {
      return null;
    } else if (cp == ' ' && plusForSpace) {

            

Reported by PMD.

guava-testlib/src/com/google/common/collect/testing/google/BiMapPutTester.java
56 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 37

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapPutTester<K, V> extends AbstractBiMapTester<K, V> {

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {

            

Reported by PMD.

The String literal 'unchecked' appears 9 times in this file; the first occurrence is on line 37
Error

Line: 37

              @Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class BiMapPutTester<K, V> extends AbstractBiMapTester<K, V> {

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {

            

Reported by PMD.

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

Line: 41

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {
      getMap().put(k1(), v0());
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success

            

Reported by PMD.

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

Line: 43

                public void testPutWithSameValueFails() {
    getMap().put(k0(), v0());
    try {
      getMap().put(k1(), v0());
      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success
    }
    // verify that the bimap is unchanged

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 52

                  expectAdded(e0());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());

            

Reported by PMD.

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

Line: 56

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());
    // verify that the bimap is changed, and that the old inverse mapping
    // from v1 -> v0 is deleted
    expectContents(Helpers.mapEntry(k0(), v1()));
  }

            

Reported by PMD.

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

Line: 57

                @CollectionSize.Require(ZERO)
  public void testPutPresentKeyDifferentValue() {
    getMap().put(k0(), v0());
    getMap().put(k0(), v1());
    // verify that the bimap is changed, and that the old inverse mapping
    // from v1 -> v0 is deleted
    expectContents(Helpers.mapEntry(k0(), v1()));
  }


            

Reported by PMD.

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

Line: 67

                @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ZERO)
  public void putDistinctKeysDistinctValues() {
    getMap().put(k0(), v0());
    getMap().put(k1(), v1());
    expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")

            

Reported by PMD.

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

Line: 68

                @CollectionSize.Require(ZERO)
  public void putDistinctKeysDistinctValues() {
    getMap().put(k0(), v0());
    getMap().put(k1(), v1());
    expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 72

                  expectAdded(e0(), e1());
  }

  @SuppressWarnings("unchecked")
  @MapFeature.Require(SUPPORTS_PUT)
  @CollectionSize.Require(ONE)
  public void testForcePutKeyPresent() {
    getMap().forcePut(k0(), v1());
    expectContents(Helpers.mapEntry(k0(), v1()));

            

Reported by PMD.

guava-tests/test/com/google/common/util/concurrent/CallablesTest.java
55 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 38

              @GwtCompatible(emulated = true)
public class CallablesTest extends TestCase {

  public void testReturning() throws Exception {
    assertNull(Callables.returning(null).call());

    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());

            

Reported by PMD.

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

Line: 38

              @GwtCompatible(emulated = true)
public class CallablesTest extends TestCase {

  public void testReturning() throws Exception {
    assertNull(Callables.returning(null).call());

    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());

            

Reported by PMD.

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

Line: 39

              public class CallablesTest extends TestCase {

  public void testReturning() throws Exception {
    assertNull(Callables.returning(null).call());

    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

              public class CallablesTest extends TestCase {

  public void testReturning() throws Exception {
    assertNull(Callables.returning(null).call());

    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls

            

Reported by PMD.

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

Line: 43

              
    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls
    assertSame(value, callable.call());
  }

  @GwtIncompatible

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 43

              
    Object value = new Object();
    Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls
    assertSame(value, callable.call());
  }

  @GwtIncompatible

            

Reported by PMD.

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

Line: 45

                  Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls
    assertSame(value, callable.call());
  }

  @GwtIncompatible
  public void testAsAsyncCallable() throws Exception {
    final String expected = "MyCallableString";

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                  Callable<Object> callable = Callables.returning(value);
    assertSame(value, callable.call());
    // Expect the same value on subsequent calls
    assertSame(value, callable.call());
  }

  @GwtIncompatible
  public void testAsAsyncCallable() throws Exception {
    final String expected = "MyCallableString";

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 48

                  assertSame(value, callable.call());
  }

  @GwtIncompatible
  public void testAsAsyncCallable() throws Exception {
    final String expected = "MyCallableString";
    Callable<String> callable =
        new Callable<String>() {
          @Override

            

Reported by PMD.

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

Line: 62

                  AsyncCallable<String> asyncCallable =
        Callables.asAsyncCallable(callable, MoreExecutors.newDirectExecutorService());

    ListenableFuture<String> future = asyncCallable.call();
    assertSame(expected, future.get());
  }

  @GwtIncompatible
  public void testAsAsyncCallable_exception() throws Exception {

            

Reported by PMD.

guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
55 issues
JUnit 4 indicates test suites via annotations, not the suite method.
Design

Line: 43

               * @author Kevin Bourrillion
 */
public class ImmutableClassToInstanceMapTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableClassToInstanceMapTest.class);

    suite.addTest(
        MapTestSuiteBuilder.using(

            

Reported by PMD.

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

Line: 59

                                      ImmutableClassToInstanceMap.builder();
                    for (Object object : elements) {
                      Entry<Class, Impl> entry = (Entry<Class, Impl>) object;
                      builder.put(entry.getKey(), entry.getValue());
                    }
                    return (Map) builder.build();
                  }
                })
            .named("ImmutableClassToInstanceMap")

            

Reported by PMD.

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

Line: 59

                                      ImmutableClassToInstanceMap.builder();
                    for (Object object : elements) {
                      Entry<Class, Impl> entry = (Entry<Class, Impl>) object;
                      builder.put(entry.getKey(), entry.getValue());
                    }
                    return (Map) builder.build();
                  }
                })
            .named("ImmutableClassToInstanceMap")

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 77

                  return suite;
  }

  public void testSerialization_empty() {
    assertSame(
        ImmutableClassToInstanceMap.of(),
        SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
  }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 78

                }

  public void testSerialization_empty() {
    assertSame(
        ImmutableClassToInstanceMap.of(),
        SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
  }

  public void testCopyOf_map_empty() {

            

Reported by PMD.

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

Line: 83

                      SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
  }

  public void testCopyOf_map_empty() {
    Map<Class<?>, Object> in = Collections.emptyMap();
    ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
    assertTrue(map.isEmpty());
    assertSame(map, ImmutableClassToInstanceMap.of());
    assertSame(map, ImmutableClassToInstanceMap.copyOf(map));

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 83

                      SerializableTester.reserialize(ImmutableClassToInstanceMap.of()));
  }

  public void testCopyOf_map_empty() {
    Map<Class<?>, Object> in = Collections.emptyMap();
    ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
    assertTrue(map.isEmpty());
    assertSame(map, ImmutableClassToInstanceMap.of());
    assertSame(map, ImmutableClassToInstanceMap.copyOf(map));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 86

                public void testCopyOf_map_empty() {
    Map<Class<?>, Object> in = Collections.emptyMap();
    ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
    assertTrue(map.isEmpty());
    assertSame(map, ImmutableClassToInstanceMap.of());
    assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
  }

  public void testOf_zero() {

            

Reported by PMD.

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

Line: 86

                public void testCopyOf_map_empty() {
    Map<Class<?>, Object> in = Collections.emptyMap();
    ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
    assertTrue(map.isEmpty());
    assertSame(map, ImmutableClassToInstanceMap.of());
    assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
  }

  public void testOf_zero() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 87

                  Map<Class<?>, Object> in = Collections.emptyMap();
    ClassToInstanceMap<Object> map = ImmutableClassToInstanceMap.copyOf(in);
    assertTrue(map.isEmpty());
    assertSame(map, ImmutableClassToInstanceMap.of());
    assertSame(map, ImmutableClassToInstanceMap.copyOf(map));
  }

  public void testOf_zero() {
    assertTrue(ImmutableClassToInstanceMap.of().isEmpty());

            

Reported by PMD.

android/guava-tests/test/com/google/common/collect/MultisetsImmutableEntryTest.java
55 issues
Avoid using equals() to compare against null
Error

Line: 57

                  assertFalse(control("foo", 1).equals(entry("foo", 2)));
    assertFalse(entry("foo", 1).equals(control("bar", 1)));
    assertFalse(entry("foo", 1).equals(new Object()));
    assertFalse(entry("foo", 1).equals(null));
  }

  public void testEqualsNull() {
    assertEquals(control(NE, 1), entry(NE, 1));
    assertFalse(control(NE, 1).equals(entry(NE, 2)));

            

Reported by PMD.

Avoid using equals() to compare against null
Error

Line: 65

                  assertFalse(control(NE, 1).equals(entry(NE, 2)));
    assertFalse(entry(NE, 1).equals(control("bar", 1)));
    assertFalse(entry(NE, 1).equals(new Object()));
    assertFalse(entry(NE, 1).equals(null));
  }

  public void testHashCode() {
    assertEquals(control("foo", 1).hashCode(), entry("foo", 1).hashCode());
    assertEquals(control("bar", 2).hashCode(), entry("bar", 2).hashCode());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 41

                  return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {

            

Reported by PMD.

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

Line: 41

                  return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {

            

Reported by PMD.

The String literal 'foo' appears 12 times in this file; the first occurrence is on line 42
Error

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.

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

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.

guava-tests/test/com/google/common/collect/MultisetsImmutableEntryTest.java
55 issues
Avoid using equals() to compare against null
Error

Line: 57

                  assertFalse(control("foo", 1).equals(entry("foo", 2)));
    assertFalse(entry("foo", 1).equals(control("bar", 1)));
    assertFalse(entry("foo", 1).equals(new Object()));
    assertFalse(entry("foo", 1).equals(null));
  }

  public void testEqualsNull() {
    assertEquals(control(NE, 1), entry(NE, 1));
    assertFalse(control(NE, 1).equals(entry(NE, 2)));

            

Reported by PMD.

Avoid using equals() to compare against null
Error

Line: 65

                  assertFalse(control(NE, 1).equals(entry(NE, 2)));
    assertFalse(entry(NE, 1).equals(control("bar", 1)));
    assertFalse(entry(NE, 1).equals(new Object()));
    assertFalse(entry(NE, 1).equals(null));
  }

  public void testHashCode() {
    assertEquals(control("foo", 1).hashCode(), entry("foo", 1).hashCode());
    assertEquals(control("bar", 2).hashCode(), entry("bar", 2).hashCode());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

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

Line: 38

                }

  private static <E> Entry<E> control(E element, int count) {
    return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());

            

Reported by PMD.

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

Line: 41

                  return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 41

                  return HashMultiset.create(Collections.nCopies(count, element)).entrySet().iterator().next();
  }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {

            

Reported by PMD.

The String literal 'foo' appears 12 times in this file; the first occurrence is on line 42
Error

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.

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

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                }

  public void testToString() {
    assertEquals("foo", entry("foo", 1).toString());
    assertEquals("bar x 2", entry("bar", 2).toString());
  }

  public void testToStringNull() {
    assertEquals("null", entry(NE, 1).toString());

            

Reported by PMD.