Skip to content

Commit 1ac29b3

Browse files
committed
fix sonar issue 2629 Logging arguments should not require evaluation
1 parent 874ce88 commit 1ac29b3

File tree

24 files changed

+100
-125
lines changed

24 files changed

+100
-125
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/util/FileDownloadUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static void createValidationFiles(URLConnection resourceUrlConnection, Fi
212212
if(size == -1) {
213213
logger.warn("could not find expected file size for resource {}.", resourceUrlConnection.getURL());
214214
} else {
215-
logger.debug("Content-Length: " + size);
215+
logger.debug("Content-Length: {}", size);
216216
File sizeFile = new File(localDestination.getParentFile(), localDestination.getName() + SIZE_EXT);
217217
try (PrintStream sizePrintStream = new PrintStream(sizeFile)) {
218218
sizePrintStream.print(size);

biojava-core/src/main/java/org/biojava/nbio/core/util/SingleLinkageClusterer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private void clusterIt() {
135135
dendrogram = new LinkedPair[numItems-1];
136136

137137

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

140140

141141
for (int m=0;m<numItems-1;m++) {
@@ -309,11 +309,11 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {
309309
}
310310
}
311311

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

314314
} else {
315315

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

318318
}
319319
}
@@ -344,7 +344,7 @@ public Map<Integer, Set<Integer>> getClusters(double cutoff) {
344344

345345
}
346346

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

349349
return finalClusters;
350350
}

biojava-genome/src/main/java/org/biojava/nbio/genome/util/ChromosomeMappingTools.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ public static int getCDSLength(GeneChromosomePosition chromPos) {
231231
*/
232232
public static ChromPos getChromosomePosForCDScoordinate(int cdsNucleotidePosition, GeneChromosomePosition chromPos) {
233233

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

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

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

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

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

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

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

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

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

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

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

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

867867
// map the genetic coordinate on a stretch of a reverse strand
868868
List<Range<Integer>> cdsRegions = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);

biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,7 @@ public GroupType getPredominantGroupType(){
597597
max = GroupType.HETATM;
598598
}
599599
}
600-
logger.debug(
601-
"Ratio of residues to total for chain with asym_id {} is below {}. Assuming it is a {} chain. "
602-
+ "Counts: # aa residues: {}, # nuc residues: {}, # non-water het residues: {}, # waters: {}, "
603-
+ "ratio aa/total: {}, ratio nuc/total: {}",
604-
getId(), ratioResiduesToTotal, max, sizeAminos,
605-
sizeNucleotides, sizeHetatomsWithoutWater, sizeWaters,
606-
(double) sizeAminos / (double) fullSize,
607-
(double) sizeNucleotides / (double) fullSize);
600+
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);
608601

609602
return max;
610603
}

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,7 @@ public static Atom[] getAtomArray(Chain c, String[] atomNames) {
834834
for (String atomName : atomNames) {
835835
Atom a = g.getAtom(atomName);
836836
if (a == null) {
837-
logger.debug("Group " + g.getResidueNumber() + " ("
838-
+ g.getPDBName()
839-
+ ") does not have the required atom '" + atomName
840-
+ "'");
837+
logger.debug("Group {} ({}) does not have the required atom '{}'", g.getResidueNumber(), g.getPDBName(), atomName);
841838
// this group does not have a required atom, skip it...
842839
thisGroupAllAtoms = false;
843840
break;

biojava-structure/src/main/java/org/biojava/nbio/structure/align/StructurePairAligner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ public void align(Atom[] ca1, Atom[] ca2, StrucAligParameters params)
407407

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

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

biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/FragmentJoiner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ public JointFragments[] frag_pairwise_compat(FragmentPair[] fraglst, int angleDi
375375
List<JointFragments> fll = new ArrayList<JointFragments>();
376376

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

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

biojava-structure/src/main/java/org/biojava/nbio/structure/align/seq/SmithWaterman3Daligner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public AFPChain align(Atom[] ca1, Atom[] ca2, Object parameters)
140140
throw new StructureException("Empty alignment for sequences "+s1+" and "+s2);
141141
}
142142

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

145145
// convert to a 3D alignment...
146146
afpChain = convert(ca1,ca2,pair, smithWaterman);

biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/SubunitExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static List<Subunit> extractSubunits(Structure structure,
8282
// Calculate the minimum length of a Subunit
8383
int adjustedMinLen = calcAdjustedMinimumSequenceLength(subunits,
8484
absMinLen, fraction, minLen);
85-
logger.debug("Adjusted minimum sequence length: " + adjustedMinLen);
85+
logger.debug("Adjusted minimum sequence length: {}", adjustedMinLen);
8686

8787
// Filter out short Subunits
8888
for (int s = subunits.size() - 1; s >= 0; s--) {

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,13 @@ public String toString() {
468468
public static StructureInterfaceList calculateInterfaces(Structure struc) {
469469
CrystalBuilder builder = new CrystalBuilder(struc);
470470
StructureInterfaceList interfaces = builder.getUniqueInterfaces();
471-
logger.debug("Calculating ASA for "+interfaces.size()+" potential interfaces");
471+
logger.debug("Calculating ASA for {} potential interfaces", interfaces.size());
472472
interfaces.calcAsas(StructureInterfaceList.DEFAULT_ASA_SPHERE_POINTS, //fewer for performance
473473
Runtime.getRuntime().availableProcessors(),
474474
StructureInterfaceList.DEFAULT_MIN_COFACTOR_SIZE);
475475
interfaces.removeInterfacesBelowArea();
476476
interfaces.getClusters();
477-
logger.debug("Found "+interfaces.size()+" interfaces");
477+
logger.debug("Found {} interfaces", interfaces.size());
478478
return interfaces;
479479
}
480480

0 commit comments

Comments
 (0)