package org.sonar.server.db;
import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang.StringUtils;
import org.picocontainer.Startable;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
import org.sonar.server.qualityprofile.ActiveRule;
import org.sonar.server.search.BaseDoc;
+import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_CREATED_AT;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_KEY;
public ActiveRule.Inheritance inheritance() {
String inheritance = getNullableField(FIELD_ACTIVE_RULE_INHERITANCE);
if (inheritance == null || inheritance.isEmpty() ||
- inheritance.toLowerCase().contains("none")) {
+ containsIgnoreCase(inheritance, "none")) {
return Inheritance.NONE;
- } else if (inheritance.toLowerCase().contains("herit")) {
+ } else if (containsIgnoreCase(inheritance, "herit")) {
return Inheritance.INHERITED;
- } else if (inheritance.toLowerCase().contains("over")) {
+ } else if (containsIgnoreCase(inheritance, "over")) {
return Inheritance.OVERRIDES;
} else {
throw new IllegalStateException("Value \"" + inheritance + "\" is not valid for rule's inheritance");
int major = 0;
int minor = 0;
int patch = 0;
- if (split.size() > 0) {
+ int size = split.size();
+ if (size > 0) {
major = parseSequence(split.get(0));
- if (split.size() > 1) {
+ if (size > 1) {
minor = parseSequence(split.get(1));
- if (split.size() > 2) {
+ if (size > 2) {
patch = parseSequence(split.get(2));
- if (split.size() > 3) {
+ if (size > 3) {
throw new IllegalArgumentException("Only 3 sequences are accepted");
}
}
package org.sonar.batch.profiling;
import com.google.common.collect.Maps;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
public class ModuleProfiling extends AbstractTimeProfiling {
- private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<>();
+ private Map<Phase, PhaseProfiling> profilingPerPhase = new EnumMap<>(Phase.class);
private Map<String, ItemProfiling> profilingPerBatchStep = new LinkedHashMap<>();
private final Project module;
return ResourceUtils.isProject(r) ? r.getDescription() : null;
}
- private ComponentType getType(Resource r) {
+ private static ComponentType getType(Resource r) {
if (ResourceUtils.isFile(r)) {
return ComponentType.FILE;
} else if (ResourceUtils.isDirectory(r)) {
private static RulesProfile select(QProfile qProfile, ActiveRules activeRules) {
RulesProfile deprecatedProfile = new RulesProfile();
- // TODO deprecatedProfile.setVersion(qProfile.version());
deprecatedProfile.setName(qProfile.getName());
deprecatedProfile.setLanguage(qProfile.getLanguage());
for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules.findByLanguage(qProfile.getLanguage())) {
return mainInclusions.length > 0 || mainExclusions.length > 0 || testInclusions.length > 0 || testExclusions.length > 0;
}
- private void log(String title, PathPattern[] patterns) {
+ private static void log(String title, PathPattern[] patterns) {
if (patterns.length > 0) {
LOG.info(title);
for (PathPattern pattern : patterns) {
*/
package org.sonar.batch.scan.filesystem;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
public class AdditionalFilePredicatesTest {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
@Test
public void key() {
FilePredicate predicate = new AdditionalFilePredicates.KeyPredicate("struts:Action.java");