import org.sonar.server.search.action.KeyIndexAction;
import javax.annotation.CheckForNull;
+
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
private static final String ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED = "ActiveRuleParam is already persisted";
private static final String PARAMETER_NAME_CANNOT_BE_NULL = "ParameterName cannot be null";
- //TODO remove once key is finalized (used only to get id for SQL statement)
+ // TODO remove once key is finalized (used only to get id for SQL statement)
private final RuleDao ruleDao;
private final QualityProfileDao profileDao;
ActiveRuleDto activeRule = mapper(session).selectById(activeRuleId);
if (activeRule != null) {
QualityProfileDto profile = profileDao.getById(activeRule.getProfileId(), session);
- RuleDto rule = ruleDao.getById(session, activeRule.getRulId());
+ RuleDto rule = ruleDao.getById(session, activeRule.getRuleId());
if (profile != null && rule != null) {
activeRule.setKey(ActiveRuleKey.of(profile.getKey(), rule.getKey()));
return activeRule;
@Override
protected ActiveRuleDto doInsert(DbSession session, ActiveRuleDto item) {
Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED);
- Preconditions.checkArgument(item.getRulId() != null, RULE_IS_NOT_PERSISTED);
+ Preconditions.checkArgument(item.getRuleId() != null, RULE_IS_NOT_PERSISTED);
Preconditions.checkArgument(item.getId() == null, ACTIVE_RULE_IS_ALREADY_PERSISTED);
mapper(session).insert(item);
return item;
@Override
protected ActiveRuleDto doUpdate(DbSession session, ActiveRuleDto item) {
Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED);
- Preconditions.checkArgument(item.getRulId() != null, ActiveRuleDao.RULE_IS_NOT_PERSISTED);
+ Preconditions.checkArgument(item.getRuleId() != null, ActiveRuleDao.RULE_IS_NOT_PERSISTED);
Preconditions.checkArgument(item.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED);
mapper(session).update(item);
return item;
}
public void removeParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) {
- //TODO SQL rewrite to delete by key
+ // TODO SQL rewrite to delete by key
ActiveRuleDto activeRule = getNullableByKey(session, key);
if (activeRule != null) {
ActiveRuleParamDto activeRuleParam = mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), param);
Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL);
Preconditions.checkNotNull(name, PARAMETER_NAME_CANNOT_BE_NULL);
ActiveRuleDto activeRule = getNullableByKey(session, key);
- if (activeRule!=null) {
+ if (activeRule != null) {
return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name);
}
return null;
import static org.fest.assertions.Fail.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class QProfileRepositoryExporterTest {
ArgumentCaptor<ActiveRuleDto> activeRuleArgument = ArgumentCaptor.forClass(ActiveRuleDto.class);
verify(activeRuleDao).insert(activeRuleArgument.capture(), eq(session));
- assertThat(activeRuleArgument.getValue().getRulId()).isEqualTo(10);
+ assertThat(activeRuleArgument.getValue().getRuleId()).isEqualTo(10);
assertThat(activeRuleArgument.getValue().getSeverityString()).isEqualTo(Severity.BLOCKER);
ArgumentCaptor<ActiveRuleParamDto> activeRuleParamArgument = ArgumentCaptor.forClass(ActiveRuleParamDto.class);
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ </dependency>
<!-- unit tests -->
<dependency>
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 02110-1301, USA.
+ */
+package org.sonar.batch.protocol.input;
+
+import javax.annotation.CheckForNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ActiveRule {
+ private final String repositoryKey, ruleKey;
+ private final String severity, internalKey, language;
+ private final Map<String, String> params = new HashMap<String, String>();
+
+ public ActiveRule(String repositoryKey, String ruleKey, String severity, String internalKey, String language) {
+ this.repositoryKey = repositoryKey;
+ this.ruleKey = ruleKey;
+ this.severity = severity;
+ this.internalKey = internalKey;
+ this.language = language;
+ }
+
+ public String repositoryKey() {
+ return repositoryKey;
+ }
+
+ public String ruleKey() {
+ return ruleKey;
+ }
+
+ public String severity() {
+ return severity;
+ }
+
+ public String language() {
+ return language;
+ }
+
+ @CheckForNull
+ public String param(String key) {
+ return params.get(key);
+ }
+
+ public ActiveRule addParam(String key, String value) {
+ params.put(key, value);
+ return this;
+ }
+
+ public Map<String, String> params() {
+ return params;
+ }
+
+ public String internalKey() {
+ return internalKey;
+ }
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.protocol.input;
-
-public class Language {
-
- private String key;
-
- private String name;
-
- private String[] suffixes;
-
- public String key() {
- return key;
- }
-
- public String name() {
- return name;
- }
-
- public String[] suffixes() {
- return suffixes;
- }
-
-}
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
public class ProjectReferentials {
private long timestamp;
- private Collection<Language> languages = new ArrayList<Language>();
private Collection<Metric> metrics = new ArrayList<Metric>();
-
- public Collection<Language> languages() {
- return languages;
- }
+ private Map<String, QProfile> qprofilesByLanguage = new HashMap<String, QProfile>();
+ private Collection<ActiveRule> activeRules = new ArrayList<ActiveRule>();
public Collection<Metric> metrics() {
return metrics;
}
+ public Collection<QProfile> qProfiles() {
+ return qprofilesByLanguage.values();
+ }
+
+ public ProjectReferentials addQProfile(QProfile qProfile) {
+ qprofilesByLanguage.put(qProfile.language(), qProfile);
+ return this;
+ }
+
+ public Collection<ActiveRule> activeRules() {
+ return activeRules;
+ }
+
+ public ProjectReferentials addActiveRule(ActiveRule activeRule) {
+ activeRules.add(activeRule);
+ return this;
+ }
+
public long timestamp() {
return timestamp;
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 02110-1301, USA.
+ */
+package org.sonar.batch.protocol.input;
+
+import java.util.Date;
+
+public class QProfile {
+
+ private final String key, name, language;
+ private final Date rulesUpdatedAt;
+
+ public QProfile(String key, String name, String language, Date rulesUpdatedAt) {
+ this.key = key;
+ this.name = name;
+ this.language = language;
+ this.rulesUpdatedAt = rulesUpdatedAt;
+ }
+
+ public String key() {
+ return key;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public String language() {
+ return language;
+ }
+
+ public Date rulesUpdatedAt() {
+ return rulesUpdatedAt;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ QProfile qProfile = (QProfile) o;
+ return key.equals(qProfile.key);
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode();
+ }
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.protocol.input;
-
-import java.util.Map;
-
-public class QProfiles {
-
- public static class QProfile {
-
- private String key, name, language;
- }
-
- private Map<String, QProfile> byLanguage;
-
-}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.batch.protocol.input;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
import org.skyscreamer.jsonassert.JSONAssert;
import java.io.StringReader;
+import java.text.SimpleDateFormat;
import static org.fest.assertions.Assertions.assertThat;
public class ProjectReferentialsTest {
@Test
- public void testToJson() throws JSONException {
+ public void testToJson() throws Exception {
ProjectReferentials ref = new ProjectReferentials();
ref.metrics().add(new Metric("ncloc", "INT"));
+ ref.addQProfile(new QProfile("squid-java", "Java", "java", new SimpleDateFormat("dd/MM/yyyy").parse("14/03/1984")));
System.out.println(ref.toJson());
- JSONAssert.assertEquals("{timestamp:0,languages:[],metrics:[{key:ncloc,valueType:INT}]}", ref.toJson(), true);
+ JSONAssert
+ .assertEquals(
+ "{timestamp:0,metrics:[{key:ncloc,valueType:INT}],"
+ + "qprofilesByLanguage:{java:{key:\"squid-java\","
+ + "name:Java,"
+ + "language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}},"
+ + "activeRules:[]}",
+ ref.toJson(), true);
}
@Test
public void testFromJson() throws JSONException {
- ProjectReferentials ref = ProjectReferentials.fromJson(new StringReader("{timestamp:1,languages:[],metrics:[{key:ncloc,valueType:INT}]}"));
+ ProjectReferentials ref = ProjectReferentials.fromJson(new StringReader("{timestamp:1,metrics:[{key:ncloc,valueType:INT}]}"));
assertThat(ref.timestamp()).isEqualTo(1);
Metric metric = ref.metrics().iterator().next();
import org.sonar.api.config.EmailSettings;
import org.sonar.api.platform.ComponentContainer;
import org.sonar.api.platform.PluginMetadata;
-import org.sonar.api.rules.RuleFinder;
import org.sonar.api.utils.Durations;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
import org.sonar.api.utils.internal.TempFolderCleaner;
-import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.components.PastSnapshotFinder;
import org.sonar.batch.components.PastSnapshotFinderByDate;
import org.sonar.batch.components.PastSnapshotFinderByDays;
import org.sonar.batch.components.PastSnapshotFinderByPreviousAnalysis;
import org.sonar.batch.components.PastSnapshotFinderByPreviousVersion;
import org.sonar.batch.components.PastSnapshotFinderByVersion;
-import org.sonar.batch.debt.DebtModelProvider;
import org.sonar.batch.referential.DefaultProjectReferentialsLoader;
import org.sonar.batch.referential.ProjectReferentialsLoader;
-import org.sonar.batch.rule.RulesProvider;
-import org.sonar.batch.rules.DefaultQProfileReferential;
-import org.sonar.batch.rules.QProfilesReferential;
import org.sonar.batch.settings.DefaultSettingsReferential;
import org.sonar.batch.settings.SettingsReferential;
import org.sonar.core.cluster.NullQueue;
UriReader.class,
new FileCacheProvider(),
System2.INSTANCE);
- if (getComponentByType(ProjectReferentialsLoader.class) == null) {
- add(DefaultProjectReferentialsLoader.class);
- }
if (getComponentByType(SettingsReferential.class) == null) {
add(DefaultSettingsReferential.class);
}
if (getComponentByType(PluginsReferential.class) == null) {
add(DefaultPluginsReferential.class);
}
- if (getComponentByType(RuleFinder.class) == null) {
- add(CacheRuleFinder.class);
- }
- if (getComponentByType(QProfilesReferential.class) == null) {
- add(DefaultQProfileReferential.class);
+ if (getComponentByType(ProjectReferentialsLoader.class) == null) {
+ add(DefaultProjectReferentialsLoader.class);
}
}
JpaDatabaseSession.class,
BatchDatabaseSessionFactory.class,
DaoUtils.getDaoClasses(),
- PurgeProfiler.class);
+ PurgeProfiler.class,
+ CacheRuleFinder.class);
}
/**
PastSnapshotFinderByPreviousAnalysis.class,
PastSnapshotFinderByVersion.class,
PastSnapshotFinderByPreviousVersion.class,
- PastMeasuresLoader.class,
PastSnapshotFinder.class,
- Durations.class,
- new DebtModelProvider(),
- new RulesProvider());
+ Durations.class);
}
@Override
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 02110-1301, USA.
+ */
+package org.sonar.batch.languages;
+
+import org.sonar.api.resources.Languages;
+
+import javax.annotation.CheckForNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Languages referential using {@link Languages}
+ * @since 4.4
+ */
+public class DefaultLanguagesReferential implements LanguagesReferential {
+
+ private Languages languages;
+
+ public DefaultLanguagesReferential(Languages languages) {
+ this.languages = languages;
+ }
+
+ /**
+ * Get language.
+ */
+ @CheckForNull
+ public Language get(String languageKey) {
+ org.sonar.api.resources.Language language = languages.get(languageKey);
+ return language != null ? new Language(language.getKey(), language.getName(), language.getFileSuffixes()) : null;
+ }
+
+ /**
+ * Get list of all supported languages.
+ */
+ public Collection<Language> all() {
+ org.sonar.api.resources.Language[] all = languages.all();
+ Collection<Language> result = new ArrayList<Language>(all.length);
+ for (org.sonar.api.resources.Language language : all) {
+ result.add(new Language(language.getKey(), language.getName(), language.getFileSuffixes()));
+ }
+ return result;
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.languages;
-
-import org.sonar.api.resources.Languages;
-
-import javax.annotation.CheckForNull;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * Languages referential using {@link Languages}
- * @since 4.4
- */
-public class DeprecatedLanguagesReferential implements LanguagesReferential {
-
- private Languages languages;
-
- public DeprecatedLanguagesReferential(Languages languages) {
- this.languages = languages;
- }
-
- /**
- * Get language.
- */
- @CheckForNull
- public Language get(String languageKey) {
- org.sonar.api.resources.Language language = languages.get(languageKey);
- return language != null ? new Language(language.getKey(), language.getName(), language.getFileSuffixes()) : null;
- }
-
- /**
- * Get list of all supported languages.
- */
- public Collection<Language> all() {
- org.sonar.api.resources.Language[] all = languages.all();
- Collection<Language> result = new ArrayList<Language>(all.length);
- for (org.sonar.api.resources.Language language : all) {
- result.add(new Language(language.getKey(), language.getName(), language.getFileSuffixes()));
- }
- return result;
- }
-
-}
*/
package org.sonar.batch.mediumtest;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
import org.apache.commons.io.IOUtils;
import org.sonar.api.SonarPlugin;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.batch.debt.internal.DefaultDebtModel;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
-import org.sonar.api.batch.rule.internal.RulesBuilder;
+import org.sonar.api.config.Settings;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.platform.PluginMetadata;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RuleQuery;
+import org.sonar.api.resources.Languages;
import org.sonar.batch.bootstrap.PluginsReferential;
import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.batch.languages.Language;
-import org.sonar.batch.languages.LanguagesReferential;
+import org.sonar.batch.protocol.input.ActiveRule;
import org.sonar.batch.protocol.input.ProjectReferentials;
import org.sonar.batch.referential.ProjectReferentialsLoader;
-import org.sonar.batch.rule.QProfile;
-import org.sonar.batch.rules.QProfilesReferential;
import org.sonar.batch.scan.filesystem.InputFileCache;
import org.sonar.batch.scan2.AnalyzerIssueCache;
import org.sonar.batch.scan2.AnalyzerMeasureCache;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
private final FakeProjectReferentialsLoader refProvider = new FakeProjectReferentialsLoader();
private final FakeSettingsReferential settingsReferential = new FakeSettingsReferential();
private final FackPluginsReferential pluginsReferential = new FackPluginsReferential();
- private final FakeRuleFinder ruleFinder = new FakeRuleFinder();
- private final FakeQProfileReferential qProfileReferential = new FakeQProfileReferential();
- private final FakeLanguageReferential languageReferential = new FakeLanguageReferential();
private final Map<String, String> bootstrapProperties = new HashMap<String, String>();
- private final RulesBuilder rulesBuilder = new RulesBuilder();
- private final ActiveRulesBuilder activeRulesBuilder = new ActiveRulesBuilder();
- private int metricId = 1;
public AnalyzerMediumTester build() {
return new AnalyzerMediumTester(this);
public AnalyzerMediumTesterBuilder registerMetric(Metric<?> metric) {
refProvider.add(metric);
- metricId++;
return this;
}
public AnalyzerMediumTesterBuilder addQProfile(String language, String name) {
- qProfileReferential.add(new QProfile().setKey(name).setName(name).setLanguage(language).setRulesUpdatedAt(new Date()));
+ refProvider.addQProfile(language, name);
return this;
}
return this;
}
- public AnalyzerMediumTesterBuilder registerLanguage(org.sonar.api.resources.Language... languages) {
- languageReferential.register(languages);
- return this;
- }
-
public AnalyzerMediumTesterBuilder bootstrapProperties(Map<String, String> props) {
bootstrapProperties.putAll(props);
return this;
}
- public AnalyzerMediumTesterBuilder activateRule(RuleKey key) {
- rulesBuilder.add(key);
- activeRulesBuilder.create(key).activate();
- return this;
- }
-
- public AnalyzerMediumTesterBuilder registerInactiveRule(RuleKey key) {
- rulesBuilder.add(key);
+ public AnalyzerMediumTesterBuilder activateRule(ActiveRule activeRule) {
+ refProvider.addActiveRule(activeRule);
return this;
}
builder.settingsReferential,
builder.pluginsReferential,
builder.refProvider,
- builder.ruleFinder,
- builder.qProfileReferential,
- builder.rulesBuilder.build(),
- builder.activeRulesBuilder.build(),
- new DefaultDebtModel(),
- builder.languageReferential)
+ new DefaultDebtModel())
.setBootstrapProperties(builder.bootstrapProperties)
.build();
}
private ProjectReferentials ref = new ProjectReferentials();
@Override
- public ProjectReferentials load(String projectKey) {
+ public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) {
return ref;
}
+ public FakeProjectReferentialsLoader addQProfile(String language, String name) {
+ ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(name, name, language, new Date()));
+ return this;
+ }
+
public FakeProjectReferentialsLoader add(Metric metric) {
ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metric.key(), metric.getType().name()));
return this;
}
+
+ public FakeProjectReferentialsLoader addActiveRule(ActiveRule activeRule) {
+ ref.addActiveRule(activeRule);
+ return this;
+ }
}
private static class FakeSettingsReferential implements SettingsReferential {
}
- private static class FakeRuleFinder implements RuleFinder {
- private BiMap<Integer, Rule> rulesById = HashBiMap.create();
- private Map<String, Map<String, Rule>> rulesByRepoKeyAndRuleKey = Maps.newHashMap();
-
- @Override
- public Rule findById(int ruleId) {
- return rulesById.get(ruleId);
- }
-
- @Override
- public Rule findByKey(String repositoryKey, String ruleKey) {
- Map<String, Rule> repository = rulesByRepoKeyAndRuleKey.get(repositoryKey);
- return repository != null ? repository.get(ruleKey) : null;
- }
-
- @Override
- public Rule findByKey(RuleKey key) {
- return findByKey(key.repository(), key.rule());
- }
-
- @Override
- public Rule find(RuleQuery query) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Collection<Rule> findAll(RuleQuery query) {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class FakeQProfileReferential implements QProfilesReferential {
-
- private Map<String, Map<String, QProfile>> profiles = new HashMap<String, Map<String, QProfile>>();
-
- @Override
- public QProfile get(String language, String name) {
- return profiles.get(language).get(name);
- }
-
- public void add(QProfile qprofile) {
- if (!profiles.containsKey(qprofile.getLanguage())) {
- profiles.put(qprofile.getLanguage(), new HashMap<String, QProfile>());
- }
- profiles.get(qprofile.getLanguage()).put(qprofile.getName(), qprofile);
- }
-
- }
-
- private static class FakeLanguageReferential implements LanguagesReferential {
-
- private Map<String, Language> languages = new HashMap<String, Language>();
-
- public FakeLanguageReferential register(org.sonar.api.resources.Language... languages) {
- for (org.sonar.api.resources.Language language : languages) {
- this.languages.put(language.getKey(), new Language(language.getKey(), language.getName(), language.getFileSuffixes()));
- }
- return this;
- }
-
- @Override
- public Language get(String languageKey) {
- return languages.get(languageKey);
- }
-
- @Override
- public Collection<Language> all() {
- return languages.values();
- }
-
- }
-
}
*/
package org.sonar.batch.referential;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Languages;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.rules.RuleParam;
+import org.sonar.api.utils.MessageException;
+import org.sonar.batch.protocol.input.ActiveRule;
import org.sonar.batch.protocol.input.ProjectReferentials;
+import org.sonar.batch.protocol.input.QProfile;
+import org.sonar.batch.rule.ModuleQProfiles;
+import org.sonar.core.UtcDateUtils;
+import org.sonar.core.qualityprofile.db.ActiveRuleDao;
+import org.sonar.core.qualityprofile.db.ActiveRuleDto;
+import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
+import org.sonar.core.qualityprofile.db.QualityProfileDao;
+import org.sonar.core.qualityprofile.db.QualityProfileDto;
import org.sonar.jpa.session.DatabaseSessionFactory;
+import javax.annotation.CheckForNull;
+
import java.util.Collection;
+/**
+ * TODO This is currently implemented by accessing DB but should be replaced by WS call
+ */
public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoader {
private static final String ENABLED = "enabled";
- private DatabaseSessionFactory sessionFactory;
- protected Collection<Metric> doFindAll() {
- return sessionFactory.getSession().getResults(Metric.class, ENABLED, true);
- }
+ private final DatabaseSessionFactory sessionFactory;
+ private final QualityProfileDao qualityProfileDao;
+ private final ActiveRuleDao activeRuleDao;
+ private final RuleFinder ruleFinder;
- public DefaultProjectReferentialsLoader(DatabaseSessionFactory sessionFactory) {
+ public DefaultProjectReferentialsLoader(DatabaseSessionFactory sessionFactory, QualityProfileDao qualityProfileDao,
+ ActiveRuleDao activeRuleDao, RuleFinder ruleFinder) {
this.sessionFactory = sessionFactory;
+ this.qualityProfileDao = qualityProfileDao;
+ this.activeRuleDao = activeRuleDao;
+ this.ruleFinder = ruleFinder;
}
- public ProjectReferentials load(String projectKey) {
+ @Override
+ public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) {
ProjectReferentials ref = new ProjectReferentials();
for (Metric m : sessionFactory.getSession().getResults(Metric.class, ENABLED, true)) {
ref.metrics().add(new org.sonar.batch.protocol.input.Metric(m.getKey(), m.getType().name()));
}
+
+ String defaultName = settings.getString(ModuleQProfiles.SONAR_PROFILE_PROP);
+
+ for (Language language : languages.all()) {
+ org.sonar.batch.protocol.input.QProfile profile = null;
+ if (StringUtils.isNotBlank(defaultName)) {
+ profile = loadDefaultQProfile(defaultName, language.getKey());
+ }
+ if (profile == null) {
+ profile = loadQProfile(settings, language.getKey());
+ }
+ if (profile != null) {
+ ref.addQProfile(profile);
+ }
+ }
+
+ for (QProfile qProfile : ref.qProfiles()) {
+ ListMultimap<Integer, ActiveRuleParamDto> paramDtosByActiveRuleId = ArrayListMultimap.create();
+ for (ActiveRuleParamDto dto : activeRuleDao.selectParamsByProfileKey(qProfile.key())) {
+ paramDtosByActiveRuleId.put(dto.getActiveRuleId(), dto);
+ }
+
+ for (ActiveRuleDto activeDto : activeRuleDao.selectByProfileKey(qProfile.key())) {
+ Rule rule = ruleFinder.findById(activeDto.getRuleId());
+ if (rule != null) {
+ String internalKey;
+ Rule template = rule.getTemplate();
+ if (template != null) {
+ internalKey = template.getConfigKey();
+ } else {
+ internalKey = rule.getConfigKey();
+ }
+ ActiveRule activeRule = new ActiveRule(rule.ruleKey().repository(), rule.ruleKey().rule(), activeDto.getSeverityString(), internalKey, rule.getLanguage());
+
+ // load parameter values
+ for (ActiveRuleParamDto paramDto : paramDtosByActiveRuleId.get(activeDto.getId())) {
+ activeRule.params().put(paramDto.getKey(), paramDto.getValue());
+ }
+
+ // load default values
+ for (RuleParam param : rule.getParams()) {
+ if (!activeRule.params().containsKey(param.getKey())) {
+ activeRule.params().put(param.getKey(), param.getDefaultValue());
+ }
+ }
+
+ ref.addActiveRule(activeRule);
+ }
+ }
+ }
+
return ref;
}
+
+ @CheckForNull
+ private QProfile loadQProfile(Settings settings, String language) {
+ String profileName = settings.getString("sonar.profile." + language);
+ if (profileName != null) {
+ QProfile dto = get(language, profileName);
+ if (dto == null) {
+ throw MessageException.of(String.format("Quality profile not found : '%s' on language '%s'", profileName, language));
+ }
+ return dto;
+ }
+ return null;
+ }
+
+ @CheckForNull
+ private QProfile loadDefaultQProfile(String profileName, String language) {
+ return get(language, profileName);
+ }
+
+ protected Collection<Metric> doFindAll() {
+ return sessionFactory.getSession().getResults(Metric.class, ENABLED, true);
+ }
+
+ public QProfile get(String language, String name) {
+ QualityProfileDto dto = qualityProfileDao.getByNameAndLanguage(name, language);
+ if (dto == null) {
+ return null;
+ }
+ return new org.sonar.batch.protocol.input.QProfile(dto.getKey(), dto.getName(), dto.getLanguage(), UtcDateUtils.parseDateTime(dto.getRulesUpdatedAt()));
+ }
}
*/
package org.sonar.batch.referential;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Languages;
import org.sonar.batch.protocol.input.ProjectReferentials;
public interface ProjectReferentialsLoader {
- ProjectReferentials load(String projectKey);
+ ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages);
+
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 02110-1301, USA.
+ */
+package org.sonar.batch.referential;
+
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Languages;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+
+public class ProjectReferentialsProvider extends ProviderAdapter {
+
+ public ProjectReferentials provide(ProjectReferentialsLoader loader, ProjectReactor reactor, Settings settings, Languages languages) {
+ return loader.load(reactor, settings, languages);
+ }
+}
*/
package org.sonar.batch.rule;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ListMultimap;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.api.batch.rule.internal.NewActiveRule;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.rules.RuleParam;
-import org.sonar.core.qualityprofile.db.ActiveRuleDao;
-import org.sonar.core.qualityprofile.db.ActiveRuleDto;
-import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.batch.protocol.input.ActiveRule;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+
+import java.util.Map.Entry;
/**
* Loads the rules that are activated on the Quality profiles
private ActiveRules singleton = null;
- public ActiveRules provide(ModuleQProfiles qProfiles, ActiveRuleDao dao, RuleFinder ruleFinder) {
+ public ActiveRules provide(ProjectReferentials ref) {
if (singleton == null) {
- singleton = load(qProfiles, dao, ruleFinder);
+ singleton = load(ref);
}
return singleton;
}
- private ActiveRules load(ModuleQProfiles qProfiles, ActiveRuleDao dao, RuleFinder ruleFinder) {
+ private ActiveRules load(ProjectReferentials ref) {
ActiveRulesBuilder builder = new ActiveRulesBuilder();
- for (QProfile qProfile : qProfiles.findAll()) {
- ListMultimap<Integer, ActiveRuleParamDto> paramDtosByActiveRuleId = ArrayListMultimap.create();
- for (ActiveRuleParamDto dto : dao.selectParamsByProfileKey(qProfile.getKey())) {
- paramDtosByActiveRuleId.put(dto.getActiveRuleId(), dto);
- }
-
- for (ActiveRuleDto activeDto : dao.selectByProfileKey(qProfile.getKey())) {
- Rule rule = ruleFinder.findById(activeDto.getRulId());
- if (rule != null) {
- NewActiveRule newActiveRule = builder.create(rule.ruleKey());
- newActiveRule.setSeverity(activeDto.getSeverityString());
- newActiveRule.setLanguage(rule.getLanguage());
- Rule template = rule.getTemplate();
- if (template != null) {
- newActiveRule.setInternalKey(template.getConfigKey());
- } else {
- newActiveRule.setInternalKey(rule.getConfigKey());
- }
+ for (ActiveRule activeRule : ref.activeRules()) {
+ NewActiveRule newActiveRule = builder.create(RuleKey.of(activeRule.repositoryKey(), activeRule.ruleKey()));
+ newActiveRule.setSeverity(activeRule.severity());
+ newActiveRule.setLanguage(activeRule.language());
+ newActiveRule.setInternalKey(activeRule.internalKey());
- // load parameter values
- for (ActiveRuleParamDto paramDto : paramDtosByActiveRuleId.get(activeDto.getId())) {
- newActiveRule.setParam(paramDto.getKey(), paramDto.getValue());
- }
-
- // load default values
- for (RuleParam param : rule.getParams()) {
- if (!newActiveRule.params().containsKey(param.getKey())) {
- newActiveRule.setParam(param.getKey(), param.getDefaultValue());
- }
- }
- newActiveRule.activate();
- }
+ // load parameters
+ for (Entry<String, String> param : activeRule.params().entrySet()) {
+ newActiveRule.setParam(param.getKey(), param.getValue());
}
+
+ newActiveRule.activate();
}
return builder.build();
}
*/
package org.sonar.batch.rule;
-import org.sonar.batch.languages.Language;
-
import com.google.common.collect.ImmutableMap;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchComponent;
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.MessageException;
-import org.sonar.batch.languages.LanguagesReferential;
-import org.sonar.batch.rules.QProfilesReferential;
+import org.sonar.batch.protocol.input.ProjectReferentials;
import javax.annotation.CheckForNull;
public class ModuleQProfiles implements BatchComponent {
public static final String SONAR_PROFILE_PROP = "sonar.profile";
-
private final Map<String, QProfile> byLanguage;
- public ModuleQProfiles(Settings settings, LanguagesReferential languages, QProfilesReferential qProfileRef) {
+ public ModuleQProfiles(ProjectReferentials ref) {
ImmutableMap.Builder<String, QProfile> builder = ImmutableMap.builder();
- String defaultName = settings.getString(SONAR_PROFILE_PROP);
- for (Language language : languages.all()) {
- QProfile profile = null;
- if (StringUtils.isNotBlank(defaultName)) {
- profile = loadDefaultQProfile(qProfileRef, defaultName, language.key());
- }
- if (profile == null) {
- profile = loadQProfile(qProfileRef, settings, language.key());
- }
- if (profile != null) {
- builder.put(profile.getLanguage(), profile);
- }
+ for (org.sonar.batch.protocol.input.QProfile qProfile : ref.qProfiles()) {
+ builder.put(qProfile.language(),
+ new QProfile().setKey(qProfile.key()).setName(qProfile.name()).setLanguage(qProfile.language()).setRulesUpdatedAt(qProfile.rulesUpdatedAt()));
}
byLanguage = builder.build();
}
- @CheckForNull
- private QProfile loadQProfile(QProfilesReferential qProfileRef, Settings settings, String language) {
- String profileName = settings.getString("sonar.profile." + language);
- if (profileName != null) {
- QProfile dto = qProfileRef.get(language, profileName);
- if (dto == null) {
- throw MessageException.of(String.format("Quality profile not found : '%s' on language '%s'", profileName, language));
- }
- return dto;
- }
- return null;
- }
-
- @CheckForNull
- private QProfile loadDefaultQProfile(QProfilesReferential qProfileRef, String profileName, String language) {
- return qProfileRef.get(language, profileName);
- }
-
public Collection<QProfile> findAll() {
return byLanguage.values();
}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.rules;
-
-import org.sonar.batch.rule.QProfile;
-import org.sonar.core.UtcDateUtils;
-import org.sonar.core.qualityprofile.db.QualityProfileDao;
-import org.sonar.core.qualityprofile.db.QualityProfileDto;
-
-/**
- * @since 4.4
- */
-public class DefaultQProfileReferential implements QProfilesReferential {
-
- private QualityProfileDao qualityProfileDao;
-
- public DefaultQProfileReferential(QualityProfileDao qualityProfileDao) {
- this.qualityProfileDao = qualityProfileDao;
- }
-
- @Override
- public QProfile get(String language, String name) {
- QualityProfileDto dto = qualityProfileDao.getByNameAndLanguage(name, language);
- if (dto == null) {
- return null;
- }
- QProfile profile = new QProfile();
- profile.setKey(dto.getKey());
- profile.setName(dto.getName());
- profile.setLanguage(dto.getLanguage());
- profile.setRulesUpdatedAt(UtcDateUtils.parseDateTime(dto.getRulesUpdatedAt()));
- return profile;
- }
-
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.rules;
-
-import org.sonar.batch.rule.QProfile;
-
-import org.sonar.api.BatchComponent;
-
-import javax.annotation.CheckForNull;
-
-/**
- * Quality profiles referential
- * @since 4.4
- */
-public interface QProfilesReferential extends BatchComponent {
-
- /**
- * Get quality profile
- */
- @CheckForNull
- QProfile get(String language, String name);
-
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.rules;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
import org.sonar.batch.bootstrap.MetricProvider;
+import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.components.PeriodsDefinition;
+import org.sonar.batch.debt.DebtModelProvider;
import org.sonar.batch.debt.IssueChangelogDebtCalculator;
import org.sonar.batch.index.Caches;
import org.sonar.batch.index.ComponentDataCache;
import org.sonar.batch.issue.IssueCache;
import org.sonar.batch.issue.IssuePersister;
import org.sonar.batch.issue.ScanIssueStorage;
-import org.sonar.batch.languages.DeprecatedLanguagesReferential;
+import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.phases.GraphPersister;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
-import org.sonar.batch.referential.ProjectReferentialsLoader;
+import org.sonar.batch.referential.ProjectReferentialsProvider;
+import org.sonar.batch.rule.RulesProvider;
import org.sonar.batch.scan.filesystem.InputFileCache;
import org.sonar.batch.scan.maven.FakeMavenPluginExecutor;
import org.sonar.batch.scan.maven.MavenPluginExecutor;
}
add(reactor);
}
- ProjectReferentialsLoader projectReferentialsLoader = getComponentByType(ProjectReferentialsLoader.class);
- add(projectReferentialsLoader.load(reactor.getRoot().getKeyWithBranch()));
-
}
private void addBatchComponents() {
add(
+ new ProjectReferentialsProvider(),
DefaultResourceCreationLock.class,
DefaultPersistenceManager.class,
DependencyPersister.class,
// lang
Languages.class,
- DeprecatedLanguagesReferential.class,
+ DefaultLanguagesReferential.class,
HighlightableBuilder.class,
SymbolizableBuilder.class,
MeasureCache.class,
DeprecatedMetricFinder.class,
DefaultMetricFinder.class,
+ PastMeasuresLoader.class,
+
+ // Rules
+ new RulesProvider(),
+ new DebtModelProvider(),
ProjectSettings.class);
}
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.rule.Rules;
import org.sonar.api.config.Settings;
import org.sonar.batch.issue.IssueFilters;
import org.sonar.batch.scan.AnalyzerContextAdaptor;
private final FileSystem fs;
private final ActiveRules activeRules;
private final IssueFilters issueFilters;
- private final Rules rules;
public DefaultAnalyzerContext(ProjectDefinition def, AnalyzerMeasureCache measureCache, AnalyzerIssueCache issueCache,
- Settings settings, FileSystem fs, ActiveRules activeRules, IssueFilters issueFilters, Rules rules) {
+ Settings settings, FileSystem fs, ActiveRules activeRules, IssueFilters issueFilters) {
this.def = def;
this.measureCache = measureCache;
this.issueCache = issueCache;
this.fs = fs;
this.activeRules = activeRules;
this.issueFilters = issueFilters;
- this.rules = rules;
}
@Override
import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer;
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader;
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsRegexpScanner;
+import org.sonar.batch.rule.ActiveRulesProvider;
import org.sonar.batch.rule.ModuleQProfiles;
import org.sonar.batch.rule.QProfileVerifier;
import org.sonar.batch.scan.LanguageVerifier;
// rules
ModuleQProfiles.class,
+ new ActiveRulesProvider(),
CheckFactory.class,
// issues
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ComponentContainer;
+import org.sonar.api.resources.Languages;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.ExtensionMatcher;
import org.sonar.batch.bootstrap.ExtensionUtils;
import org.sonar.batch.index.Caches;
+import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
+import org.sonar.batch.referential.DefaultProjectReferentialsLoader;
import org.sonar.batch.referential.ProjectReferentialsLoader;
+import org.sonar.batch.referential.ProjectReferentialsProvider;
import org.sonar.batch.scan.ProjectReactorBuilder;
import org.sonar.batch.scan.ProjectSettings;
import org.sonar.batch.scan.filesystem.InputFileCache;
throw new IllegalStateException(bootstrapper + " has returned null as ProjectReactor");
}
add(reactor);
- ProjectReferentialsLoader projectReferentialsLoader = getComponentByType(ProjectReferentialsLoader.class);
- add(projectReferentialsLoader.load(reactor.getRoot().getKeyWithBranch()));
+ if (getComponentByType(ProjectReferentialsLoader.class) == null) {
+ add(DefaultProjectReferentialsLoader.class);
+ }
}
private void addBatchComponents() {
add(
+ new ProjectReferentialsProvider(),
ProjectSettings.class,
Caches.class,
+ // lang
+ Languages.class,
+ DefaultLanguagesReferential.class,
+
// Measures
DefaultMetricFinder.class,
AnalyzerMeasureCache.class,
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.MessageException;
import org.sonar.batch.mediumtest.AnalyzerMediumTester;
import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult;
import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin;
-import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo;
+import org.sonar.batch.protocol.input.ActiveRule;
import java.io.File;
import java.io.IOException;
public AnalyzerMediumTester tester = AnalyzerMediumTester.builder()
.registerPlugin("xoo", new XooPlugin())
- .registerLanguage(new Xoo())
.addDefaultQProfile("xoo", "Sonar Way")
- .activateRule(RuleKey.of("xoo", "OneIssuePerLine"))
+ .activateRule(new ActiveRule("xoo", "OneIssuePerLine", "MAJOR", "xoo", "xoo"))
.bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor"))
.build();
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.rule.RuleKey;
import org.sonar.batch.mediumtest.AnalyzerMediumTester;
import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult;
import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin;
-import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo;
+import org.sonar.batch.protocol.input.ActiveRule;
import java.io.File;
import java.io.IOException;
public AnalyzerMediumTester tester = AnalyzerMediumTester.builder()
.registerPlugin("xoo", new XooPlugin())
- .registerLanguage(new Xoo())
.addDefaultQProfile("xoo", "Sonar Way")
- .activateRule(RuleKey.of("xoo", "OneIssuePerLine"))
+ .activateRule(new ActiveRule("xoo", "OneIssuePerLine", "MAJOR", "xoo", "xoo"))
.bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor"))
.build();
import org.sonar.batch.mediumtest.AnalyzerMediumTester;
import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult;
import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin;
-import org.sonar.batch.mediumtest.xoo.plugin.base.Xoo;
import java.io.File;
import java.io.IOException;
public AnalyzerMediumTester tester = AnalyzerMediumTester.builder()
.registerPlugin("xoo", new XooPlugin())
- .registerLanguage(new Xoo())
.addDefaultQProfile("xoo", "Sonar Way")
.bootstrapProperties(ImmutableMap.of("sonar.analysis.mode", "sensor"))
.build();
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.rule.ActiveRule;
-import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-import org.sonar.core.qualityprofile.db.ActiveRuleDao;
-
-import java.util.Arrays;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ActiveRulesProviderTest extends AbstractDaoTestCase {
-
- ModuleQProfiles qProfiles = mock(ModuleQProfiles.class);
- RuleFinder ruleFinder = mock(RuleFinder.class);
-
- @Before
- public void init_rules() {
- Rule squidRule = new Rule().setRepositoryKey("squid").setKey("S0001");
- squidRule.createParameter("min").setDefaultValue("12");
- when(ruleFinder.findById(10)).thenReturn(squidRule);
- when(ruleFinder.findById(100)).thenReturn(new Rule().setRepositoryKey("phpunit").setKey("P1"));
- }
-
- @Test
- public void build_active_rules() throws Exception {
- setupData("shared");
- when(qProfiles.findAll()).thenReturn(Arrays.asList(
- // 1 rule is enabled on java with severity INFO
- new QProfile().setKey("java-two").setName("Java Two").setLanguage("java"),
- // 1 rule is enabled on php with severity BLOCKER
- new QProfile().setKey("php-one").setName("Php One").setLanguage("php")
- ));
-
- ActiveRulesProvider provider = new ActiveRulesProvider();
- ActiveRuleDao activeRuleDao = new ActiveRuleDao(getMyBatis());
- ActiveRules activeRules = provider.provide(qProfiles, activeRuleDao, ruleFinder);
-
- assertThat(activeRules.findAll()).hasSize(2);
- assertThat(activeRules.findByRepository("squid")).hasSize(1);
- assertThat(activeRules.findByRepository("phpunit")).hasSize(1);
- assertThat(activeRules.findByRepository("unknown")).isEmpty();
- ActiveRule squidRule = activeRules.find(RuleKey.of("squid", "S0001"));
- assertThat(squidRule.severity()).isEqualTo(Severity.INFO);
- assertThat(squidRule.internalKey()).isNull();
- // "max" and "format" parameters are set in db, "min" is not set but has a default value
- assertThat(squidRule.params()).hasSize(3);
- assertThat(squidRule.param("min")).isEqualTo("12");
- assertThat(squidRule.param("max")).isEqualTo("20");
- assertThat(squidRule.param("format")).isEqualTo("html");
-
- ActiveRule phpRule = activeRules.find(RuleKey.of("phpunit", "P1"));
- assertThat(phpRule.severity()).isEqualTo(Severity.BLOCKER);
- assertThat(phpRule.params()).isEmpty();
- }
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.batch.rule;
-
-import com.google.common.collect.Lists;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Languages;
-import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.System2;
-import org.sonar.batch.languages.DeprecatedLanguagesReferential;
-import org.sonar.batch.languages.LanguagesReferential;
-import org.sonar.batch.rules.DefaultQProfileReferential;
-import org.sonar.batch.rules.QProfilesReferential;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-import org.sonar.core.qualityprofile.db.QualityProfileDao;
-
-import java.util.List;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ModuleQProfilesTest extends AbstractDaoTestCase {
-
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new SimpleLanguage("java"), new SimpleLanguage("php")));
- Settings settings = new Settings();
-
- @Test
- public void find_profiles() throws Exception {
- // 4 profiles in db
- setupData("shared");
- QualityProfileDao dao = new QualityProfileDao(getMyBatis(), System2.INSTANCE);
- QProfilesReferential ref = new DefaultQProfileReferential(dao);
-
- settings.setProperty("sonar.profile.java", "Java One");
- settings.setProperty("sonar.profile.abap", "Abap One");
- settings.setProperty("sonar.profile.php", "Php One");
-
- ModuleQProfiles moduleQProfiles = new ModuleQProfiles(settings, languages, ref);
- List<QProfile> qProfiles = Lists.newArrayList(moduleQProfiles.findAll());
-
- // load only the profiles of languages detected in project
- assertThat(qProfiles).hasSize(2);
- assertThat(moduleQProfiles.findByLanguage("java")).isNotNull();
- assertThat(moduleQProfiles.findByLanguage("php")).isNotNull();
- assertThat(moduleQProfiles.findByLanguage("abap")).isNull();
- QProfile javaProfile = qProfiles.get(0);
- assertThat(javaProfile.getKey()).isEqualTo("java-one");
- assertThat(javaProfile.getName()).isEqualTo("Java One");
- assertThat(javaProfile.getLanguage()).isEqualTo("java");
- QProfile phpProfile = qProfiles.get(1);
- assertThat(phpProfile.getKey()).isEqualTo("php-one");
- assertThat(phpProfile.getName()).isEqualTo("Php One");
- assertThat(phpProfile.getLanguage()).isEqualTo("php");
- }
-
- @Test
- public void supported_deprecated_property() throws Exception {
- setupData("shared");
- QualityProfileDao dao = new QualityProfileDao(getMyBatis(), System2.INSTANCE);
- QProfilesReferential ref = new DefaultQProfileReferential(dao);
-
- // deprecated property
- settings.setProperty("sonar.profile", "Java Two");
- settings.setProperty("sonar.profile.php", "Php One");
-
- ModuleQProfiles moduleQProfiles = new ModuleQProfiles(settings, languages, ref);
- List<QProfile> qProfiles = Lists.newArrayList(moduleQProfiles.findAll());
-
- assertThat(qProfiles).hasSize(2);
- QProfile javaProfile = qProfiles.get(0);
- assertThat(javaProfile.getKey()).isEqualTo("java-two");
- assertThat(javaProfile.getName()).isEqualTo("Java Two");
- assertThat(javaProfile.getLanguage()).isEqualTo("java");
-
- // "Java Two" does not exist for PHP -> fallback to sonar.profile.php
- QProfile phpProfile = qProfiles.get(1);
- assertThat(phpProfile.getKey()).isEqualTo("php-one");
- assertThat(phpProfile.getName()).isEqualTo("Php One");
- assertThat(phpProfile.getLanguage()).isEqualTo("php");
- }
-
- @Test
- public void fail_if_unknown_profile() throws Exception {
- setupData("shared");
- QualityProfileDao dao = new QualityProfileDao(getMyBatis(), System2.INSTANCE);
- QProfilesReferential ref = new DefaultQProfileReferential(dao);
-
- settings.setProperty("sonar.profile.java", "Unknown");
- settings.setProperty("sonar.profile.php", "Php One");
-
- try {
- new ModuleQProfiles(settings, languages, ref);
- fail();
- } catch (MessageException e) {
- assertThat(e).hasMessage("Quality profile not found : 'Unknown' on language 'java'");
- }
- }
-
- private static class SimpleLanguage implements Language {
-
- private final String key;
-
- private SimpleLanguage(String key) {
- this.key = key;
- }
-
- @Override
- public String getKey() {
- return key;
- }
-
- @Override
- public String getName() {
- return key;
- }
-
- @Override
- public String[] getFileSuffixes() {
- return new String[0];
- }
- }
-}
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
import org.sonar.api.utils.MessageException;
-import org.sonar.batch.languages.DeprecatedLanguagesReferential;
+import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.languages.LanguagesReferential;
import static org.fest.assertions.Assertions.assertThat;
public class LanguageVerifierTest {
Settings settings = new Settings();
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(Java.INSTANCE));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(Java.INSTANCE));
DefaultFileSystem fs = new DefaultFileSystem();
@Rule
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ComponentContainer;
+import org.sonar.api.resources.Languages;
import org.sonar.api.task.TaskExtension;
import org.sonar.api.utils.System2;
import org.sonar.batch.bootstrap.AnalysisMode;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.GlobalSettings;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
+import org.sonar.batch.protocol.input.ProjectReferentials;
+import org.sonar.batch.referential.ProjectReferentialsLoader;
import org.sonar.batch.scan.maven.MavenPluginExecutor;
import org.sonar.batch.settings.SettingsReferential;
bootstrapProperties = new BootstrapProperties(Collections.<String, String>emptyMap());
AnalysisMode analysisMode = new AnalysisMode(bootstrapProperties);
when(projectBootstrapper.bootstrap()).thenReturn(new ProjectReactor(ProjectDefinition.create()));
- settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), mock(SettingsReferential.class), new PropertiesConfiguration(), analysisMode);
parentContainer = new ComponentContainer();
- parentContainer.add(settings);
parentContainer.add(System2.INSTANCE);
parentContainer.add(bootstrapProperties);
parentContainer.add(analysisMode);
parentContainer.add(new PropertiesConfiguration());
- parentContainer.add(mock(SettingsReferential.class));
+ SettingsReferential settingsReferential = mock(SettingsReferential.class);
+ settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), settingsReferential, new PropertiesConfiguration(), analysisMode);
+ parentContainer.add(settings);
+ parentContainer.add(settingsReferential);
+ ProjectReferentialsLoader projectReferentialsLoader = new ProjectReferentialsLoader() {
+ @Override
+ public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) {
+ return new ProjectReferentials();
+ }
+ };
+ parentContainer.add(projectReferentialsLoader);
container = new ProjectScanContainer(parentContainer);
}
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
-import org.sonar.batch.languages.DeprecatedLanguagesReferential;
+import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.languages.LanguagesReferential;
import static org.fest.assertions.Assertions.assertThat;
public class LanguageDetectionFactoryTest {
@Test
public void testCreate() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(Java.INSTANCE));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(Java.INSTANCE));
LanguageDetectionFactory factory = new LanguageDetectionFactory(new Settings(), languages);
LanguageDetection languageDetection = factory.create();
assertThat(languageDetection).isNotNull();
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.utils.MessageException;
-import org.sonar.batch.languages.DeprecatedLanguagesReferential;
+import org.sonar.batch.languages.DefaultLanguagesReferential;
import org.sonar.batch.languages.LanguagesReferential;
import java.io.File;
@Test
public void search_by_file_extension() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("java", "java", "jav"), new MockLanguage("cobol", "cbl", "cob")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java", "jav"), new MockLanguage("cobol", "cbl", "cob")));
LanguageDetection detection = new LanguageDetection(new Settings(), languages);
assertThat(detection.language(newInputFile("Foo.java"))).isEqualTo("java");
@Test
public void should_not_fail_if_no_language() throws Exception {
- LanguageDetection detection = spy(new LanguageDetection(new Settings(), new DeprecatedLanguagesReferential(new Languages())));
+ LanguageDetection detection = spy(new LanguageDetection(new Settings(), new DefaultLanguagesReferential(new Languages())));
assertThat(detection.language(newInputFile("Foo.java"))).isNull();
}
@Test
public void plugin_can_declare_a_file_extension_twice_for_case_sensitivity() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("abap", "abap", "ABAP")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("abap", "abap", "ABAP")));
LanguageDetection detection = new LanguageDetection(new Settings(), languages);
assertThat(detection.language(newInputFile("abc.abap"))).isEqualTo("abap");
public void language_with_no_extension() throws Exception {
// abap does not declare any file extensions.
// When analyzing an ABAP project, then all source files must be parsed.
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
// No side-effect on non-ABAP projects
LanguageDetection detection = new LanguageDetection(new Settings(), languages);
@Test
public void force_language_using_deprecated_property() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
Settings settings = new Settings();
settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
thrown.expect(MessageException.class);
thrown.expectMessage("No language is installed with key 'unknown'. Please update property 'sonar.language'");
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
Settings settings = new Settings();
settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
new LanguageDetection(settings, languages);
@Test
public void fail_if_conflicting_language_suffix() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
LanguageDetection detection = new LanguageDetection(new Settings(), languages);
try {
detection.language(newInputFile("abc.xhtml"));
@Test
public void solve_conflict_using_filepattern() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
Settings settings = new Settings();
settings.setProperty("sonar.lang.patterns.xml", "xml/**");
@Test
public void fail_if_conflicting_filepattern() throws Exception {
- LanguagesReferential languages = new DeprecatedLanguagesReferential(new Languages(new MockLanguage("abap", "abap"), new MockLanguage("cobol", "cobol")));
+ LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("abap", "abap"), new MockLanguage("cobol", "cobol")));
Settings settings = new Settings();
settings.setProperty("sonar.lang.patterns.abap", "*.abap,*.txt");
settings.setProperty("sonar.lang.patterns.cobol", "*.cobol,*.txt");
return this;
}
- public Integer getRulId() {
+ public Integer getRuleId() {
return ruleId;
}
import java.util.HashMap;
import java.util.Map;
+/**
+ * @deprecated since 4.5
+ */
+@Deprecated
public final class CacheRuleFinder implements RuleFinder {
private BiMap<Integer, Rule> rulesById = HashBiMap.create();
*/
package org.sonar.api.batch.rule;
-import com.google.common.annotations.Beta;
import org.sonar.api.rule.RuleKey;
import javax.annotation.CheckForNull;
/**
* @since 4.2
+ * @deprecated since 4.5 use {@link ActiveRules}
*/
-@Beta
+@Deprecated
public interface Rules {
@CheckForNull