import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
-import org.codehaus.plexus.util.StringUtils;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
-import javax.annotation.CheckForNull;
-
/**
* Loads the rules that are activated on the Quality profiles
* used by the current module and build {@link org.sonar.api.batch.rule.ActiveRules}.
}
return builder.build();
}
-
- @CheckForNull
- private String defaultParamValue(Rule rule, String paramKey) {
- RuleParam param = rule.getParam(paramKey);
- return param != null ? param.getDefaultValue() : null;
- }
}
return detectedLanguage;
}
- // Check if deprecated sonar.language is used and we are on a language without declared extensions
- if (forcedLanguage != null) {
- // Languages without declared suffixes match everything
- if (patternsByLanguage.get(forcedLanguage).length == 0) {
- return forcedLanguage;
- }
+ // Check if deprecated sonar.language is used and we are on a language without declared extensions.
+ // Languages without declared suffixes match everything.
+ if (forcedLanguage != null && patternsByLanguage.get(forcedLanguage).length == 0) {
+ return forcedLanguage;
}
return null;
}
package org.sonar.batch.scan.filesystem;
import com.google.common.collect.Maps;
-import org.picocontainer.Startable;
import org.sonar.api.BatchComponent;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.utils.KeyValueFormat;
import org.sonar.core.source.db.SnapshotDataDao;
import org.sonar.core.source.db.SnapshotDataDto;
-import javax.annotation.CheckForNull;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
*/
package org.sonar.core.persistence.dialect;
-import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.hibernate.dialect.Oracle10gDialect;
import org.sonar.api.database.DatabaseProperties;
import java.sql.Types;
-import java.util.List;
/**
* @since 1.12
*/
public class JsonWriter {
- public static JsonWriter of(Writer writer) {
- return new JsonWriter(writer);
- }
-
private final com.google.gson.stream.JsonWriter stream;
private JsonWriter(Writer writer) {
this.stream = stream;
}
+ public static JsonWriter of(Writer writer) {
+ return new JsonWriter(writer);
+ }
+
/**
* Begins encoding a new array. Each call to this method must be paired with
* a call to {@link #endArray}. Output is <code>[</code>.
*/
public class XmlWriter {
- public static XmlWriter of(Writer writer) {
- return new XmlWriter(writer);
- }
-
private final XMLStreamWriter stream;
private XmlWriter(Writer writer) {
}
}
+ public static XmlWriter of(Writer writer) {
+ return new XmlWriter(writer);
+ }
+
public XmlWriter declaration() {
try {
stream.writeStartDocument();
class ClassLoaderUtils {
private ClassLoaderUtils() {
- }
-
- static File copyResources(ClassLoader classLoader, String rootPath, File toDir) {
- return copyResources(classLoader, rootPath, toDir, Functions.<String>identity());
+ // only static methods
}
static File copyResources(ClassLoader classLoader, String rootPath, File toDir, Function<String, String> relocationFunction) {
});
}
-
- static Collection<String> listResources(ClassLoader classLoader, String rootPath) {
- return listResources(classLoader, rootPath, Predicates.<String>alwaysTrue());
- }
-
/**
* Finds directories and files within a given directory and its subdirectories.
*
* @param classLoader
* @param rootPath the root directory, for example org/sonar/sqale, or a file in this root directory, for example org/sonar/sqale/index.txt
- * @param
+ * @param predicate
* @return a list of relative paths, for example {"org/sonar/sqale", "org/sonar/sqale/foo", "org/sonar/sqale/foo/bar.txt}. Never null.
*/
static Collection<String> listResources(ClassLoader classLoader, String rootPath, Predicate<String> predicate) {
JarFile jar = null;
try {
Collection<String> paths = Lists.newArrayList();
- rootPath = StringUtils.removeStart(rootPath, "/");
-
URL root = classLoader.getResource(rootPath);
if (root != null) {
checkJarFile(root);
/* PROFILES CONSOLE : RULES AND METRIC THRESHOLDS */
+ /**
+ * @deprecated in 4.2
+ */
@Deprecated
@CheckForNull
public RuleRepositories.Repository getRuleRepository(String repositoryKey) {
package org.sonar.server.platform;
import com.google.common.base.Function;
+import com.google.common.base.Functions;
import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.server.platform.ClassLoaderUtils;
import javax.annotation.Nullable;
import java.io.File;
@Test
public void listResources_unknown_root() {
- Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "unknown/directory");
+ Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "unknown/directory", Predicates.<String>alwaysTrue());
assertThat(strings.size(), Is.is(0));
}
@Test
public void listResources_all() {
- Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "org/sonar/sqale");
- assertThat(strings, hasItems(
- "org/sonar/sqale/",
- "org/sonar/sqale/app/",
- "org/sonar/sqale/app/copyright.txt",
- "org/sonar/sqale/app/README.md"));
- assertThat(strings.size(), Is.is(4));
- }
-
- @Test
- public void listResources_root_path_starts_with_slash() {
- Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "/org/sonar/sqale");
+ Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "org/sonar/sqale", Predicates.<String>alwaysTrue());
assertThat(strings, hasItems(
"org/sonar/sqale/",
"org/sonar/sqale/app/",
@Test
public void copyRubyRailsApp() {
File toDir = temp.newFolder("dest");
- ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir);
+ ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, Functions.<String>identity());
assertThat(FileUtils.listFiles(toDir, null, true).size(), Is.is(2));
assertThat(new File(toDir, "org/sonar/sqale/app/copyright.txt").exists(), Is.is(true));