001/*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2013 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.xoo.rule;
021
022import org.sonar.api.rule.RuleStatus;
023import org.sonar.api.rule.Severity;
024import org.sonar.api.server.rule.RuleDefinitions;
025import org.sonar.api.server.rule.RuleParamType;
026import org.sonar.xoo.Xoo;
027
028/**
029 * Define all the coding rules that are supported on the repository named "xoo".
030 */
031public class XooRuleDefinitions implements RuleDefinitions {
032
033  public static final String XOO_REPOSITORY = "xoo";
034
035  @Override
036  public void define(Context context) {
037    NewRepository repository = context.newRepository(XOO_REPOSITORY, Xoo.KEY).setName("Xoo");
038
039    // define a single rule programmatically. Note that rules
040    // can be loaded from JSON or XML files too.
041    NewRule x1Rule = repository.newRule("x1")
042      .setName("No empty line")
043      .setHtmlDescription("Generate an issue on empty lines of Xoo source files")
044
045        // optional tags
046      .setTags("style", "security")
047
048        // optional status. Default value is READY.
049      .setStatus(RuleStatus.BETA)
050
051        // default severity when the rule is activated on a Quality profile. Default value is MAJOR.
052      .setSeverity(Severity.MINOR);
053
054    x1Rule.newParam("acceptWhitespace")
055      .setDefaultValue("false")
056      .setType(RuleParamType.BOOLEAN)
057      .setDescription("Accept whitespaces on the line");
058
059    // don't forget to call done() to finalize the definition
060    repository.done();
061  }
062
063}