All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.drools.rules.DefaultDroolsProfile Maven / Gradle / Ivy

/*
 * Sonar Drools Plugin
 * Copyright (C) 2011 Jérémie Lagarde
 * [email protected]
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
 */
package org.sonar.plugins.drools.rules;

import java.util.List;

import org.sonar.api.profiles.ProfileDefinition;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleRepository;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.plugins.drools.language.Drools;

/**
 * Default Drools Profile.
 * It activates by default the  MAJOR, CRITICAL and BLOCKER rules
 * 
 * @author Jeremie Lagarde
 * @since 0.1
 */
public class DefaultDroolsProfile extends ProfileDefinition {
  
  private RuleRepository repository;
  
  public DefaultDroolsProfile(DroolsRuleRepository ruleRepository) {
    this.repository = ruleRepository;
  }
  
  @Override
  public RulesProfile createProfile(ValidationMessages validation) {
    List rules = repository.createRules();
    RulesProfile rulesProfile = RulesProfile.create(DroolsRuleRepository.REPOSITORY_NAME, Drools.KEY);
    for (Rule rule : rules) {
      //if(RulePriority.MAJOR.equals(rule.getPriority()) || RulePriority.CRITICAL.equals(rule.getPriority())  || RulePriority.BLOCKER.equals(rule.getPriority() ))
      rulesProfile.activateRule(rule,null);
    }
    rulesProfile.setDefaultProfile(true);
    return rulesProfile;
  }
}
 




© 2015 - 2025 Weber Informatics LLC | Privacy Policy