156 }
157 }
158
159 protected void analyzeComplexity(CxxComplexityScope scope) {160 SourceCode code = getContext().peekSourceCode();161 code.setMeasure(CxxMetric.COGNITIVE_COMPLEXITY, scope.getComplexity());162 }163
164}
84
85 private Deque<CxxComplexityScope> complexityScopes = null;
86
87 private static boolean isElseIf(AstNode node) { 88 return node.is(CxxGrammarImpl.selectionStatement) && node.getToken().getType().equals(CxxKeyword.IF) 89 && node.getParent().getPreviousAstNode().getType().equals(CxxKeyword.ELSE); 90 } 91
92 @Override
93 public void init() {
572 newHighlighting.save();
573 }
574
575 private <T extends Serializable> void saveMetric(InputFile file, Metric<T> metric, T value) {576 context.<T>newMeasure()577 .withValue(value)578 .forMetric(metric)579 .on(file)580 .save();581 }582}
553 cpdTokens.save();
554 }
555
556 private void saveHighlighting(InputFile inputFile, SourceFile sourceFile) {557 NewHighlighting newHighlighting = context.newHighlighting().onFile(inputFile);558559 List<CxxHighlighterVisitor.Highlight> data = (List<CxxHighlighterVisitor.Highlight>) sourceFile.getData(560 CxxMetric.HIGHLIGTHING_DATA);561 data.forEach((item) -> {562 try {563 newHighlighting.highlight(item.startLine, item.startLineOffset, item.endLine, item.endLineOffset,564 TypeOfText.forCssClass(item.typeOfText));565 } catch (IllegalArgumentException | IllegalStateException e) {566 // ignore highlight errors: parsing errors could lead to wrong location data567 LOG.debug("Highlighting error in file '{}' at start:{}:{} end:{}:{}", inputFile.filename(),568 item.startLine, item.startLineOffset, item.endLine, item.endLineOffset);569 }570 });571572 newHighlighting.save();573 }574
575 private <T extends Serializable> void saveMetric(InputFile file, Metric<T> metric, T value) {
576 context.<T>newMeasure()
536 fileLinesContext.save();
537 }
538
539 private void saveCpdTokens(InputFile inputFile, SourceFile sourceFile) {540 NewCpdTokens cpdTokens = context.newCpdTokens().onFile(inputFile);541542 List<CxxCpdVisitor.CpdToken> data = (List<CxxCpdVisitor.CpdToken>) sourceFile.getData(CxxMetric.CPD_TOKENS_DATA);543 data.forEach((item) -> {544 try {545 TextRange range = inputFile.newRange(item.startLine, item.startCol, item.endLine, item.endCol);546 cpdTokens.addToken(range, item.token);547 } catch (IllegalArgumentException | IllegalStateException e) {548 // ignore range errors: parsing errors could lead to wrong location data549 LOG.debug("CPD error in file '{}' at line:{}, column:{}", inputFile.filename(), item.startLine, item.startCol);550 }551 });552553 cpdTokens.save();554 }555
556 private void saveHighlighting(InputFile inputFile, SourceFile sourceFile) {
557 NewHighlighting newHighlighting = context.newHighlighting().onFile(inputFile);
This method does not have any documentation.
Consider adding a documentation comment to explain its use.
While it may seem like the usage of a method is perfectly obvious, any consumers of your API may not be able to pick up on certain details.
This method appears to return an address string based on its name and the return type, but it is hard to say anything further about it. We neither know if the address will be formatted in a special way nor are we given any useful information regarding the returned value.
String getAddress() {
// ...
}
Provide a detailed description of what the method does.
/**
* Returns the address in 3 line format,
* with street address on line 1, area/city on line 2
* and state and country as well as postal code on line 3.
*/
String getAddress() {
// ...
}