public class RulesProfileWrapper extends RulesProfile {
private static final Logger LOG = LoggerFactory.getLogger(RulesProfileWrapper.class);
+ private static final String DEPRECATED_USAGE_MESSAGE = "Please update your plugin to support multi-language analysis";
private final Collection<RulesProfile> profiles;
private final RulesProfile singleLanguageProfile;
private RulesProfile getSingleProfileOrFail() {
if (singleLanguageProfile == null) {
- throw new IllegalStateException("Please update your plugin to support multi-language analysis");
+ throw new IllegalStateException(DEPRECATED_USAGE_MESSAGE);
}
return singleLanguageProfile;
}
public String getLanguage() {
if (singleLanguageProfile == null) {
// Multi-languages module
- // FIXME This is a hack for CommonChecksDecorator that call this method in its constructor
- LOG.debug("Please update your plugin to support multi-language analysis", new SonarException("Please update your plugin to support multi-language analysis"));
+ // This is a hack for CommonChecksDecorator that call this method in its constructor
+ LOG.debug(DEPRECATED_USAGE_MESSAGE, new SonarException(DEPRECATED_USAGE_MESSAGE));
return "";
}
return singleLanguageProfile.getLanguage();
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.io.File;
import java.nio.charset.Charset;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Index input files into {@link InputFileCache}.
}
private String computeFilePath(DefaultModuleFileSystem fileSystem, File file) {
- String path = pathResolver.relativePath(fileSystem.baseDir(), file);
- return path;
+ return pathResolver.relativePath(fileSystem.baseDir(), file);
}
@CheckForNull
}
@Override
- protected synchronized Class<?> loadClass(String s, boolean b) throws ClassNotFoundException {
+ protected synchronized Class loadClass(String s, boolean b) throws ClassNotFoundException {
throw new UnsupportedOperationException("I18n classloader does support only resources, but not classes");
}
if (issue.isNew()) {
insert(issueMapper, now, issue);
insertChanges(issueChangeMapper, issue);
- if (count++ > BatchSession.MAX_BATCH_SIZE) {
+ if (count > BatchSession.MAX_BATCH_SIZE) {
batchSession.commit();
}
+ count++;
} else if (issue.isChanged()) {
toBeUpdated.add(issue);
}
}
@SuppressWarnings("unchecked")
- public static List<Class<?>> getDaoClasses() {
- return ImmutableList.of(
+ public static List<Class> getDaoClasses() {
+ return ImmutableList.<Class>of(
ActionPlanDao.class,
ActionPlanStatsDao.class,
ActiveDashboardDao.class,
import org.sonar.core.persistence.MyBatis;
import javax.annotation.CheckForNull;
-
import java.util.Collection;
import java.util.List;
return getMapper(session).selectNonManual();
}
+ @CheckForNull
public RuleDto selectById(Integer id, SqlSession session) {
return getMapper(session).selectById(id);
}
-
+ @CheckForNull
public RuleDto selectById(Integer id) {
SqlSession session = mybatis.openSession();
try {
}
}
+ @CheckForNull
public RuleDto selectByName(String name) {
SqlSession session = mybatis.openSession();
try {
@CheckForNull
public String selectSnapshotSourceByComponentKey(String componentKey, SqlSession session) {
- SnapshotSourceMapper mapper = session.getMapper(SnapshotSourceMapper.class);
- return mapper.selectSnapshotSourceByComponentKey(componentKey);
+ SnapshotSourceMapper mapper = session.getMapper(SnapshotSourceMapper.class);
+ return mapper.selectSnapshotSourceByComponentKey(componentKey);
}
- @CheckForNull
+ @CheckForNull
public String selectSnapshotSourceByComponentKey(String componentKey) {
SqlSession session = mybatis.openSession();
try {
public class DaoUtilsTest {
@Test
- public void should_list_all_dao_classes() {
- List<Class<?>> daoClasses = DaoUtils.getDaoClasses();
+ public void list_all_dao_classes() {
+ List<Class> daoClasses = DaoUtils.getDaoClasses();
assertThat(daoClasses).isNotEmpty();
}
import org.sonar.api.rules.RulePriority;
import javax.persistence.*;
-
import java.util.ArrayList;
import java.util.List;
/**
* This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.
- * @deprecated since 4.2. Replaced by {@link org.sonar.api.batch.rule.ModuleRules} for batch extensions.
*/
@Entity
@Table(name = "rules_profiles")
-@Deprecated
public class RulesProfile implements Cloneable {
/**
writer.prop("path", controller.path());
writer.prop("since", controller.since());
writer.prop("description", controller.description());
- if (!controller.actions().isEmpty()) {
- // sort actions by key
- Ordering<Action> ordering = Ordering.natural().onResultOf(new Function<Action, String>() {
- public String apply(Action action) {
- return action.key();
- }
- });
- writer.name("actions").beginArray();
- for (Action action : ordering.sortedCopy(controller.actions())) {
- write(writer, action);
+ // sort actions by key
+ Ordering<Action> ordering = Ordering.natural().onResultOf(new Function<Action, String>() {
+ public String apply(Action action) {
+ return action.key();
}
- writer.endArray();
+ });
+ writer.name("actions").beginArray();
+ for (Action action : ordering.sortedCopy(controller.actions())) {
+ write(writer, action);
}
+ writer.endArray();
writer.endObject();
}