本文整理汇总了Java中org.sonar.squidbridge.api.CheckMessage类的典型用法代码示例。如果您正苦于以下问题:Java CheckMessage类的具体用法?Java CheckMessage怎么用?Java CheckMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckMessage类属于org.sonar.squidbridge.api包,在下文中一共展示了CheckMessage类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: saveIssues
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
/**
* Saves issues form input file and source file.
*
* @param sonarFile input file.
* @param squidFile source file.
*/
private void saveIssues(InputFile sonarFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
messages.forEach(message -> {
RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck());
Issuable issuable = resourcePerspectives.as(Issuable.class, sonarFile);
if (issuable != null) {
Issue issue = issuable.newIssueBuilder()
.ruleKey(ruleKey)
.line(message.getLine())
.message(message.getText(Locale.ENGLISH))
.build();
issuable.addIssue(issue);
}
});
}
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:23,代码来源:ApexSquidSensor.java
示例2: tryCatchCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void tryCatchCheck() {
//check valid flow
String validFlowPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkTryCatchValid/flow.xml";
SourceFile sfCorrect = FlowAstScanner.scanSingleFile( new File(validFlowPath) , new TryCatchCheck());
Set<CheckMessage> scmCorrect = sfCorrect.getCheckMessages();
assertEquals(0, scmCorrect.size());
// check invalid flow
String invalidFlowPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkTryCatchInvalid/flow.xml";
String expectedMessage = "Create try-catch sequence";
SourceFile sfViolation = FlowAstScanner.scanSingleFile( new File(invalidFlowPath) , new TryCatchCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(1, violationMessages.size());
assertTrue("Returned check message not as expected", expectedMessage.equals(violationMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:22,代码来源:FlowAstScannerTest.java
示例3: branchPropertiesCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void branchPropertiesCheck() {
String expectedMessageA = "Both switch and evaluate labels are defined in properties of BRANCH";
String expectedMessageB = "Evaluate labels must be true when no switch parameter is defined in BRANCH";
// Check correct flow
SourceFile sfCorrect = FlowAstScanner.scanSingleFile( new File("src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkBranchPropertiesValid/flow.xml"), new BranchPropertiesCheck());
Set<CheckMessage> scmCorrect = sfCorrect.getCheckMessages();
assertEquals(0, scmCorrect.size());
// Check violation flow A: both switch and evaluate labels defined
SourceFile sfViolationA = FlowAstScanner.scanSingleFile( new File("src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkBranchPropertiesInvalidA/flow.xml"), new BranchPropertiesCheck());
List<CheckMessage> violationAMessages = new ArrayList<CheckMessage>(sfViolationA.getCheckMessages());
assertEquals(1, violationAMessages.size());
assertTrue("Returned check message not as expected",expectedMessageA.equals(violationAMessages.get(0).getDefaultMessage()));
// Check violation flow B: neither switch nor evaluate labels defined
SourceFile sfViolationB = FlowAstScanner.scanSingleFile( new File("src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkBranchPropertiesInvalidB/flow.xml"), new BranchPropertiesCheck());
List<CheckMessage> violationBMessages = new ArrayList<CheckMessage>(sfViolationB.getCheckMessages());
assertEquals(1, violationBMessages.size());
assertTrue("Returned check message not as expected", expectedMessageB.equals(violationBMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:23,代码来源:FlowAstScannerTest.java
示例4: saveIssues
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
private void saveIssues(InputFile inputFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
for (CheckMessage message : messages) {
RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck());
NewIssue newIssue = context.newIssue();
NewIssueLocation primaryLocation = newIssue.newLocation()
.message(message.getText(Locale.ENGLISH))
.on(inputFile);
if (message.getLine() != null) {
primaryLocation.at(inputFile.selectLine(message.getLine()));
}
newIssue.forRule(ruleKey).at(primaryLocation).save();
}
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:18,代码来源:PuppetSquidSensor.java
示例5: addIssue
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
public void addIssue(@Nullable Integer line, CodeCheck check, String message, @Nullable Double cost) {
Preconditions.checkNotNull(check);
Preconditions.checkNotNull(message);
CheckMessage checkMessage = new CheckMessage(check, message);
if (line > 0) {
checkMessage.setLine(line);
}
if (cost == null) {
Annotation linear = AnnotationUtils.getAnnotation(check, SqaleLinearRemediation.class);
Annotation linearWithOffset = AnnotationUtils.getAnnotation(check, SqaleLinearWithOffsetRemediation.class);
if (linear != null || linearWithOffset != null) {
throw new IllegalStateException("A check annotated with a linear SQALE function should provide an effort to fix.");
}
} else {
checkMessage.setCost(cost);
}
if (getContext().peekSourceCode() instanceof SourceFile) {
getContext().peekSourceCode().log(checkMessage);
} else if (getContext().peekSourceCode().getParent(SourceFile.class) != null) {
getContext().peekSourceCode().getParent(SourceFile.class).log(checkMessage);
} else {
throw new IllegalStateException("Unable to log a check message on source code '"
+ (getContext().peekSourceCode() == null ? "[NULL]" : getContext().peekSourceCode().getKey()) + "'");
}
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:27,代码来源:PuppetCheckVisitor.java
示例6: saveViolations
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
private void saveViolations(SensorContext context, InputFile inputFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
if (messages != null) {
for (CheckMessage message : messages) {
RuleKey ruleKey = checks.ruleKey((SquidCheck<LexerlessGrammar>) message.getCheck());
NewIssue newIssue = context.newIssue()
.forRule(ruleKey)
.gap(message.getCost());
Integer line = message.getLine();
NewIssueLocation location = newIssue.newLocation()
.on(inputFile)
.message(message.getText(Locale.ENGLISH));
if (line != null) {
location.at(inputFile.selectLine(line));
}
newIssue.at(location);
newIssue.save();
}
}
}
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:22,代码来源:LuaSquidSensor.java
示例7: getIssues
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
public static Collection<CheckMessage> getIssues(String relativePath, CssCheck check, ActionParser<Tree> parser) {
File file = new File(relativePath);
TreeImpl tree = (TreeImpl) parser.parse(file);
CssTreeVisitorContext context = new CssTreeVisitorContext(tree, file, "css");
List<Issue> issues = check.scanFile(context);
return getCheckMessages(issues);
}
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:10,代码来源:TreeCheckTest.java
示例8: saveViolations
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
private void saveViolations(InputFile inputFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
if (messages != null) {
for (CheckMessage message : messages) {
SquidCheck<Grammar> c = (SquidCheck<Grammar>) message.getCheck();
logger.debug("+++File: " + squidFile.getKey() + " - Checking message ToplevelService: " + squidFile.getInt(FlowMetric.IS_TOP_LEVEL) + " TopLevelCheck: " + String.valueOf(c instanceof TopLevelCheck));
if(squidFile.getInt(FlowMetric.IS_TOP_LEVEL)!=1 && c instanceof TopLevelCheck){
logger.debug("+++Ignoring toplevelCheck: " + c.getKey() + " for file: " + squidFile.getKey());
}else{
logger.debug("+++ Message " + message.getDefaultMessage());
logger.debug("+++ Message " + message.toString());
RuleKey ruleKey;
if(message.getCheck() instanceof NodeCheck){
ruleKey = nodeChecks.ruleKey((SquidCheck<Grammar>) message.getCheck());
}else
ruleKey = checks.ruleKey((SquidCheck<Grammar>) message.getCheck());
Issuable issuable = resourcePerspectives.as(Issuable.class, inputFile);
if (issuable != null) {
IssueBuilder issueBuilder = issuable.newIssueBuilder().ruleKey(ruleKey).line(message.getLine())
.message(message.getText(Locale.ENGLISH));
if (message.getCost() != null) {
issueBuilder.effortToFix(message.getCost());
}
issuable.addIssue(issueBuilder.build());
}
}
}
}
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:32,代码来源:FlowSquidSensor.java
示例9: savePipelineCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void savePipelineCheck() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkSavePipelineInvalid/flow.xml";
String expectedMessage = "Remove service pub.flow:savePipeline";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new SavePipelineCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(1, violationMessages.size());
assertTrue("Returned check message not as expected", expectedMessage.equals(violationMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:12,代码来源:FlowAstScannerTest.java
示例10: disabledCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void disabledCheck() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkDisabledInvalid/flow.xml";
String expectedMessage = "Remove disabled code";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new DisabledCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(1, violationMessages.size());
assertTrue("Returned check message not as expected", expectedMessage.equals(violationMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:11,代码来源:FlowAstScannerTest.java
示例11: exitCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void exitCheck() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkExitStepInvalid/flow.xml";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new ExitCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(2, violationMessages.size());
// Todo check both violation messages
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:10,代码来源:FlowAstScannerTest.java
示例12: emptyMapCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void emptyMapCheck() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkEmptyMapInvalid/flow.xml";
String expectedMessage = "This map step in the flow is empty, create content or remove the map.";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new EmptyMapCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(1, violationMessages.size());
assertTrue("Returned check message not as expected", expectedMessage.equals(violationMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:11,代码来源:FlowAstScannerTest.java
示例13: emptyMapCheckValid
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void emptyMapCheckValid() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkEmptyMapValid/flow.xml";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new EmptyMapCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(0, violationMessages.size());
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:9,代码来源:FlowAstScannerTest.java
示例14: emptyFlowCheck
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
@Test
public void emptyFlowCheck() {
String invalidPath = "src/test/resources/WmPackage/ns/I8cFlowSonarPluginTest/pub/checkEmptyFlowInvalid/flow.xml";
String expectedMessage = "Service doesn't contain any flow steps. Remove service or add flow steps.";
SourceFile sfViolation = FlowAstScanner.scanSingleFile(new File(invalidPath), new EmptyFlowCheck());
List<CheckMessage> violationMessages = new ArrayList<CheckMessage>(sfViolation.getCheckMessages());
assertEquals(1, violationMessages.size());
assertTrue("Returned check message not as expected", expectedMessage.equals(violationMessages.get(0).getDefaultMessage()));
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:11,代码来源:FlowAstScannerTest.java
示例15: getIssues
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
public static Collection<CheckMessage> getIssues(String relativePath, GherkinCheck check, Charset charset, String language) {
File file = new File(relativePath);
GherkinDocumentTree propertiesTree = (GherkinDocumentTree) GherkinParserBuilder.createTestParser(charset, language).parse(file);
GherkinVisitorContext context = new GherkinVisitorContext(propertiesTree, file);
List<Issue> issues = check.scanFile(context);
return getCheckMessages(issues);
}
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:10,代码来源:TreeCheckTest.java
示例16: getIssues
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
public static Collection<CheckMessage> getIssues(String relativePath, JavaPropertiesCheck check, Charset charset) {
File file = new File(relativePath);
PropertiesTree propertiesTree = (PropertiesTree) JavaPropertiesParserBuilder.createParser(charset).parse(file);
JavaPropertiesVisitorContext context = new JavaPropertiesVisitorContext(propertiesTree, file);
List<Issue> issues = check.scanFile(context);
return getCheckMessages(issues);
}
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:10,代码来源:TreeCheckTest.java
示例17: createIssueWithCost
import org.sonar.squidbridge.api.CheckMessage; //导入依赖的package包/类
protected void createIssueWithCost(String message, AstNode node, double effort) {
CheckMessage checkMessage = new CheckMessage((Object) this, message);
if (node.getTokenLine() > 0) {
checkMessage.setLine(node.getTokenLine());
}
checkMessage.setCost(effort);
getContext().log(checkMessage);
}
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:9,代码来源:LuaCheck.java
注:本文中的org.sonar.squidbridge.api.CheckMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论