本文整理汇总了Java中org.sonar.api.batch.rule.CheckFactory类的典型用法代码示例。如果您正苦于以下问题:Java CheckFactory类的具体用法?Java CheckFactory怎么用?Java CheckFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CheckFactory类属于org.sonar.api.batch.rule包,在下文中一共展示了CheckFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.css");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.CSS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createCssSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例2: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.less");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.LESS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createLessSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例3: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.scss");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.SCSS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createScssSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例4: FlowSquidSensor
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
public FlowSquidSensor(Settings settings, CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory,
FileSystem fileSystem, ResourcePerspectives resourcePerspectives, PathResolver pathResolver) {
logger.debug("** FlowSquidSenser constructor");
this.settings = settings;
this.pathResolver = pathResolver;
this.checks = checkFactory
.<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
.addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY),false));
this.nodeChecks = checkFactory
.<SquidCheck<Grammar>>create(CheckList.REPOSITORY_KEY)
.addAnnotatedChecks((Iterable)CheckList.getChecks(settings.getBoolean(FlowPlugin.IGNORE_TOPLEVEL_KEY), true));
this.fileLinesContextFactory = fileLinesContextFactory;
this.fileSystem = fileSystem;
this.resourcePerspectives = resourcePerspectives;
this.mainFilePredicates = fileSystem.predicates().and(
fileSystem.predicates().hasLanguage(FlowLanguage.KEY),
fileSystem.predicates().hasType(InputFile.Type.MAIN));
}
示例5: should_execute_and_save_issues_on_UTF8_with_BOM_file
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_with_BOM_file() {
inputFile("my-feature-bom.feature", Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
createGherkinSquidSensor().execute(context);
assertThat(context.allIssues()).hasSize(3);
}
示例6: should_execute_and_save_issues_on_UTF8_file
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_file() {
inputFile("my-feature.feature", Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
createGherkinSquidSensor().execute(context);
assertThat(context.allIssues()).hasSize(3);
}
示例7: should_execute_and_save_issues_on_UTF8_with_BOM_file_french
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_with_BOM_file_french() {
inputFile("my-feature-bom-fr.feature", Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
createGherkinSquidSensor().execute(context);
assertThat(context.allIssues()).hasSize(3);
}
示例8: should_execute_and_save_issues_on_UTF8_file_french
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_file_french() {
inputFile("my-feature-fr.feature", Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
createGherkinSquidSensor().execute(context);
assertThat(context.allIssues()).hasSize(3);
}
示例9: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
String relativePath = "parsing-error.feature";
inputFile(relativePath, Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createGherkinSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例10: JavaPropertiesSquidSensor
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
public JavaPropertiesSquidSensor(FileSystem fileSystem, CheckFactory checkFactory, @Nullable CustomJavaPropertiesRulesDefinition[] customRulesDefinition) {
this.fileSystem = fileSystem;
this.charset = Charset.forName("ISO-8859-1");
this.mainFilePredicate = fileSystem.predicates().and(
fileSystem.predicates().hasType(InputFile.Type.MAIN),
fileSystem.predicates().hasLanguage(JavaPropertiesLanguage.KEY));
this.parser = JavaPropertiesParserBuilder.createParser(charset);
this.checks = JavaPropertiesChecks.createJavaPropertiesChecks(checkFactory)
.addChecks(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, GenericJavaPropertiesRulesDefinition.getChecks())
.addChecks(SonarScannerJavaPropertiesRulesDefinition.SONAR_SCANNER_REPOSITORY_KEY, SonarScannerJavaPropertiesRulesDefinition.getChecks())
.addCustomChecks(customRulesDefinition);
}
示例11: should_execute_and_save_issues_on_ISO_8859_1_file
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_ISO_8859_1_file() {
inputFile("myProperties.properties", Charsets.ISO_8859_1);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
.activate()
.create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, LineLengthCheck.class.getAnnotation(Rule.class).key()))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
createJavaPropertiesSquidSensor().execute(context);
assertThat(context.allIssues()).hasSize(4);
}
示例12: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
String relativePath = "parsingError.properties";
inputFile(relativePath, Charsets.ISO_8859_1);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createJavaPropertiesSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(2);
}
示例13: createIssueSensorBackedByMocks
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
List<Object> checksList = Arrays.asList(new Object[] {realIfOneStringExistsBothMustExistMultiFileCheck});
when(checks.all()).thenReturn(checksList);
when(checks.ruleKey(Mockito.isA(StringDisallowedIfMatchInAnotherFileCheck.class))).thenReturn(RuleKey.of("text", "StringDisallowedIfMatchInAnotherFileCheck"));
when(checks.ruleKey(Mockito.isA(MultiFileIfOneStringExistsThenBothMustExistCheck.class))).thenReturn(RuleKey.of("text", "MultiFileIfOneStringExistsThenBothMustExistCheck"));
// realStringDisallowedMultiFileCheck.setRuleKey(RuleKey.parse("text:StringDisallowedIfMatchInAnotherFileCheck")); // Not strictly necessary here. Normally set by the framework to the value in the Check class's annotation
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:26,代码来源:MultiFileIfOneExistsThenBothMustExistCheckTest.java
示例14: createIssueSensorBackedByMocks
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
List<Object> checksList = Arrays.asList(new Object[] {realStringDisallowedMultiFileCheck});
when(checks.all()).thenReturn(checksList);
when(checks.ruleKey(Mockito.isA(StringDisallowedIfMatchInAnotherFileCheck.class))).thenReturn(RuleKey.of("text", "StringDisallowedIfMatchInAnotherFileCheck"));
// realStringDisallowedMultiFileCheck.setRuleKey(RuleKey.parse("text:StringDisallowedIfMatchInAnotherFileCheck")); // Not strictly necessary here. Normally set by the framework to the value in the Check class's annotation
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:25,代码来源:StringDisallowedIfMatchInAnotherFileCheckTest.java
示例15: createIssueSensorBackedByMocks
import org.sonar.api.batch.rule.CheckFactory; //导入依赖的package包/类
@Before
public void createIssueSensorBackedByMocks() {
ResourcePerspectives resourcePerspectives = mock(ResourcePerspectives.class);
Checks<Object> checks = mock(Checks.class);
CheckFactory checkFactory = mock(CheckFactory.class);
when(checkFactory.create(Mockito.anyString())).thenReturn(checks);
textCheckMock = mock(AbstractTextCheck.class);
List<Object> checksList = Arrays.asList(new Object[] {textCheckMock});
when(checks.all()).thenReturn(checksList);
when(checks.addAnnotatedChecks(Mockito.anyCollection())).thenReturn(checks);
mockIssuable = mock(Issuable.class);
when(resourcePerspectives.as(Mockito.eq(Issuable.class), Mockito.isA(InputFile.class))).thenReturn(mockIssuable);
IssueBuilder mockIssueBuilder = mock(IssueBuilder.class);
when(mockIssuable.newIssueBuilder()).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.ruleKey(Mockito.isA(RuleKey.class))).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.line(Mockito.anyInt())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.message(Mockito.anyString())).thenReturn(mockIssueBuilder);
when(mockIssueBuilder.build()).thenReturn(mock(Issue.class));
sensor = new TextIssueSensor(fs, resourcePerspectives, checkFactory, project);
}