Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sonar issue 2629 Logging arguments should not require evaluation #1086

Merged
merged 1 commit into from Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -212,7 +212,7 @@ public static void createValidationFiles(URLConnection resourceUrlConnection, Fi
if(size == -1) {
logger.warn("could not find expected file size for resource {}.", resourceUrlConnection.getURL());
} else {
logger.debug("Content-Length: " + size);
logger.debug("Content-Length: {}", size);
File sizeFile = new File(localDestination.getParentFile(), localDestination.getName() + SIZE_EXT);
try (PrintStream sizePrintStream = new PrintStream(sizeFile)) {
sizePrintStream.print(size);
Expand Down
Expand Up @@ -135,7 +135,7 @@ private void clusterIt() {
dendrogram = new LinkedPair[numItems-1];


logger.debug("Initial matrix: \n"+matrixToString());
logger.debug("Initial matrix: \n{}", matrixToString());


for (int m=0;m<numItems-1;m++) {
Expand Down Expand Up @@ -309,11 +309,11 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {
}
}

logger.debug("Within cutoff: "+dendrogram[i]);
logger.debug("Within cutoff: {}", dendrogram[i]);

} else {

logger.debug("Not within cutoff: "+dendrogram[i]);
logger.debug("Not within cutoff: {}", dendrogram[i]);

}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {

}

logger.debug("Clusters: \n"+clustersToString(finalClusters));
logger.debug("Clusters: \n{}", clustersToString(finalClusters));

return finalClusters;
}
Expand Down
Expand Up @@ -231,12 +231,12 @@ public static int getCDSLength(GeneChromosomePosition chromPos) {
*/
public static ChromPos getChromosomePosForCDScoordinate(int cdsNucleotidePosition, GeneChromosomePosition chromPos) {

logger.debug(" ? Checking chromosome position for CDS position " + cdsNucleotidePosition);
logger.debug(" ? Checking chromosome position for CDS position {}", cdsNucleotidePosition);

List<Integer> exonStarts = chromPos.getExonStarts();
List<Integer> exonEnds = chromPos.getExonEnds();

logger.debug(" Exons:" + exonStarts.size());
logger.debug(" Exons:{}", exonStarts.size());

int cdsStart = chromPos.getCdsStart();
int cdsEnd = chromPos.getCdsEnd();
Expand Down Expand Up @@ -378,7 +378,7 @@ public static ChromPos getChromPosReverse(int cdsPos, List<Integer> exonStarts,

if ( tmp > (end - start ) ) {
tmp = (end - start );
logger.debug("changing tmp to " + tmp);
logger.debug("changing tmp to {}", tmp);
}
logger.debug(" " + cdsPos + " " + codingLength + " | " + (cdsPos - codingLength) + " | " + (end -start) + " | " + tmp);
logger.debug(" Exon : " + format(start+1) + " - " + format(end) + " | " + format(end - start) + " | " + codingLength + " | " + (codingLength % 3));
Expand All @@ -397,7 +397,7 @@ public static ChromPos getChromPosReverse(int cdsPos, List<Integer> exonStarts,
logger.debug(" coding length: " + codingLength + "(phase:" + (codingLength % 3) + ") CDS POS trying to map:" + cdsPos);
}

logger.debug("length exons: " + lengthExons);
logger.debug("length exons: {}", lengthExons);
// could not map, or map over the full length??
return new ChromPos(-1,-1);

Expand Down Expand Up @@ -811,11 +811,11 @@ public static int getCDSPosForward(int chromPos, List<Integer> exonStarts, List<

// the genetic coordinate is not in a coding region
if ( (chromPos < (cdsStart+base) ) || ( chromPos > (cdsEnd+base) ) ) {
logger.debug("The "+format(chromPos)+" position is not in a coding region");
logger.debug("The {} position is not in a coding region", format(chromPos));
return -1;
}

logger.debug("looking for CDS position for " +format(chromPos));
logger.debug("looking for CDS position for {}", format(chromPos));

// map the genetic coordinates of coding region on a stretch of a reverse strand
List<Range<Integer>> cdsRegions = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);
Expand Down Expand Up @@ -858,11 +858,11 @@ public static int getCDSPosReverse(int chromPos, List<Integer> exonStarts, List<

// the genetic coordinate is not in a coding region
if ( (chromPos < (cdsStart+base)) || ( chromPos > (cdsEnd+base) ) ) {
logger.debug("The "+format(chromPos)+" position is not in a coding region");
logger.debug("The {} position is not in a coding region", format(chromPos));
return -1;
}

logger.debug("looking for CDS position for " +format(chromPos));
logger.debug("looking for CDS position for {}", format(chromPos));

// map the genetic coordinate on a stretch of a reverse strand
List<Range<Integer>> cdsRegions = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);
Expand Down
Expand Up @@ -597,14 +597,7 @@ public GroupType getPredominantGroupType(){
max = GroupType.HETATM;
}
}
logger.debug(
"Ratio of residues to total for chain with asym_id {} is below {}. Assuming it is a {} chain. "
+ "Counts: # aa residues: {}, # nuc residues: {}, # non-water het residues: {}, # waters: {}, "
+ "ratio aa/total: {}, ratio nuc/total: {}",
getId(), ratioResiduesToTotal, max, sizeAminos,
sizeNucleotides, sizeHetatomsWithoutWater, sizeWaters,
(double) sizeAminos / (double) fullSize,
(double) sizeNucleotides / (double) fullSize);
logger.debug("Ratio of residues to total for chain with asym_id {} is below {}. Assuming it is a {} chain. Counts: # aa residues: {}, # nuc residues: {}, # non-water het residues: {}, # waters: {}, ratio aa/total: {}, ratio nuc/total: {}{}{}{}{}", getId(), ratioResiduesToTotal, max, sizeAminos, sizeNucleotides, sizeHetatomsWithoutWater, sizeWaters, (double) sizeAminos, (double) fullSize, (double) sizeNucleotides, (double) fullSize);

return max;
}
Expand Down
Expand Up @@ -834,10 +834,7 @@ public static Atom[] getAtomArray(Chain c, String[] atomNames) {
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
logger.debug("Group " + g.getResidueNumber() + " ("
+ g.getPDBName()
+ ") does not have the required atom '" + atomName
+ "'");
logger.debug("Group {} ({}) does not have the required atom '{}'", g.getResidueNumber(), g.getPDBName(), atomName);
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
Expand Down
Expand Up @@ -407,8 +407,8 @@ public void align(Atom[] ca1, Atom[] ca2, StrucAligParameters params)

// step 1 get all Diagonals of length X that are similar between both
// structures
logger.debug(" length atoms1:" + ca1.length);
logger.debug(" length atoms2:" + ca2.length);
logger.debug(" length atoms1:{}", ca1.length);
logger.debug(" length atoms2:{}", ca2.length);

logger.debug("step 1 - get fragments with similar intramolecular distances ");

Expand Down
Expand Up @@ -375,10 +375,10 @@ public JointFragments[] frag_pairwise_compat(FragmentPair[] fraglst, int angleDi
List<JointFragments> fll = new ArrayList<JointFragments>();

double adiff = angleDiff * Math.PI / 180d;
logger.debug("addiff" + adiff);
logger.debug("addiff{}", adiff);
//distance between two unit vectors with angle adiff
double ddiff = Math.sqrt(2.0-2.0*Math.cos(adiff));
logger.debug("ddiff" + ddiff);
logger.debug("ddiff{}", ddiff);

// the fpairs in the flist have to be sorted with respect to their positions

Expand Down
Expand Up @@ -140,7 +140,7 @@ public AFPChain align(Atom[] ca1, Atom[] ca2, Object parameters)
throw new StructureException("Empty alignment for sequences "+s1+" and "+s2);
}

logger.debug("Smith-Waterman alignment is: "+pair.toString(100));
logger.debug("Smith-Waterman alignment is: {}", pair.toString(100));

// convert to a 3D alignment...
afpChain = convert(ca1,ca2,pair, smithWaterman);
Expand Down
Expand Up @@ -82,7 +82,7 @@ public static List<Subunit> extractSubunits(Structure structure,
// Calculate the minimum length of a Subunit
int adjustedMinLen = calcAdjustedMinimumSequenceLength(subunits,
absMinLen, fraction, minLen);
logger.debug("Adjusted minimum sequence length: " + adjustedMinLen);
logger.debug("Adjusted minimum sequence length: {}", adjustedMinLen);

// Filter out short Subunits
for (int s = subunits.size() - 1; s >= 0; s--) {
Expand Down
Expand Up @@ -468,13 +468,13 @@ public String toString() {
public static StructureInterfaceList calculateInterfaces(Structure struc) {
CrystalBuilder builder = new CrystalBuilder(struc);
StructureInterfaceList interfaces = builder.getUniqueInterfaces();
logger.debug("Calculating ASA for "+interfaces.size()+" potential interfaces");
logger.debug("Calculating ASA for {} potential interfaces", interfaces.size());
interfaces.calcAsas(StructureInterfaceList.DEFAULT_ASA_SPHERE_POINTS, //fewer for performance
Runtime.getRuntime().availableProcessors(),
StructureInterfaceList.DEFAULT_MIN_COFACTOR_SIZE);
interfaces.removeInterfacesBelowArea();
interfaces.getClusters();
logger.debug("Found "+interfaces.size()+" interfaces");
logger.debug("Found {} interfaces", interfaces.size());
return interfaces;
}

Expand Down
Expand Up @@ -127,7 +127,7 @@ public Map<K,V> reloadFromFile() {

try{

logger.debug("Reloading from cache " + f.getAbsolutePath());
logger.debug("Reloading from cache {}", f.getAbsolutePath());

FileInputStream fis = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fis);
Expand Down
Expand Up @@ -261,13 +261,13 @@ private void calcRmsd(Point3d[] x, Point3d[] y) {
// translate to origin
xref = CalcPoint.clonePoint3dArray(x);
xtrans = CalcPoint.centroid(xref);
logger.debug("x centroid: " + xtrans);
logger.debug("x centroid: {}", xtrans);
xtrans.negate();
CalcPoint.translate(new Vector3d(xtrans), xref);

yref = CalcPoint.clonePoint3dArray(y);
ytrans = CalcPoint.centroid(yref);
logger.debug("y centroid: " + ytrans);
logger.debug("y centroid: {}", ytrans);
ytrans.negate();
CalcPoint.translate(new Vector3d(ytrans), yref);
innerProduct(yref, xref);
Expand Down
Expand Up @@ -297,7 +297,7 @@ private static TreeMap<String,EntityInfo> findEntitiesFromAlignment(List<List<Ch

logger.debug("Alignment for chain pair {},{}: identity: {}, gap coverage 1: {}, gap coverage 2: {}",
c1.getId(), c2.getId(), String.format("%4.2f",identity), String.format("%4.2f",gapCov1), String.format("%4.2f",gapCov2));
logger.debug("\n"+pair.toString(100));
logger.debug("\n{}", pair.toString(100));

if (identity > IDENTITY_THRESHOLD && gapCov1<GAP_COVERAGE_THRESHOLD && gapCov2<GAP_COVERAGE_THRESHOLD) {
if ( !chainIds2entities.containsKey(c1.getId()) &&
Expand Down
Expand Up @@ -436,7 +436,7 @@ public boolean deleteStructure(PdbId pdbId) throws IOException{
// delete file
boolean success = existing.delete();
if(success) {
logger.debug("Deleting "+existing.getAbsolutePath());
logger.debug("Deleting {}", existing.getAbsolutePath());
}
deleted = deleted || success;

Expand All @@ -445,7 +445,7 @@ public boolean deleteStructure(PdbId pdbId) throws IOException{
if(parent != null) {
success = parent.delete();
if(success) {
logger.debug("Deleting "+parent.getAbsolutePath());
logger.debug("Deleting {}", parent.getAbsolutePath());
}
}

Expand Down