本文整理汇总了Java中org.sonar.squidbridge.api.SourceClass类的典型用法代码示例。如果您正苦于以下问题:Java SourceClass类的具体用法?Java SourceClass怎么用?Java SourceClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceClass类属于org.sonar.squidbridge.api包,在下文中一共展示了SourceClass类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveClassComplexity
import org.sonar.squidbridge.api.SourceClass; //导入依赖的package包/类
private void saveClassComplexity(InputFile inputFile, SourceFile squidFile) {
Collection<SourceCode> classes = scanner.getIndex().search(new QueryByParent(squidFile),
new QueryByType(SourceClass.class));
double complexityInClasses = 0;
for (SourceCode squidClass : classes) {
double classComplexity = squidClass.getDouble(FlowMetric.INVOKES);
complexityInClasses += classComplexity;
}
context.saveMeasure(inputFile, CoreMetrics.COMPLEXITY_IN_CLASSES, complexityInClasses);
}
示例2: leaveNode
import org.sonar.squidbridge.api.SourceClass; //导入依赖的package包/类
@Override
public void leaveNode(AstNode node) {
SourceClass sourceClass = (SourceClass) getContext().peekSourceCode();
int complexity = ChecksHelper.getRecursiveMeasureInt(sourceClass, PuppetMetric.COMPLEXITY);
if (complexity > max) {
String nodeType = node.is(PuppetGrammar.CLASSDEF) ? "class" : "define";
addIssue(node, this,
"The complexity of this " + nodeType + " is " + complexity + " which is greater than " + max + " authorized. Split this " + nodeType + ".",
(double) complexity - max);
}
}
示例3: createSourceCode
import org.sonar.squidbridge.api.SourceClass; //导入依赖的package包/类
@Override
public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) {
seq++;
SourceClass cls = new SourceClass("class:" + seq);
cls.setStartAtLine(astNode.getTokenLine());
return cls;
}
示例4: saveClassComplexity
import org.sonar.squidbridge.api.SourceClass; //导入依赖的package包/类
private void saveClassComplexity(SensorContext context, InputFile inputFile, SourceFile squidFile) {
Collection<SourceCode> classes = scanner.getIndex().search(new QueryByParent(squidFile), new QueryByType(SourceClass.class));
int complexityInClasses = 0;
for (SourceCode squidClass : classes) {
int classComplexity = squidClass.getInt(LuaMetric.COMPLEXITY);
complexityInClasses += classComplexity;
}
context.<Integer>newMeasure()
.on(inputFile)
.forMetric(CoreMetrics.COMPLEXITY_IN_CLASSES)
.withValue(complexityInClasses)
.save();
}
示例5: leaveNode
import org.sonar.squidbridge.api.SourceClass; //导入依赖的package包/类
@Override
public void leaveNode(AstNode node) {
SourceClass table = (SourceClass) getContext().peekSourceCode();
int tableComplexity = ChecksHelper.getRecursiveMeasureInt(table, LuaMetric.COMPLEXITY);
if (tableComplexity > maximumTableComplexityThreshold) {
String message = String.format("Table has a complexity of %s which is greater than %s authorized.", tableComplexity, maximumTableComplexityThreshold);
createIssueWithCost(message, node, (double)tableComplexity - maximumTableComplexityThreshold);
}
}