Skip to content

Commit

Permalink
Fix fields that should be final, as reported by SpotBugs (#1268)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite authored and lbergelson committed Feb 11, 2019
1 parent 52169ed commit 77b3b8f
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/main/java/htsjdk/samtools/SAMRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ public class SAMRecord implements Cloneable, Locatable, Serializable {
* Tags that are known to need the reverse complement if the read is reverse complemented.
*/
@SuppressWarnings("deprecated")
public static List<String> TAGS_TO_REVERSE_COMPLEMENT = Arrays.asList(SAMTag.E2.name(), SAMTag.SQ.name());
public static final List<String> TAGS_TO_REVERSE_COMPLEMENT = Arrays.asList(SAMTag.E2.name(), SAMTag.SQ.name());

/**
* Tags that are known to need the reverse if the read is reverse complemented.
*/
public static List<String> TAGS_TO_REVERSE = Arrays.asList(SAMTag.OQ.name(), SAMTag.U2.name());
public static final List<String> TAGS_TO_REVERSE = Arrays.asList(SAMTag.OQ.name(), SAMTag.U2.name());

private String mReadName = null;
private byte[] mReadBases = NULL_SEQUENCE;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/SamReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ void applyTo(final SRAFileReader underlyingReader, final SamReader reader) {

};

public static EnumSet<Option> DEFAULTS = EnumSet.noneOf(Option.class);
public static final EnumSet<Option> DEFAULTS = EnumSet.noneOf(Option.class);

/** Applies this option to the provided reader, if applicable. */
void applyTo(final SamReader.PrimitiveSamReaderToSamReaderAdapter reader) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/cram/CRAIEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public int compare(final CRAIEntry o1, final CRAIEntry o2) {
}
};

public static Comparator<CRAIEntry> byStartDesc = new Comparator<CRAIEntry>() {
public static final Comparator<CRAIEntry> byStartDesc = new Comparator<CRAIEntry>() {

@Override
public int compare(CRAIEntry o1, CRAIEntry o2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

Expand All @@ -51,7 +52,7 @@
* @author Tim Fennell
*/
public class ReferenceSequenceFileFactory {
public static final Set<String> FASTA_EXTENSIONS = new HashSet<String>() {{
public static final Set<String> FASTA_EXTENSIONS = Collections.unmodifiableSet(new HashSet<String>() {{
add(".fasta");
add(".fasta.gz");
add(".fa");
Expand All @@ -60,7 +61,7 @@ public class ReferenceSequenceFileFactory {
add(".fna.gz");
add(".txt");
add(".txt.gz");
}};
}});

public static final String FASTA_INDEX_EXTENSION = ".fai";

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class TestUtil {

public static int RANDOM_SEED = 42;
public static final int RANDOM_SEED = 42;


/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/htsjdk/samtools/util/ftp/FTPClient.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* Copyright (c) 2007-2011 by The Broad Institute of MIT and Harvard. All Rights Reserved.
*
Expand Down Expand Up @@ -38,7 +39,7 @@ public class FTPClient {

private Socket commandSocket = null;

public static int READ_TIMEOUT = 5 * 60 * 1000;
public static final int READ_TIMEOUT = 5 * 60 * 1000;

/**
* Stream to write commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public class IntervalIndexCreator extends TribbleIndexCreator {

public static int DEFAULT_FEATURE_COUNT = 600;
public static final int DEFAULT_FEATURE_COUNT = 600;

/**
* Maximum number of features stored per interval.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @author jrobinso
*/
public class LinearIndexCreator extends TribbleIndexCreator {
public static int DEFAULT_BIN_WIDTH = 8000;
public static final int DEFAULT_BIN_WIDTH = 8000;
// the set bin width
private int binWidth = DEFAULT_BIN_WIDTH;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/htsjdk/tribble/index/tabix/TabixFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class TabixFormat implements Cloneable {
public static final int UCSC_FLAGS = GENERIC_FLAGS | ZERO_BASED;

/** Predefined headers for known formats */
public static TabixFormat GFF = new TabixFormat(GENERIC_FLAGS, 1, 4, 5, '#', 0);
public static TabixFormat BED = new TabixFormat(UCSC_FLAGS, 1, 2, 3, '#', 0);
public static TabixFormat PSLTBL = new TabixFormat(UCSC_FLAGS, 15, 17, 18, '#', 0);
public static TabixFormat SAM = new TabixFormat(SAM_FLAGS, 3, 4, 0, '@', 0);
public static TabixFormat VCF = new TabixFormat(VCF_FLAGS, 1, 2, 0, '#', 0);
public static final TabixFormat GFF = new TabixFormat(GENERIC_FLAGS, 1, 4, 5, '#', 0);
public static final TabixFormat BED = new TabixFormat(UCSC_FLAGS, 1, 2, 3, '#', 0);
public static final TabixFormat PSLTBL = new TabixFormat(UCSC_FLAGS, 15, 17, 18, '#', 0);
public static final TabixFormat SAM = new TabixFormat(SAM_FLAGS, 3, 4, 0, '@', 0);
public static final TabixFormat VCF = new TabixFormat(VCF_FLAGS, 1, 2, 0, '#', 0);

/** Describes interpretation of file being indexed. See FLAGS constants above. */
public int flags;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/tribble/util/ParsingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
public class ParsingUtils {

public static Map<Object, Color> colorCache = new WeakHashMap<>(100);
public static final Map<Object, Color> colorCache = new WeakHashMap<>(100);

// HTML 4.1 color table, + orange and magenta
static Map<String, String> colorSymbols = new HashMap();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/htsjdk/tribble/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* Date: 2012-Dec-13
*/
public class TestUtils {
public static String DATA_DIR = "src/test/resources/htsjdk/tribble/";
public static final String DATA_DIR = "src/test/resources/htsjdk/tribble/";

/**
* A utility method for copying a tribble file (and possibly its index) into a Jimfs-like FileSystem
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/htsjdk/variant/vcf/VCFHeaderUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,9 @@ private void checkMD5ofHeaderFile(VCFHeader header, String md5sum) {
Assert.assertEquals(md5SumFile(myTempFile), md5sum);
}

public static int VCF4headerStringCount = 16;
public static final int VCF4headerStringCount = 16;

public static String VCF4headerStrings =
public static final String VCF4headerStrings =
"##fileformat=VCFv4.2\n" +
"##filedate=2010-06-21\n" +
"##reference=NCBI36\n" +
Expand All @@ -618,7 +618,7 @@ private void checkMD5ofHeaderFile(VCFHeader header, String md5sum) {
"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n";


public static String VCF4headerStrings_with_negativeOne =
public static final String VCF4headerStrings_with_negativeOne =
"##fileformat=VCFv4.2\n" +
"##filedate=2010-06-21\n" +
"##reference=NCBI36\n" +
Expand Down

0 comments on commit 77b3b8f

Please sign in to comment.