当前位置: 首页>>代码示例>>Java>>正文


Java CheckFactory类代码示例

本文整理汇总了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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:CssAnalyzerSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:LessAnalyzerSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:ScssAnalyzerSensorTest.java

示例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));
 }
 
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:19,代码来源:FlowSquidSensor.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:20,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:17,代码来源:JavaPropertiesSquidSensor.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:19,代码来源:JavaPropertiesSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:20,代码来源:JavaPropertiesSquidSensorTest.java

示例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);
}
 
开发者ID:gjd6640,项目名称:sonar-text-plugin,代码行数:23,代码来源:IssueSensorTest.java


注:本文中的org.sonar.api.batch.rule.CheckFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。