Tabnine Logo
ch.hortis.sonar.model
Code IndexAdd Tabnine to your IDE (free)

How to use ch.hortis.sonar.model

Best Java code snippets using ch.hortis.sonar.model (Showing top 14 results out of 315)

origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

private String retrieveRuleFailureLevel(String levelName) {
 String level = "5";
 if (RuleFailureLevel.ERROR.toString().equals(levelName)) {
  level = "1";
 } else if (RuleFailureLevel.WARNING.toString().equals(levelName)) {
  level = "3";
 }
 return level;
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

protected Ruleset buildModuleTree(List<ActiveRule> activeRules) {
 Ruleset ruleset = new Ruleset("Sonar PMD rules");
 for (ActiveRule activeRule : activeRules) {
  if (activeRule.getRule().getPluginName().equals(PmdPlugin.KEY)) {
   String configKey = activeRule.getRule().getConfigKey();
   Rule rule = new Rule(configKey, retrieveRuleFailureLevel(activeRule.getLevel().name()));
   List<Property> properties = null;
   if (activeRule.getActiveRuleParams() != null && !activeRule.getActiveRuleParams().isEmpty()) {
    properties = new ArrayList<Property>();
    for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) {
     properties.add(new Property(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue()));
    }
   }
   rule.setProperties(properties);
   ruleset.addRule(rule);
  }
 }
 return ruleset;
}
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

private RulesProfile loadProvidedProfile(String name, String filename) {
 try {
  InputStream sonarWayProfile = getClass().getResourceAsStream(filename);
  RulesProfile profile = new RulesProfile(name);
  profile.setActiveRules(importConfiguration(IOUtils.toString(sonarWayProfile), getInitialReferential()));
  return profile;
 } catch (IOException e) {
  throw new RuntimeException("Configuration file not found for the profile : " + name, e);
 }
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

protected void buildActiveRulesFromModuleTree(Ruleset ruleset, List<ActiveRule> activeRules, List<ch.hortis.sonar.model.Rule> rules) {
 if (ruleset.getRules() != null && !ruleset.getRules().isEmpty()) {
  for (Rule rule : ruleset.getRules()) {
   String ref = rule.getRef();
   for (ch.hortis.sonar.model.Rule dbRule : rules) {
    if (dbRule.getConfigKey().equals(ref)) {
     RuleFailureLevel ruleFailureLevel = getRuleFailureLevel(rule);
     if (ruleFailureLevel != null) {
      ActiveRule activeRule = new ActiveRule(null, dbRule, ruleFailureLevel);
      activeRule.setActiveRuleParams(getActiveRuleParams(rule, dbRule, activeRule));
      activeRules.add(activeRule);
      break;
     }
    }
   }
  }
 }
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

private RulesProfile loadProvidedProfile(String name, String filename) {
 try {
  InputStream sonarWayProfile = getClass().getResourceAsStream(filename);
  RulesProfile profile = new RulesProfile(name);
  // TODO set as mandatory into the RulesProfile constructor
  profile.setLanguage(Languages.JAVA.getKey());
  profile.setActiveRules(importConfiguration(IOUtils.toString(sonarWayProfile), getInitialReferential()));
  return profile;
 } catch (IOException e) {
  throw new RuntimeException("Configuration file not found for the profile : " + name, e);
 }
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

public String exportConfiguration(RulesProfile activeProfile) {
 Ruleset tree = buildModuleTree(activeProfile.getActiveRulesByPlugin(PmdPlugin.KEY));
 String xmlModules = buildXmlFromModuleTree(tree);
 return addHeaderToXml(xmlModules);
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

private List<ActiveRuleParam> getActiveRuleParams(Rule rule, ch.hortis.sonar.model.Rule dbRule, ActiveRule activeRule) {
 List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
 if (rule.getProperties() != null) {
  for (Property property : rule.getProperties()) {
   if (dbRule.getParams() != null) {
    for (RuleParam ruleParam : dbRule.getParams()) {
     if (ruleParam.getKey().equals(property.getName())) {
      activeRuleParams.add(new ActiveRuleParam(activeRule, ruleParam, property.getValue()));
     }
    }
   }
  }
 }
 return activeRuleParams;
}
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

String line = error.getAttribute("line");
if (line != null && !"".equals(line)) {
 lineParam = new RuleFailureParam("line", CollectorUtils.parseNumber(line), null);
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

protected Module buildModuleTree(List<ActiveRule> activeRules) {
 Module root = new Module("");
 for (ActiveRule activeRule : activeRules) {
  if (activeRule.getRule().getPluginName().equals(CheckstylePlugin.KEY)) {
   String configKey = activeRule.getRule().getConfigKey();
   Module current = root;
   String[] modules = StringUtils.split(configKey, MODULE_SEPARATOR);
   String failureLevel = StringUtils.lowerCase(activeRule.getLevel().name());
   properties.add(new Property("severity", failureLevel));
   for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) {
    if (activeRuleParam.getValue() != null && activeRuleParam.getValue().length() != 0) {
     properties.add(new Property(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue()));
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

protected void buildActiveRulesFromModuleTree(Module moduleTree, String modulePath, List<ActiveRule> activeRules, List<Rule> rules) {
 if (moduleTree.getChildren() == null || moduleTree.getChildren().isEmpty()) {
  for (Rule rule : rules) {
   if (rule.getConfigKey().equals(modulePath)) {
    RuleFailureLevel ruleFailureLevel = getRuleFailureLevel(moduleTree);
    if (ruleFailureLevel != null) {
     ActiveRule activeRule = new ActiveRule(null, rule, ruleFailureLevel);
     activeRule.setActiveRuleParams(getActiveRuleParams(moduleTree, rule, activeRule));
     activeRules.add(activeRule);
     return;
    }
   }
  }
 } else {
  String baseModulePath = modulePath.length() == 0 ? moduleTree.getName() + MODULE_SEPARATOR :
   modulePath + MODULE_SEPARATOR;
  for (Module child : moduleTree.getChildren()) {
   buildActiveRulesFromModuleTree(child, baseModulePath + child.getName(), activeRules, rules);
  }
 }
}
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

public String exportConfiguration(RulesProfile activeProfile) {
 Module tree = buildModuleTree(activeProfile.getActiveRulesByPlugin(CheckstylePlugin.KEY));
 String xmlModules = buildXmlFromModuleTree(tree);
 return addHeaderToXml(xmlModules);
}
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

private RuleFailureLevel getRuleFailureLevel(Module module) {
 if (module.getProperties() != null) {
  for (Property property : module.getProperties()) {
   if (property.getName().equals("severity")) {
    if (property.getValue().equals(StringUtils.lowerCase(RuleFailureLevel.ERROR.toString()))) {
     return RuleFailureLevel.ERROR;
    } else if (property.getValue().equals(StringUtils.lowerCase(RuleFailureLevel.WARNING.toString()))) {
     return RuleFailureLevel.WARNING;
    } else {
     return null;
    }
   }
  }
 }
 return RuleFailureLevel.ERROR;
}
origin: org.codehaus.sonar.plugins/sonar-plugin-checkstyle

private List<ActiveRuleParam> getActiveRuleParams(Module module, Rule rule, ActiveRule activeRule) {
 List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
 if (module.getProperties() != null) {
  for (Property property : module.getProperties()) {
   if (rule.getParams() != null) {
    for (RuleParam ruleParam : rule.getParams()) {
     if (ruleParam.getKey().equals(property.getName())) {
      activeRuleParams.add(new ActiveRuleParam(activeRule, ruleParam, property.getValue()));
     }
    }
   }
  }
 }
 return activeRuleParams;
}
origin: org.codehaus.sonar.plugins/sonar-plugin-pmd

String line = violation.getAttribute("beginline");
if (line != null && !"".equals(line)) {
 lineParam = new RuleFailureParam("line", CollectorUtils.parseNumber(line), null);
 columnParam = new RuleFailureParam("column", CollectorUtils.parseNumber(column), null);
ch.hortis.sonar.model

Most used classes

  • ActiveRule
  • Rule
  • RuleFailureLevel
  • RuleFailureParam
  • RulesProfile
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now