@Override public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) { List<ActiveRule> activeRules = new ArrayList<>(); for (RulesProfile profile : profiles) { activeRules.addAll(profile.getActiveRulesByRepository(repositoryKey)); } return activeRules; }
@Override public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) { List<ActiveRule> activeRules = new ArrayList<ActiveRule>(); for (RulesProfile profile : profiles) { activeRules.addAll(profile.getActiveRulesByRepository(repositoryKey)); } return activeRules; }
protected void init() { checkByActiveRule.clear(); activeRuleByCheck.clear(); for (ActiveRule activeRule : profile.getActiveRulesByRepository(repositoryKey)) { C check = createCheck(activeRule); checkByActiveRule.put(activeRule, check); activeRuleByCheck.put(check, activeRule); } }
public void exportProfile(RulesProfile profile) { try { generateXML(profile.getActiveRulesByRepository(CodeNarcRulesDefinition.REPOSITORY_KEY)); } catch (IOException e) { throw new IllegalStateException("Fail to export CodeNarc profile : " + profile, e); } }
public boolean shouldExecuteOnProject(Project project) { return (!project.getFileSystem().mainFiles(Java.KEY).isEmpty() && !profile.getActiveRulesByRepository(PmdConstants.REPOSITORY_KEY).isEmpty()) || (!project.getFileSystem().testFiles(Java.KEY).isEmpty() && !profile.getActiveRulesByRepository(PmdConstants.TEST_REPOSITORY_KEY).isEmpty()); }
public boolean shouldExecuteOnProject(Project project) { return !project.getFileSystem().mainFiles(Java.KEY).isEmpty() && !profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).isEmpty(); }
/** * Exports configuration * @param activeProfile The currrent active quality profile * @return The active rules as XML String */ public static String exportConfiguration(RulesProfile activeProfile) { Ruleset tree = buildRulesetFromActiveProfile(activeProfile .getActiveRulesByRepository(DelphiPmdConstants.REPOSITORY_KEY)); return DelphiRulesUtils.buildXmlFromRuleset(tree); }
public String exportProfile(String repositoryKey, RulesProfile profile) { String profileName = profile.getName(); PmdRuleset tree = createPmdRuleset(repositoryKey, profile.getActiveRulesByRepository(repositoryKey), profileName); StringWriter stringWriter = new StringWriter(); exportPmdRulesetToXml(tree, stringWriter, profileName); return stringWriter.toString(); }
private List<String> enabledRuleConfigKeys() { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (ActiveRule activeRule : profile.getActiveRulesByRepository(fxCopConf.repositoryKey())) { if (!CUSTOM_RULE_KEY.equals(activeRule.getRuleKey())) { String effectiveConfigKey = activeRule.getConfigKey(); if (effectiveConfigKey == null) { effectiveConfigKey = activeRule.getParameter(CUSTOM_RULE_CHECK_ID_PARAMETER); } builder.add(effectiveConfigKey); } } return builder.build(); }
public String exportProfile(String repositoryKey, RulesProfile profile) { String profileName = profile.getName(); PmdRuleSet tree = createPmdRuleset(repositoryKey, profile.getActiveRulesByRepository(repositoryKey)); StringWriter stringWriter = new StringWriter(); exportPmdRulesetToXml(tree, stringWriter, profileName); return stringWriter.toString(); }
private String ruleKey(String ruleConfigKey) { for (ActiveRule activeRule : profile.getActiveRulesByRepository(fxCopConf.repositoryKey())) { if (ruleConfigKey.equals(activeRule.getConfigKey()) || ruleConfigKey.equals(activeRule.getParameter(CUSTOM_RULE_CHECK_ID_PARAMETER))) { return activeRule.getRuleKey(); } } throw new IllegalStateException( "Unable to find the rule key corresponding to the rule config key \"" + ruleConfigKey + "\" in repository \"" + fxCopConf.repositoryKey() + "\"."); }
private boolean isToolEnableInProfile() { boolean result = !rulesProfile.getActiveRulesByRepository(profileExporter.getKey()).isEmpty(); if (!result) { LOG.warn("/!\\ SKIP " + getToolName() + " analysis: no rule defined for " + getToolName() + " in the \"{}\" profile.", rulesProfile.getName()); } return result; } }
@Override public void exportProfile(RulesProfile profile, Writer writer) { String profileName = profile.getName(); PmdRuleset tree = createPmdRuleset(PmdConstants.REPOSITORY_KEY, profile.getActiveRulesByRepository(PmdConstants.REPOSITORY_KEY), profileName); exportPmdRulesetToXml(tree, writer, profileName); }
/** * {@inheritDoc} */ @Override public void exportProfile(RulesProfile profile, Writer writer) { try { printRules(writer, profile.getActiveRulesByRepository(getKey())); } catch (IOException e) { throw new SonarException("Error while generating the Gendarme profile to export: " + profile, e); } }
@Override public void exportProfile(RulesProfile profile, Writer writer) { String profileName = profile.getName(); PmdRuleSet tree = createPmdRuleset(PmdConstants.REPOSITORY_KEY, profile.getActiveRulesByRepository(PmdConstants.REPOSITORY_KEY)); exportPmdRulesetToXml(tree, writer, profileName); }
@Override public void exportProfile(RulesProfile profile, Writer writer) { try { ListMultimap<String, ActiveRule> activeRulesByConfigKey = arrangeByConfigKey(profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY)); generateXML(writer, activeRulesByConfigKey); } catch (IOException e) { throw new SonarException("Fail to export the profile " + profile, e); } }
private void printRules(RulesProfile profile, Writer writer) throws IOException { List<ActiveRule> activeRules = profile.getActiveRulesByRepository(getKey()); List<FxCopRule> rules = transformIntoFxCopRules(activeRules); // We group the rules by RuleFile names Map<String, List<FxCopRule>> rulesByFile = groupFxCopRulesByRuleFileName(rules); // And then print out each rule for (String fileName : rulesByFile.keySet()) { printRuleFile(writer, rulesByFile, fileName); } }
@Override public void exportProfile(RulesProfile profile, Writer writer) { try { ListMultimap<String, ActiveRule> activeRulesByConfigKey = arrangeByConfigKey(profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY)); generateXML(writer, activeRulesByConfigKey); } catch (IOException e) { throw new SonarException("Fail to export the profile " + profile, e); } }
@Override public boolean shouldExecuteOnProject(Project project) { FilePredicates predicates = fs.predicates(); Iterable<File> mainFiles = fs.files(predicates.and( predicates.hasLanguage(CheckstyleConstants.JAVA_KEY), predicates.hasType(Type.MAIN))); return !Iterables.isEmpty(mainFiles) && !profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).isEmpty(); }
private boolean hasFilesToCheck(Type type, String repositoryKey) { FilePredicates predicates = fs.predicates(); Iterable<File> files = fs.files(predicates.and( predicates.hasLanguage(Java.KEY), predicates.hasType(type))); return !Iterables.isEmpty(files) && !profile.getActiveRulesByRepository(repositoryKey).isEmpty(); }