Exemplo n.º 1
0
  @Test
  public void toModels() {
    Rule rule = new RuleUnmarshaller().toModel("[]");
    assertThat(rule, nullValue());

    List<Rule> rules = new RuleUnmarshaller().toModels("[]");
    assertThat(rules.size(), is(0));

    rules = new RuleUnmarshaller().toModels(loadFile("/rules/rules.json"));
    assertThat(rules.size(), is(6));

    rule = rules.get(0);
    assertThat(rule.getTitle(), is("Indentation"));
    assertThat(
        rule.getKey(),
        is("checkstyle:com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"));
    assertThat(rule.getRepository(), is("checkstyle"));
    assertThat(rule.getDescription(), is("Checks correct indentation of Java Code."));
    assertThat(rule.getSeverity(), is("MINOR"));
    assertThat(rule.isActive(), is(false));
    assertThat(rule.getParams().size(), is(3));
    assertThat(rule.getParams().get(0).getName(), is("basicOffset"));
    assertThat(
        rule.getParams().get(0).getDescription(),
        is("how many spaces to use for new indentation level. Default is 4."));

    rule = rules.get(1);
    assertThat(rule.isActive(), is(true));
  }
Exemplo n.º 2
0
 @Override
 public boolean isValid(Issue issue) {
   return issue.ruleKey().equals(rule.getKey());
 }
Exemplo n.º 3
0
 @Override
 public void apply(IssueQuery query) {
   query.rules(rule.getKey());
 }