diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/UndocumentedApiCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/UndocumentedApiCheck.java index a672496ede..5d13fa8298 100644 --- a/cxx-checks/src/main/java/org/sonar/cxx/checks/UndocumentedApiCheck.java +++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/UndocumentedApiCheck.java @@ -87,9 +87,8 @@ public UndocumentedApiCheck() { protected void onPublicApi(AstNode node, String id, List comments) { boolean commented = !comments.isEmpty(); - LOG.debug("node: " + node.getType() + " line: " + node.getTokenLine() - + " id: '" + id + "' documented: " + commented); - + LOG.debug("node: {} line: {} id: '{}' documented: {}", + new Object[]{node.getType(), node.getTokenLine(), id, commented}); if (!commented) { getContext().createLineViolation(this, "Undocumented API: " + id, node); diff --git a/cxx-squid/src/main/java/org/sonar/cxx/CxxConfiguration.java b/cxx-squid/src/main/java/org/sonar/cxx/CxxConfiguration.java index 8587af6bf5..6c6c4892d8 100644 --- a/cxx-squid/src/main/java/org/sonar/cxx/CxxConfiguration.java +++ b/cxx-squid/src/main/java/org/sonar/cxx/CxxConfiguration.java @@ -231,7 +231,9 @@ public void setCompilationPropertiesWithBuildLog(List reports, for(File buildLog : reports) { if (buildLog.exists()) { - LOG.debug("Parse build log file '{}'", buildLog.getAbsolutePath()); + if (LOG.isDebugEnabled()) { + LOG.debug("Parse build log file '{}'", buildLog.getAbsolutePath()); + } if (fileFormat.equals("Visual C++")) { cxxVCppParser.parseVCppLog(buildLog, baseDir, charsetName); } diff --git a/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java b/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java index c1be841a23..8debdf94ea 100644 --- a/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java +++ b/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java @@ -413,7 +413,7 @@ PreprocessorAction handleIfLine(AstNode ast, Token token, String filename) { } catch (EvaluationException e) { LOG.error("[{}:{}]: error evaluating the expression {} assume 'true' ...", new Object[] {filename, token.getLine(), token.getValue()}); - LOG.error(e.toString()); + LOG.error("{}", e); state.skipping = false; } @@ -443,7 +443,7 @@ PreprocessorAction handleElIfLine(AstNode ast, Token token, String filename) { } catch (EvaluationException e) { LOG.error("[{}:{}]: error evaluating the expression {} assume 'true' ...", new Object[] {filename, token.getLine(), token.getValue()}); - LOG.error(e.toString()); + LOG.error("{}", e); state.skipping = false; } @@ -695,7 +695,7 @@ private int matchArguments(List tokens, List arguments) { rest = match(rest, ")"); } catch (MismatchException me) { - LOG.error(me.toString()); + LOG.error("{}", me); return 0; } diff --git a/cxx-squid/src/main/java/org/sonar/cxx/visitors/AbstractCxxPublicApiVisitor.java b/cxx-squid/src/main/java/org/sonar/cxx/visitors/AbstractCxxPublicApiVisitor.java index 19fb9da62d..ef121cd319 100644 --- a/cxx-squid/src/main/java/org/sonar/cxx/visitors/AbstractCxxPublicApiVisitor.java +++ b/cxx-squid/src/main/java/org/sonar/cxx/visitors/AbstractCxxPublicApiVisitor.java @@ -159,7 +159,7 @@ public void visitNode(AstNode astNode) { break; default: // should not happen - LOG.error("Visiting unknown node: " + astNode.getType()); + LOG.error("Visiting unknown node: {}", astNode.getType()); break; } } @@ -289,7 +289,7 @@ private void visitDeclarator(AstNode declarator, AstNode docNode) { .getFirstDescendant(CxxGrammarImpl.declaratorId); if (declaratorId == null) { - LOG.error("null declaratorId: " + AstXmlPrinter.print(declarator)); + LOG.error("null declaratorId: {}", AstXmlPrinter.print(declarator)); } else { visitPublicApi(declaratorId, declaratorId.getTokenValue(), comments); } @@ -473,7 +473,7 @@ private void visitMemberDeclarator(AstNode node) { id = idNode.getTokenValue(); } else { - LOG.error("Unsupported declarator at " + node.getTokenLine()); + LOG.error("Unsupported declarator at {}", node.getTokenLine()); } } } @@ -491,7 +491,7 @@ private void visitAliasDeclaration(AstNode aliasDeclNode) { .getFirstDescendant(GenericTokenType.IDENTIFIER); if (aliasDeclIdNode == null) { - LOG.error("No identifier found at " + aliasDeclNode.getTokenLine()); + LOG.error("No identifier found at {}", aliasDeclNode.getTokenLine()); } else { // look for block documentation @@ -641,14 +641,11 @@ private static boolean isPublicApiMember(AstNode node) { // default access in classes is private return false; default: - LOG.error("isPublicApiMember unhandled case: " - + enclosingSpecifierNode.getType() - + " at " + enclosingSpecifierNode.getTokenLine()); + LOG.error("isPublicApiMember unhandled case: {} at {}", enclosingSpecifierNode.getType(), enclosingSpecifierNode.getTokenLine()); return false; } } else { - LOG.error("isPublicApiMember: failed to get enclosing " - + "classSpecifier for node at " + node.getTokenLine()); + LOG.error("isPublicApiMember: failed to get enclosing classSpecifier for node at {}", node.getTokenLine()); return false; } } diff --git a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java index f8988d089d..818fe236f3 100644 --- a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java +++ b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java @@ -46,7 +46,8 @@ public void init() { public void visitNode(AstNode node) { AstNode identifierAst = node.getFirstChild(GenericTokenType.IDENTIFIER); if( identifierAst != null ) { - CxxGrammarImpl.LOG.warn("[{}:{}]: syntax error, skip '{}'", new Object[] {context.getFile(), node.getToken().getLine(), identifierAst.getTokenValue()}); + CxxGrammarImpl.LOG.warn("[{}:{}]: syntax error, skip '{}'", + new Object[] {context.getFile(), node.getToken().getLine(), identifierAst.getTokenValue()}); } } diff --git a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxPublicApiVisitor.java b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxPublicApiVisitor.java index 6f1f6e1429..1c15811550 100644 --- a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxPublicApiVisitor.java +++ b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxPublicApiVisitor.java @@ -86,8 +86,8 @@ public CxxPublicApiVisitor(MetricDef publicDocumentedApi, protected void onPublicApi(AstNode node, String id, List comments) { boolean commented = !comments.isEmpty(); - LOG.debug("node: " + node.getType() + " line: " + node.getTokenLine() - + " id: '" + id + "' documented: " + commented); + LOG.debug("node: {} line: {} id: '{}' documented: {}", + new Object[]{node.getType(), node.getTokenLine(), id, commented}); if (handler != null) { handler.onPublicApi(node, id, comments); diff --git a/cxx-squid/src/test/java/org/sonar/cxx/CxxPublicApiVisitorTest.java b/cxx-squid/src/test/java/org/sonar/cxx/CxxPublicApiVisitorTest.java index 59096112d7..ccebfc61c7 100644 --- a/cxx-squid/src/test/java/org/sonar/cxx/CxxPublicApiVisitorTest.java +++ b/cxx-squid/src/test/java/org/sonar/cxx/CxxPublicApiVisitorTest.java @@ -94,8 +94,10 @@ public void onPublicApi(AstNode node, String id, SourceFile file = CxxAstScanner.scanSingleFile(new File(fileName), visitor); - LOG.debug("#API: " + file.getInt(CxxMetric.PUBLIC_API) + " UNDOC: " - + file.getInt(CxxMetric.PUBLIC_UNDOCUMENTED_API)); + if (LOG.isDebugEnabled()) { + LOG.debug("#API: {} UNDOC: {}", + file.getInt(CxxMetric.PUBLIC_API), file.getInt(CxxMetric.PUBLIC_UNDOCUMENTED_API)); + } assertThat(file.getInt(CxxMetric.PUBLIC_API)).isEqualTo(expectedApi); assertThat(file.getInt(CxxMetric.PUBLIC_UNDOCUMENTED_API)).isEqualTo( @@ -170,8 +172,10 @@ public void onPublicApi(AstNode node, String id, SourceFile file = CxxAstScanner.scanSingleFile(new File( "src/test/resources/metrics/public_api.h"), visitor); // - LOG.debug("DOC: " + file.getInt(CxxMetric.PUBLIC_API) + " UNDOC: " - + file.getInt(CxxMetric.PUBLIC_UNDOCUMENTED_API)); + if (LOG.isDebugEnabled()) { + LOG.debug("DOC: {} UNDOC: {}", + file.getInt(CxxMetric.PUBLIC_API),file.getInt(CxxMetric.PUBLIC_UNDOCUMENTED_API)); + } final Map expectedIdCommentMap = new HashMap(); @@ -226,7 +230,7 @@ public void onPublicApi(AstNode node, String id, // check completeness for (final String id : expectedIdCommentMap.keySet()) { - LOG.debug("id: " + id); + LOG.debug("id: {}", id); List comments = idCommentMap.get(id); @@ -243,7 +247,7 @@ public void onPublicApi(AstNode node, String id, // check correction for (final String id : idCommentMap.keySet()) { - LOG.debug("id: " + id); + LOG.debug("id: {}", id); List comments = idCommentMap.get(id); diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java index bfa57594f7..1cde04ebab 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java @@ -78,7 +78,7 @@ public void processReport(final Project project, final SensorContext context, Fi Scanner scanner = new Scanner(report, charset); Pattern p = Pattern.compile(reportRegEx, Pattern.MULTILINE); - CxxUtils.LOG.debug("Using pattern : '" + p.toString() + "'"); + CxxUtils.LOG.debug("Using pattern : '{}'", p); MatchResult matchres = null; while (scanner.findWithinHorizon(p, 0) != null) { matchres = scanner.match(); @@ -86,7 +86,8 @@ public void processReport(final Project project, final SensorContext context, Fi String line = matchres.group(2); String msg = matchres.group(3); String id = matchres.group(4).replaceAll("=$", ""); - CxxUtils.LOG.debug("Scanner-matches file='" + filename + "' line='" + line + "' id='" + id + "' msg=" + msg); + CxxUtils.LOG.debug("Scanner-matches file='{}' line='{}' id='{}' msg={}", + new Object[]{filename, line, id, msg}); warnings.add(new Warning(filename, line, id, msg)); } scanner.close(); diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java index e6467178d9..f58c3434cc 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java @@ -120,7 +120,8 @@ protected void processReport(final Project project, final SensorContext context, final List warnings = new LinkedList(); // Iterate through the lines of the input file - CxxUtils.LOG.info("Scanner '" + parser.key() + "' initialized with report '{}'" + ", CharSet= '" + reportCharset + "'", report); + CxxUtils.LOG.info("Scanner '{}' initialized with report '{}', CharSet= '{}'", + new Object[]{parser.key(), report, reportCharset}); try { parser.processReport(project, context, report, reportCharset, reportRegEx, warnings); for(CompilerParser.Warning w : warnings) { @@ -132,9 +133,9 @@ protected void processReport(final Project project, final SensorContext context, } } } catch (java.io.FileNotFoundException e) { - CxxUtils.LOG.error("processReport Exception: " + "report.getName" + " - not processed '{}'", e.toString()); + CxxUtils.LOG.error("processReport Exception: {} - not processed '{}'", report, e); } catch (java.lang.IllegalArgumentException e1) { - CxxUtils.LOG.error("processReport Exception: " + "report.getName" + " - not processed '{}'", e1.toString()); + CxxUtils.LOG.error("processReport Exception: {} - not processed '{}'", report, e1); } } diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java index c6d6651003..f2be6b8343 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java @@ -78,7 +78,7 @@ public void processReport(final Project project, final SensorContext context, Fi Scanner scanner = new Scanner(report, charset); Pattern p = Pattern.compile(reportRegEx, Pattern.MULTILINE); - CxxUtils.LOG.info("Using pattern : '" + p.toString() + "'"); + CxxUtils.LOG.info("Using pattern : '{}'", p); MatchResult matchres = null; while (scanner.findWithinHorizon(p, 0) != null) { matchres = scanner.match(); @@ -86,7 +86,8 @@ public void processReport(final Project project, final SensorContext context, Fi String line = matchres.group(2); String id = matchres.group(3); String msg = matchres.group(4); - CxxUtils.LOG.debug("Scanner-matches file='" + filename + "' line='" + line + "' id='" + id + "' msg=" + msg); + CxxUtils.LOG.debug("Scanner-matches file='{}' line='{}' id='{}' msg={}", + new Object[]{filename, line, id, msg}); warnings.add(new Warning(filename, line, id, msg)); } scanner.close(); diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java index 3b493d6fde..ccb109c014 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java @@ -57,7 +57,7 @@ public void define(Context context) { try { xmlRuleLoader.load(repository, new StringReader(ruleDefs)); } catch (Exception ex) { - CxxUtils.LOG.info("Cannot load rules XML '{}'", ex.getMessage()); + CxxUtils.LOG.info("Cannot load rules XML '{}'", ex); } } } @@ -68,7 +68,7 @@ public void define(Context context) { try { CxxSqaleXmlLoader.load(repository, new StringReader(sqaleDefs)); } catch (Exception ex) { - CxxUtils.LOG.info("Cannot load SQALE XML '{}'", ex.getMessage()); + CxxUtils.LOG.info("Cannot load SQALE XML '{}'", ex); } } } diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java index 4f57344c31..8ce453473e 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java @@ -110,14 +110,14 @@ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { file, line, id, msg); } else { CxxUtils.LOG.warn("PC-lint warning ignored: {}", msg); - CxxUtils.LOG.debug("File: " + file + ", Line: " + line + ", ID: " - + id + ", msg: " + msg); + CxxUtils.LOG.debug("File: {}, Line: {}, ID: {}, msg: {}", + new Object[]{file, line, id, msg}); } } } catch (com.ctc.wstx.exc.WstxUnexpectedCharException e) { - CxxUtils.LOG.error("Ignore XML error from PC-lint '{}'", e.toString()); + CxxUtils.LOG.error("Ignore XML error from PC-lint '{}'", e); } catch (com.ctc.wstx.exc.WstxEOFException e) { - CxxUtils.LOG.error("Ignore XML error from PC-lint '{}'", e.toString()); + CxxUtils.LOG.error("Ignore XML error from PC-lint '{}'", e); } } @@ -142,8 +142,7 @@ private String mapMisraRulesToUniqueSonarRules(String msg) { if (matcher.find()) { String misraRule = matcher.group(1); String newKey = "M" + misraRule; - String debugText = "Remap MISRA rule " + misraRule + " to key " + newKey; - CxxUtils.LOG.debug(debugText); + CxxUtils.LOG.debug("Remap MISRA rule {} to key {}", misraRule, newKey); return newKey; } return ""; diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java index a1e4656eb3..82ea3baf46 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java @@ -98,7 +98,7 @@ protected void processReport(final Project project, final SensorContext context, } } catch (org.jdom.input.JDOMParseException e) { // when RATS fails the XML file might be incomplete - CxxUtils.LOG.error("Ignore incomplete XML output from RATS '{}'", e.toString()); + CxxUtils.LOG.error("Ignore incomplete XML output from RATS '{}'", e); } } diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java index 352083652e..a4bd061297 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java @@ -104,11 +104,11 @@ public void addFile(InputFile inputFile, Collection inc if (issuable.addIssue(issue)) violationsCount++; } else { - CxxUtils.LOG.warn("Already created edge from '" + sonarFile.getKey() + "' (line " + include.getLine() + ") to '" + includedFilePath + "'" + - ", previous edge from line " + prevIncludeLine); + CxxUtils.LOG.warn("Already created edge from '{}' (line {} to '{}', previous edge from line {}", + new Object[]{sonarFile.getKey(), include.getLine(), includedFilePath, prevIncludeLine}); } } else if (includedFile == null) { - CxxUtils.LOG.warn("Unable to find resource '" + include.getPath() + "' to create a dependency with '" + sonarFile.getKey() + "'"); + CxxUtils.LOG.warn("Unable to find resource '{}' to create a dependency with '{}'", include.getPath(), sonarFile.getKey()); } else if (context.isIndexed(includedFile, false)) { //Add the dependency in the files graph FileEdge fileEdge = new FileEdge(sonarFile, includedFile, include.getLine()); @@ -125,7 +125,9 @@ public void addFile(InputFile inputFile, Collection inc edge.addRootEdge(fileEdge); } } else { - CxxUtils.LOG.debug("Skipping dependency to file '{}', because it is'nt part of this project", includedFile.getName()); + if (CxxUtils.LOG.isDebugEnabled()) { + CxxUtils.LOG.debug("Skipping dependency to file '{}', because it is'nt part of this project", includedFile.getName()); + } } } } @@ -158,11 +160,8 @@ public void save() { Set feedbackEdges = cycleDetector.getFeedbackEdgeSet(); int tangles = cycleDetector.getWeightOfFeedbackEdgeSet(); - CxxUtils.LOG.info("Project '" + project.getKey() + "'" - + " Cycles:" + cycles.size() - + " Feedback cycles:" + feedbackEdges.size() - + " Tangles:" + tangles - + " Weight:" + getEdgesWeight(packagesGraph.getEdges(packages))); + CxxUtils.LOG.info("Project '{}' Cycles:{} Feedback cycles:{} Tangles:{} Weight:{}", + new Object[]{project.getKey(), cycles.size(), feedbackEdges.size(), tangles, getEdgesWeight(packagesGraph.getEdges(packages))}); saveViolations(feedbackEdges, packagesGraph); savePositiveMeasure(project, CoreMetrics.PACKAGE_CYCLES, cycles.size()); @@ -190,12 +189,9 @@ private void saveDirectory(Directory dir) { Set feedbackEdges = solver.getEdges(); int tangles = solver.getWeightOfFeedbackEdgeSet(); - CxxUtils.LOG.info("Directory: '" + dir.getKey() + "'" - + " Cycles:" + cycles.size() - + " Feedback cycles:" + feedbackEdges.size() - + " Tangles:" + tangles - + " Weight:" + getEdgesWeight(filesGraph.getEdges(files))); - + CxxUtils.LOG.info("Directory: '{}' Cycles:{} Feedback cycles:{} Tangles:{} Weight:{}", + new Object[]{dir.getKey(), cycles.size(), feedbackEdges.size(), tangles, getEdgesWeight(filesGraph.getEdges(files))}); + savePositiveMeasure(dir, CoreMetrics.FILE_CYCLES, cycles.size()); savePositiveMeasure(dir, CoreMetrics.FILE_FEEDBACK_EDGES, feedbackEdges.size()); savePositiveMeasure(dir, CoreMetrics.FILE_TANGLES, tangles); diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java index 1e29e38df8..6058e3c8bb 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java @@ -70,7 +70,7 @@ public void define(Context context) { FileReader reader = new FileReader(userExtensionXml); xmlRuleLoader.load(repository, reader); } catch (Exception ex) { - CxxUtils.LOG.info("Cannot Load XML '{}'", ex.getMessage()); + CxxUtils.LOG.info("Cannot Load XML '{}'", ex); } } } diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java index 16b6cee6e3..396a20ae05 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java @@ -87,7 +87,7 @@ public void stream(SMHierarchicCursor rootCursor) throws javax.xml.stream.XMLStr while (fileCursor.getNext() != null) { String name = fileCursor.getAttrValue("name"); - CxxUtils.LOG.info("Vera++ processes file = " + name); + CxxUtils.LOG.info("Vera++ processes file = {}", name); SMInputCursor errorCursor = fileCursor.childElementCursor("error"); while (errorCursor.getNext() != null) { if (!"error".equals(name)) { @@ -98,9 +98,11 @@ public void stream(SMHierarchicCursor rootCursor) throws javax.xml.stream.XMLStr saveUniqueViolation(project, context, CxxVeraxxRuleRepository.KEY, name, line, source, message); } else { - CxxUtils.LOG.debug("Error in file '{}', with message '{}'", + if (CxxUtils.LOG.isDebugEnabled()) { + CxxUtils.LOG.debug("Error in file '{}', with message '{}'", name + "(" + errorCursor.getAttrValue("line") + ")", errorCursor.getAttrValue("message")); + } } } } @@ -109,7 +111,7 @@ public void stream(SMHierarchicCursor rootCursor) throws javax.xml.stream.XMLStr parser.parse(report); } catch (com.ctc.wstx.exc.WstxUnexpectedCharException e) { - CxxUtils.LOG.error("Ignore XML error from Veraxx '{}'", e.toString()); + CxxUtils.LOG.error("Ignore XML error from Veraxx '{}'", e); } } } diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/xunit/CxxXunitSensor.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/xunit/CxxXunitSensor.java index aee3605e9d..379a40044b 100644 --- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/xunit/CxxXunitSensor.java +++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/xunit/CxxXunitSensor.java @@ -236,7 +236,9 @@ private Collection lookupTestFiles(Project project, SensorContext cont for (TestCase tc : testcases) { tcTotal++; - CxxUtils.LOG.debug("Trying the input file for the testcase '{}' ...", tc.getFullname()); + if (CxxUtils.LOG.isDebugEnabled()) { + CxxUtils.LOG.debug("Trying the input file for the testcase '{}' ...", tc.getFullname()); + } InputFile inputFile = lookupFile(project, context, tc); if (inputFile != null) { CxxUtils.LOG.debug("... found! The input file is '{}'", inputFile); diff --git a/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java b/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java index 132da78769..dd06b1e878 100644 --- a/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java +++ b/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java @@ -94,10 +94,10 @@ static String getPropertyOrDefaultValue(String propertyKey, String defaultValue) String propertyValue = System.getProperty(propertyKey); if (propertyValue == null) { - LOG.info("The property \"" + propertyKey + "\" is not set, using the default value \"" + defaultValue + "\"."); + LOG.info("The property '{}' is not set, using the default value '{}'.", propertyKey, defaultValue); return defaultValue; } else { - LOG.info("The property \"" + propertyKey + "\" is set, using its value \"" + propertyValue + "\"."); + LOG.info("The property '{}' is set, using its value '{}'.", propertyKey, defaultValue); return propertyValue; } }