本文整理匯總了Java中org.sonar.squidbridge.metrics.CounterVisitor類的典型用法代碼示例。如果您正苦於以下問題:Java CounterVisitor類的具體用法?Java CounterVisitor怎麽用?Java CounterVisitor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CounterVisitor類屬於org.sonar.squidbridge.metrics包,在下文中一共展示了CounterVisitor類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setMetrics
import org.sonar.squidbridge.metrics.CounterVisitor; //導入依賴的package包/類
private static void setMetrics(FlowConfiguration conf, AstScanner.Builder<Grammar> builder) {
builder.withMetrics(FlowMetric.values());
builder.setFilesMetric(FlowMetric.FILES);
builder.withSquidAstVisitor(new LinesVisitor<Grammar>(FlowMetric.LINES));
builder.withSquidAstVisitor(new FlowLinesOfCodeVisitor<Grammar>(FlowMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(new DependencyVisitor<Grammar>());
AstNodeType[] complexityAstNodeType = new AstNodeType[]{
FlowGrammar.LOOP,
FlowGrammar.BRANCH,
FlowGrammar.SEQUENCE,
FlowGrammar.RETRY
};
builder.withSquidAstVisitor(ComplexityVisitor.<Grammar>builder()
.setMetricDef(FlowMetric.COMPLEXITY)
.subscribeTo(complexityAstNodeType)
.build());
builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder().withCommentMetric(FlowMetric.COMMENT_LINES)
.withNoSonar(true)
.build());
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(FlowMetric.MAPS)
.subscribeTo(FlowGrammar.MAP)
.build());
}
示例2: create
import org.sonar.squidbridge.metrics.CounterVisitor; //導入依賴的package包/類
public static AstScanner<Grammar> create(PuppetConfiguration conf, SquidAstVisitor<Grammar>... visitors) {
final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<>(new SourceProject("Puppet Project"));
final Parser<Grammar> parser = PuppetParser.create(conf);
AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);
builder.withMetrics(PuppetMetric.values());
builder.setFilesMetric(PuppetMetric.FILES);
builder.setCommentAnalyser(new PuppetCommentAnalyser());
builder.withSquidAstVisitor(new LinesVisitor<Grammar>(PuppetMetric.LINES));
builder.withSquidAstVisitor(new PuppetLinesOfCodeVisitor<Grammar>(PuppetMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(new FunctionVisitor());
builder.withSquidAstVisitor(new ComplexityVisitor());
builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder().withCommentMetric(PuppetMetric.COMMENT_LINES)
.withNoSonar(true)
.withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
.build());
builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<Grammar>(
new ClassSourceCodeBuilderCallback(),
PuppetGrammar.CLASSDEF,
PuppetGrammar.DEFINITION));
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.CLASSES)
.subscribeTo(PuppetGrammar.CLASSDEF, PuppetGrammar.DEFINITION)
.build());
// TODO: To be discussed with the mapping of FUNCTIONS
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.RESOURCES)
.subscribeTo(PuppetGrammar.RESOURCE)
.build());
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.STATEMENTS)
.subscribeTo(PuppetGrammar.STATEMENT)
.build());
for (SquidAstVisitor<Grammar> visitor : visitors) {
if (visitor instanceof CharsetAwareVisitor) {
((CharsetAwareVisitor) visitor).setCharset(conf.getCharset());
}
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}