@@ -20,9 +20,10 @@ | |||
package org.sonar.batch.bootstrapper; | |||
import com.google.common.base.Throwables; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Maps; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.Nullable; | |||
@@ -39,11 +40,11 @@ public final class Batch { | |||
private boolean started = false; | |||
private LoggingConfiguration loggingConfig; | |||
private List<Object> components; | |||
private Map<String, String> bootstrapProperties = Maps.newHashMap(); | |||
private Map<String, String> bootstrapProperties = new HashMap<>(); | |||
private GlobalContainer bootstrapContainer; | |||
private Batch(Builder builder) { | |||
components = Lists.newArrayList(); | |||
components = new ArrayList<>(); | |||
components.addAll(builder.components); | |||
if (builder.environment != null) { | |||
components.add(builder.environment); | |||
@@ -203,7 +204,7 @@ public final class Batch { | |||
public static final class Builder { | |||
private Map<String, String> bootstrapProperties; | |||
private EnvironmentInformation environment; | |||
private List<Object> components = Lists.newArrayList(); | |||
private List<Object> components = new ArrayList<>(); | |||
private boolean enableLoggingConfiguration = true; | |||
private LogOutput logOutput; | |||
@@ -20,7 +20,8 @@ | |||
package org.sonar.batch.bootstrapper; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Maps; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
@@ -48,7 +49,7 @@ public final class LoggingConfiguration { | |||
@VisibleForTesting | |||
static final String FORMAT_MAVEN = "[%level] [%d{HH:mm:ss.SSS}] %msg%n"; | |||
private Map<String, String> substitutionVariables = Maps.newHashMap(); | |||
private Map<String, String> substitutionVariables = new HashMap<>(); | |||
private LogOutput logOutput = null; | |||
private boolean verbose; | |||
@@ -19,9 +19,6 @@ | |||
*/ | |||
package org.sonar.scanner.bootstrap; | |||
import com.google.common.base.Predicates; | |||
import com.google.common.collect.Collections2; | |||
import com.google.common.collect.Lists; | |||
import java.lang.annotation.Annotation; | |||
import java.lang.reflect.Array; | |||
import java.lang.reflect.Method; | |||
@@ -30,6 +27,8 @@ import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.ClassUtils; | |||
import org.sonar.api.batch.CheckProject; | |||
@@ -94,7 +93,7 @@ public class ScannerExtensionDictionnary { | |||
} | |||
private <T> List<T> getFilteredExtensions(Class<T> type, @Nullable DefaultInputModule module, @Nullable ExtensionMatcher matcher) { | |||
List<T> result = Lists.newArrayList(); | |||
List<T> result = new ArrayList<>(); | |||
for (Object extension : getExtensions(type)) { | |||
if (org.sonar.api.batch.Sensor.class.equals(type) && extension instanceof Sensor) { | |||
extension = new SensorWrapper((Sensor) extension, sensorContext, sensorOptimizer); | |||
@@ -125,7 +124,7 @@ public class ScannerExtensionDictionnary { | |||
} | |||
protected <T> List<T> getExtensions(Class<T> type) { | |||
List<T> extensions = Lists.newArrayList(); | |||
List<T> extensions = new ArrayList<>(); | |||
completeBatchExtensions(componentContainer, extensions, type); | |||
return extensions; | |||
} | |||
@@ -153,7 +152,9 @@ public class ScannerExtensionDictionnary { | |||
} | |||
List<?> sortedList = dag.sort(); | |||
return (Collection<T>) Collections2.filter(sortedList, Predicates.in(extensions)); | |||
return (Collection<T>) sortedList.stream() | |||
.filter(extensions::contains) | |||
.collect(Collectors.toList()); | |||
} | |||
/** | |||
@@ -187,7 +188,7 @@ public class ScannerExtensionDictionnary { | |||
} | |||
protected List<Object> evaluateAnnotatedClasses(Object extension, Class<? extends Annotation> annotation) { | |||
List<Object> results = Lists.newArrayList(); | |||
List<Object> results = new ArrayList<>(); | |||
Class<? extends Object> aClass = extension.getClass(); | |||
while (aClass != null) { | |||
evaluateClass(aClass, annotation, results); |
@@ -20,11 +20,11 @@ | |||
package org.sonar.scanner.bootstrap; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.Reader; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
@@ -71,7 +71,7 @@ public class ScannerPluginInstaller implements PluginInstaller { | |||
} | |||
private Map<String, PluginInfo> loadPlugins(List<RemotePlugin> remotePlugins) { | |||
Map<String, PluginInfo> infosByKey = new HashMap<>(); | |||
Map<String, PluginInfo> infosByKey = new HashMap<>(remotePlugins.size()); | |||
Profiler profiler = Profiler.create(LOG).startDebug("Load plugins"); | |||
@@ -114,7 +114,7 @@ public class ScannerPluginInstaller implements PluginInstaller { | |||
try { | |||
String pluginIndex = loadPluginIndex(); | |||
String[] rows = StringUtils.split(pluginIndex, CharUtils.LF); | |||
List<RemotePlugin> result = Lists.newArrayList(); | |||
List<RemotePlugin> result = new ArrayList<>(); | |||
for (String row : rows) { | |||
result.add(RemotePlugin.unmarshal(row)); | |||
} | |||
@@ -131,10 +131,10 @@ public class ScannerPluginInstaller implements PluginInstaller { | |||
String str; | |||
try (Reader reader = wsClient.call(getRequest).contentReader()) { | |||
str = IOUtils.toString(reader); | |||
} catch(IOException e) { | |||
} catch (IOException e) { | |||
throw new IllegalStateException(e); | |||
} | |||
profiler.stopInfo(); | |||
return str; | |||
} |
@@ -22,10 +22,11 @@ package org.sonar.scanner.bootstrap; | |||
import com.google.common.base.Joiner; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.base.Splitter; | |||
import com.google.common.collect.Lists; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.StreamSupport; | |||
import javax.annotation.Nonnull; | |||
@@ -93,6 +94,7 @@ public class ScannerPluginPredicate implements Predicate<String> { | |||
private static List<String> propertyValues(Settings settings, String key, String defaultValue) { | |||
String s = StringUtils.defaultIfEmpty(settings.getString(key), defaultValue); | |||
return Lists.newArrayList(Splitter.on(",").trimResults().omitEmptyStrings().split(s)); | |||
return StreamSupport.stream(Splitter.on(",").trimResults().omitEmptyStrings().split(s).spliterator(), false) | |||
.collect(Collectors.toList()); | |||
} | |||
} |
@@ -19,11 +19,11 @@ | |||
*/ | |||
package org.sonar.scanner.bootstrap; | |||
import com.google.common.collect.Maps; | |||
import org.sonar.api.config.Encryption; | |||
import javax.annotation.Nullable; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
@@ -36,7 +36,7 @@ public abstract class UserProperties { | |||
public UserProperties(Map<String, String> properties, @Nullable String pathToSecretKey) { | |||
encryption = new Encryption(pathToSecretKey); | |||
Map<String, String> decryptedProps = Maps.newHashMap(); | |||
Map<String, String> decryptedProps = new HashMap<>(properties.size()); | |||
for (Map.Entry<String, String> entry : properties.entrySet()) { | |||
String value = entry.getValue(); | |||
if (value != null && encryption.isEncrypted(value)) { | |||
@@ -48,7 +48,7 @@ public abstract class UserProperties { | |||
} | |||
decryptedProps.put(entry.getKey(), value); | |||
} | |||
this.properties = Maps.newHashMap(decryptedProps); | |||
this.properties = decryptedProps; | |||
} | |||
public Map<String, String> properties() { |
@@ -19,9 +19,9 @@ | |||
*/ | |||
package org.sonar.scanner.events; | |||
import com.google.common.collect.Lists; | |||
import org.sonar.api.batch.events.EventHandler; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
@@ -51,7 +51,7 @@ public class EventBus { | |||
} | |||
private List<EventHandler> getDispatchList(Class<? extends EventHandler> handlerType) { | |||
List<EventHandler> result = Lists.newArrayList(); | |||
List<EventHandler> result = new ArrayList<>(registeredHandlers.length); | |||
for (EventHandler handler : registeredHandlers) { | |||
if (handlerType.isAssignableFrom(handler.getClass())) { | |||
result.add(handler); |
@@ -21,6 +21,7 @@ package org.sonar.scanner.index; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
@@ -41,7 +42,6 @@ import org.sonar.api.resources.Directory; | |||
import org.sonar.api.resources.File; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.core.util.stream.Collectors; | |||
import org.sonar.scanner.scan.filesystem.InputComponentStore; | |||
import org.sonar.scanner.scan.measure.MeasureCache; | |||
import org.sonar.scanner.sensor.DefaultSensorStorage; |
@@ -19,9 +19,10 @@ | |||
*/ | |||
package org.sonar.scanner.issue; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.scan.issue.filter.IssueFilter; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import org.sonar.api.scan.issue.filter.FilterableIssue; | |||
@@ -31,11 +32,11 @@ public class DefaultIssueFilterChain implements IssueFilterChain { | |||
private final List<IssueFilter> filters; | |||
public DefaultIssueFilterChain(IssueFilter... filters) { | |||
this.filters = ImmutableList.copyOf(filters); | |||
this.filters = Collections.unmodifiableList(Arrays.asList(filters)); | |||
} | |||
public DefaultIssueFilterChain() { | |||
this.filters = ImmutableList.of(); | |||
this.filters = Collections.emptyList(); | |||
} | |||
private DefaultIssueFilterChain(List<IssueFilter> filters) { |
@@ -19,12 +19,14 @@ | |||
*/ | |||
package org.sonar.scanner.issue; | |||
import com.google.common.base.Function; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.ProjectIssues; | |||
import org.sonar.scanner.issue.tracking.TrackedIssue; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.StreamSupport; | |||
import javax.annotation.Nullable; | |||
/** | |||
@@ -32,7 +34,8 @@ import javax.annotation.Nullable; | |||
* @since 4.0 | |||
*/ | |||
public class DefaultProjectIssues implements ProjectIssues { | |||
private static final Predicate<TrackedIssue> RESOLVED = new ResolvedPredicate(true); | |||
private static final Predicate<TrackedIssue> NOT_RESOLVED = new ResolvedPredicate(false); | |||
private final IssueCache cache; | |||
public DefaultProjectIssues(IssueCache cache) { | |||
@@ -41,16 +44,18 @@ public class DefaultProjectIssues implements ProjectIssues { | |||
@Override | |||
public Iterable<Issue> issues() { | |||
return Iterables.transform( | |||
Iterables.filter(cache.all(), new ResolvedPredicate(false)), | |||
new IssueTransformer()); | |||
return StreamSupport.stream(cache.all().spliterator(), false) | |||
.filter(NOT_RESOLVED) | |||
.map(TrackedIssueAdapter::new) | |||
.collect(Collectors.toList()); | |||
} | |||
@Override | |||
public Iterable<Issue> resolvedIssues() { | |||
return Iterables.transform( | |||
Iterables.filter(cache.all(), new ResolvedPredicate(true)), | |||
new IssueTransformer()); | |||
return StreamSupport.stream(cache.all().spliterator(), false) | |||
.filter(RESOLVED) | |||
.map(TrackedIssueAdapter::new) | |||
.collect(Collectors.toList()); | |||
} | |||
private static class ResolvedPredicate implements Predicate<TrackedIssue> { | |||
@@ -61,18 +66,11 @@ public class DefaultProjectIssues implements ProjectIssues { | |||
} | |||
@Override | |||
public boolean apply(@Nullable TrackedIssue issue) { | |||
public boolean test(@Nullable TrackedIssue issue) { | |||
if (issue != null) { | |||
return resolved ? (issue.resolution() != null) : (issue.resolution() == null); | |||
} | |||
return false; | |||
} | |||
} | |||
private static class IssueTransformer implements Function<TrackedIssue, Issue> { | |||
@Override | |||
public Issue apply(TrackedIssue issue) { | |||
return new TrackedIssueAdapter(issue); | |||
} | |||
} | |||
} |
@@ -19,11 +19,12 @@ | |||
*/ | |||
package org.sonar.scanner.issue; | |||
import com.google.common.collect.ImmutableList; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.batch.IssueFilter; | |||
import org.sonar.api.issue.batch.IssueFilterChain; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.List; | |||
/** | |||
@@ -35,11 +36,11 @@ public class DeprecatedIssueFilterChain implements IssueFilterChain { | |||
private final List<IssueFilter> filters; | |||
public DeprecatedIssueFilterChain(IssueFilter... filters) { | |||
this.filters = ImmutableList.copyOf(filters); | |||
this.filters = Arrays.asList(filters); | |||
} | |||
public DeprecatedIssueFilterChain() { | |||
this.filters = ImmutableList.of(); | |||
this.filters = Collections.emptyList(); | |||
} | |||
private DeprecatedIssueFilterChain(List<IssueFilter> filters) { |
@@ -20,11 +20,11 @@ | |||
package org.sonar.scanner.issue.ignore.pattern; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.batch.ScannerSide; | |||
import org.sonar.api.config.Settings; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import static com.google.common.base.MoreObjects.firstNonNull; | |||
@@ -62,7 +62,7 @@ public abstract class AbstractPatternInitializer { | |||
@VisibleForTesting | |||
protected final void initPatterns() { | |||
// Patterns Multicriteria | |||
multicriteriaPatterns = Lists.newArrayList(); | |||
multicriteriaPatterns = new ArrayList<>(); | |||
String patternConf = StringUtils.defaultIfBlank(settings.getString(getMulticriteriaConfigurationKey()), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = getMulticriteriaConfigurationKey() + "." + id + "."; |
@@ -20,11 +20,11 @@ | |||
package org.sonar.scanner.issue.ignore.pattern; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.core.config.IssueExclusionProperties; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import static com.google.common.base.Strings.nullToEmpty; | |||
@@ -67,7 +67,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
@VisibleForTesting | |||
protected final void loadFileContentPatterns() { | |||
// Patterns Block | |||
blockPatterns = Lists.newArrayList(); | |||
blockPatterns = new ArrayList<>(); | |||
String patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_BLOCK_KEY), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = IssueExclusionProperties.PATTERNS_BLOCK_KEY + "." + id + "."; | |||
@@ -80,7 +80,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer | |||
} | |||
// Patterns All File | |||
allFilePatterns = Lists.newArrayList(); | |||
allFilePatterns = new ArrayList<>(); | |||
patternConf = StringUtils.defaultIfBlank(getSettings().getString(IssueExclusionProperties.PATTERNS_ALLFILE_KEY), ""); | |||
for (String id : StringUtils.split(patternConf, ',')) { | |||
String propPrefix = IssueExclusionProperties.PATTERNS_ALLFILE_KEY + "." + id + "."; |
@@ -20,8 +20,8 @@ | |||
package org.sonar.scanner.issue.ignore.pattern; | |||
import com.google.common.base.Preconditions; | |||
import com.google.common.collect.Sets; | |||
import java.util.LinkedHashSet; | |||
import java.util.Set; | |||
public class LineRange { | |||
@@ -40,7 +40,7 @@ public class LineRange { | |||
} | |||
public Set<Integer> toLines() { | |||
Set<Integer> lines = Sets.newLinkedHashSet(); | |||
Set<Integer> lines = new LinkedHashSet<>(to-from+1); | |||
for (int index = from; index <= to; index++) { | |||
lines.add(index); | |||
} |
@@ -20,10 +20,10 @@ | |||
package org.sonar.scanner.issue.ignore.pattern; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.utils.SonarException; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
public class PatternDecoder { | |||
@@ -33,7 +33,7 @@ public class PatternDecoder { | |||
private static final String CONFIG_FORMAT_ERROR_PREFIX = "Exclusions > Issues : Invalid format. "; | |||
public List<IssuePattern> decode(String patternsList) { | |||
List<IssuePattern> patterns = Lists.newLinkedList(); | |||
List<IssuePattern> patterns = new LinkedList<>(); | |||
String[] patternsLines = StringUtils.split(patternsList, "\n"); | |||
for (String patternLine : patternsLines) { | |||
IssuePattern pattern = decodeLine(patternLine.trim()); |
@@ -19,9 +19,6 @@ | |||
*/ | |||
package org.sonar.scanner.issue.ignore.scanner; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Sets; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
@@ -32,6 +29,9 @@ import org.sonar.scanner.issue.ignore.pattern.LineRange; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.nio.charset.Charset; | |||
import java.nio.file.Files; | |||
import java.util.ArrayList; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
@@ -53,9 +53,9 @@ public class IssueExclusionsRegexpScanner { | |||
public IssueExclusionsRegexpScanner(IssueExclusionPatternInitializer patternsInitializer) { | |||
this.exclusionPatternInitializer = patternsInitializer; | |||
lineExclusions = Lists.newArrayList(); | |||
allFilePatterns = Lists.newArrayList(); | |||
blockMatchers = Lists.newArrayList(); | |||
lineExclusions = new ArrayList<>(); | |||
allFilePatterns = new ArrayList<>(); | |||
blockMatchers = new ArrayList<>(); | |||
for (IssuePattern pattern : patternsInitializer.getAllFilePatterns()) { | |||
allFilePatterns.add(java.util.regex.Pattern.compile(pattern.getAllFileRegexp())); | |||
@@ -80,7 +80,7 @@ public class IssueExclusionsRegexpScanner { | |||
LOG.debug("Scanning {}", resource); | |||
init(); | |||
List<String> lines = FileUtils.readLines(file, sourcesEncoding.name()); | |||
List<String> lines = Files.readAllLines(file.toPath(), sourcesEncoding); | |||
int lineIndex = 0; | |||
for (String line : lines) { | |||
lineIndex++; | |||
@@ -117,7 +117,7 @@ public class IssueExclusionsRegexpScanner { | |||
} | |||
private Set<LineRange> convertLineExclusionsToLineRanges() { | |||
Set<LineRange> lineRanges = Sets.newHashSet(); | |||
Set<LineRange> lineRanges = new HashSet<>(lineExclusions.size()); | |||
for (LineExclusion lineExclusion : lineExclusions) { | |||
lineRanges.add(lineExclusion.toLineRange()); | |||
} |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.scanner.issue.tracking; | |||
import com.google.common.base.Function; | |||
import java.util.function.Function; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.batch.ScannerSide; | |||
import org.sonar.api.batch.fs.InputComponent; |
@@ -19,13 +19,13 @@ | |||
*/ | |||
package org.sonar.scanner.issue.tracking; | |||
import com.google.common.collect.ImmutableSet; | |||
import org.sonar.api.batch.fs.InputFile.Status; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import javax.annotation.CheckForNull; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
public class SourceHashHolder { | |||
@@ -69,7 +69,7 @@ public class SourceHashHolder { | |||
public Collection<Integer> getNewLinesMatching(Integer originLine) { | |||
FileHashes reference = getHashedReference(); | |||
if (reference == null) { | |||
return ImmutableSet.of(); | |||
return Collections.emptySet(); | |||
} else { | |||
return getHashedSource().getLinesForHash(reference.getHash(originLine)); | |||
} |
@@ -62,7 +62,7 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, SensorsPhaseH | |||
} | |||
} | |||
private ClassLoader getSensorClassLoader(Sensor sensor) { | |||
private static ClassLoader getSensorClassLoader(Sensor sensor) { | |||
if (sensor instanceof SensorWrapper) { | |||
SensorWrapper wrapper = (SensorWrapper) sensor; | |||
return wrapper.wrappedSensor().getClass().getClassLoader(); |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.scanner.phases; | |||
import com.google.common.collect.Lists; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.batch.PostJob; | |||
@@ -50,9 +50,9 @@ public class PostJobsExecutor { | |||
public void execute(SensorContext context) { | |||
Collection<PostJob> postJobs = selector.select(PostJob.class, module, true, null); | |||
eventBus.fireEvent(new PostJobPhaseEvent(Lists.newArrayList(postJobs), true)); | |||
eventBus.fireEvent(new PostJobPhaseEvent(new ArrayList<>(postJobs), true)); | |||
execute(context, postJobs); | |||
eventBus.fireEvent(new PostJobPhaseEvent(Lists.newArrayList(postJobs), false)); | |||
eventBus.fireEvent(new PostJobPhaseEvent(new ArrayList<>(postJobs), false)); | |||
} | |||
private void execute(SensorContext context, Collection<PostJob> postJobs) { |
@@ -19,9 +19,10 @@ | |||
*/ | |||
package org.sonar.scanner.postjob; | |||
import com.google.common.base.Function; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.StreamSupport; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
@@ -63,7 +64,10 @@ public class DefaultPostJobContext implements PostJobContext { | |||
if (!analysisMode.isIssues()) { | |||
throw new UnsupportedOperationException("Issues are only available to PostJobs in 'issues' mode."); | |||
} | |||
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer()); | |||
return StreamSupport.stream(cache.all().spliterator(), false) | |||
.filter(new ResolvedPredicate(false)) | |||
.map(DefaultIssueWrapper::new) | |||
.collect(Collectors.toList()); | |||
} | |||
@Override | |||
@@ -71,7 +75,10 @@ public class DefaultPostJobContext implements PostJobContext { | |||
if (!analysisMode.isIssues()) { | |||
throw new UnsupportedOperationException("Resolved issues are only available to PostJobs in 'issues' mode."); | |||
} | |||
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(true)), new IssueTransformer()); | |||
return StreamSupport.stream(cache.all().spliterator(), false) | |||
.filter(new ResolvedPredicate(true)) | |||
.map(DefaultIssueWrapper::new) | |||
.collect(Collectors.toList()); | |||
} | |||
private class DefaultIssueWrapper implements PostJobIssue { | |||
@@ -123,13 +130,6 @@ public class DefaultPostJobContext implements PostJobContext { | |||
} | |||
} | |||
private class IssueTransformer implements Function<TrackedIssue, PostJobIssue> { | |||
@Override | |||
public PostJobIssue apply(TrackedIssue input) { | |||
return new DefaultIssueWrapper(input); | |||
} | |||
} | |||
private static class ResolvedPredicate implements Predicate<TrackedIssue> { | |||
private final boolean resolved; | |||
@@ -138,7 +138,7 @@ public class DefaultPostJobContext implements PostJobContext { | |||
} | |||
@Override | |||
public boolean apply(@Nullable TrackedIssue issue) { | |||
public boolean test(@Nullable TrackedIssue issue) { | |||
if (issue != null) { | |||
return resolved ? issue.resolution() != null : issue.resolution() == null; | |||
} |
@@ -20,6 +20,7 @@ | |||
package org.sonar.scanner.report; | |||
import java.util.Collection; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -36,7 +37,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.InputComponentTree; | |||
import org.sonar.api.batch.fs.internal.InputModuleHierarchy; | |||
import org.sonar.core.util.CloseableIterator; | |||
import org.sonar.core.util.stream.Collectors; | |||
import org.sonar.scanner.protocol.output.ScannerReport; | |||
import org.sonar.scanner.protocol.output.ScannerReportReader; | |||
import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType; |
@@ -19,16 +19,17 @@ | |||
*/ | |||
package org.sonar.scanner.report; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.Iterables; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
import javax.annotation.Nonnull; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.scanner.protocol.output.ScannerReport; | |||
import org.sonar.scanner.protocol.output.ScannerReportWriter; | |||
import org.sonar.scanner.repository.ContextPropertiesCache; | |||
import static com.google.common.collect.FluentIterable.from; | |||
import static org.sonar.core.config.WebhookProperties.ANALYSIS_PROPERTY_PREFIX; | |||
public class ContextPropertiesPublisher implements ReportPublisherStep { | |||
@@ -46,16 +47,15 @@ public class ContextPropertiesPublisher implements ReportPublisherStep { | |||
MapEntryToContextPropertyFunction transformer = new MapEntryToContextPropertyFunction(); | |||
// properties defined programmatically by plugins | |||
Iterable<ScannerReport.ContextProperty> fromCache = from(cache.getAll().entrySet()) | |||
.transform(transformer); | |||
Stream<ScannerReport.ContextProperty> fromCache = cache.getAll().entrySet().stream().map(transformer); | |||
// properties that are automatically included to report so that | |||
// they can be included to webhook payloads | |||
Iterable<ScannerReport.ContextProperty> fromSettings = from(settings.getProperties().entrySet()) | |||
Stream<ScannerReport.ContextProperty> fromSettings = settings.getProperties().entrySet().stream() | |||
.filter(e -> e.getKey().startsWith(ANALYSIS_PROPERTY_PREFIX)) | |||
.transform(transformer); | |||
.map(transformer); | |||
writer.writeContextProperties(Iterables.concat(fromCache, fromSettings)); | |||
writer.writeContextProperties(Stream.concat(fromCache, fromSettings).collect(Collectors.toList())); | |||
} | |||
private static final class MapEntryToContextPropertyFunction implements Function<Map.Entry<String, String>, ScannerReport.ContextProperty> { |
@@ -23,6 +23,7 @@ import com.google.common.collect.Iterables; | |||
import java.io.Serializable; | |||
import java.util.Collections; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.StreamSupport; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
@@ -35,7 +36,6 @@ import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.test.MutableTestPlan; | |||
import org.sonar.api.test.TestCase.Status; | |||
import org.sonar.api.utils.KeyValueFormat; | |||
import org.sonar.core.util.stream.Collectors; | |||
import org.sonar.scanner.deprecated.test.TestPlanBuilder; | |||
import org.sonar.scanner.protocol.output.ScannerReport; | |||
import org.sonar.scanner.protocol.output.ScannerReport.Measure.BoolValue; |
@@ -21,13 +21,15 @@ package org.sonar.scanner.report; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.base.Throwables; | |||
import com.google.common.io.Files; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.Writer; | |||
import java.net.URL; | |||
import java.nio.charset.StandardCharsets; | |||
import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import javax.annotation.Nullable; | |||
@@ -222,8 +224,8 @@ public class ReportPublisher implements Startable { | |||
} | |||
private void dumpMetadata(Map<String, String> metadata) { | |||
File file = new File(projectReactor.getRoot().getWorkDir(), METADATA_DUMP_FILENAME); | |||
try (Writer output = Files.newWriter(file, StandardCharsets.UTF_8)) { | |||
Path file = projectReactor.getRoot().getWorkDir().toPath().resolve(METADATA_DUMP_FILENAME); | |||
try (Writer output = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { | |||
for (Map.Entry<String, String> entry : metadata.entrySet()) { | |||
output.write(entry.getKey()); | |||
output.write("="); |
@@ -19,9 +19,10 @@ | |||
*/ | |||
package org.sonar.scanner.repository; | |||
import com.google.common.base.Function; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.function.Function; | |||
import org.apache.commons.io.IOUtils; | |||
import org.sonar.scanner.bootstrap.ScannerWsClient; | |||
import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.scanner.repository; | |||
import com.google.common.base.Function; | |||
import java.util.function.Function; | |||
import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; | |||
public interface ServerIssuesLoader { |
@@ -22,12 +22,13 @@ package org.sonar.scanner.rule; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.sonar.api.batch.ScannerSide; | |||
import javax.annotation.CheckForNull; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
@@ -40,17 +41,17 @@ public class ModuleQProfiles { | |||
private final Map<String, QProfile> byLanguage; | |||
public ModuleQProfiles(Collection<QualityProfile> profiles) { | |||
ImmutableMap.Builder<String, QProfile> builder = ImmutableMap.builder(); | |||
Map<String, QProfile> map = new HashMap<>(profiles.size()); | |||
for (QualityProfile qProfile : profiles) { | |||
builder.put(qProfile.getLanguage(), | |||
map.put(qProfile.getLanguage(), | |||
new QProfile() | |||
.setKey(qProfile.getKey()) | |||
.setName(qProfile.getName()) | |||
.setLanguage(qProfile.getLanguage()) | |||
.setRulesUpdatedAt(DateUtils.parseDateTime(qProfile.getRulesUpdatedAt()))); | |||
} | |||
byLanguage = builder.build(); | |||
byLanguage = Collections.unmodifiableMap(map); | |||
} | |||
public Collection<QProfile> findAll() { |
@@ -22,6 +22,8 @@ package org.sonar.scanner.rule; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.builder.ReflectionToStringBuilder; | |||
@@ -31,7 +33,6 @@ 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.core.util.stream.Collectors; | |||
public class RuleFinderCompatibility implements RuleFinder { | |||
@@ -87,7 +88,7 @@ public class RuleFinderCompatibility implements RuleFinder { | |||
private Collection<Rule> byRepository(RuleQuery query) { | |||
return rules.findByRepository(query.getRepositoryKey()).stream() | |||
.map(RuleFinderCompatibility::toRule) | |||
.collect(Collectors.toArrayList()); | |||
.collect(Collectors.toList()); | |||
} | |||
private Collection<Rule> byKey(RuleQuery query) { | |||
@@ -98,7 +99,7 @@ public class RuleFinderCompatibility implements RuleFinder { | |||
private Collection<Rule> byInternalKey(RuleQuery query) { | |||
return rules.findByInternalKey(query.getRepositoryKey(), query.getConfigKey()).stream() | |||
.map(RuleFinderCompatibility::toRule) | |||
.collect(Collectors.toArrayList()); | |||
.collect(Collectors.toList()); | |||
} | |||
@CheckForNull |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.scanner.rule; | |||
import com.google.common.collect.Lists; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Map; | |||
import org.apache.commons.lang.StringUtils; | |||
@@ -57,12 +57,13 @@ public class RulesProfileProvider extends ProviderAdapter { | |||
if (qProfile != null) { | |||
return new RulesProfileWrapper(select(qProfile, activeRules)); | |||
} | |||
return new RulesProfileWrapper(Lists.<RulesProfile>newArrayList()); | |||
return new RulesProfileWrapper(new ArrayList<>()); | |||
} | |||
private static RulesProfile loadProfiles(ModuleQProfiles qProfiles, ActiveRules activeRules) { | |||
Collection<RulesProfile> dtos = Lists.newArrayList(); | |||
for (QProfile qProfile : qProfiles.findAll()) { | |||
Collection<QProfile> profiles = qProfiles.findAll(); | |||
Collection<RulesProfile> dtos = new ArrayList<>(profiles.size()); | |||
for (QProfile qProfile : profiles) { | |||
dtos.add(select(qProfile, activeRules)); | |||
} | |||
return new RulesProfileWrapper(dtos); |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.scanner.rule; | |||
import com.google.common.collect.Lists; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.profiles.RulesProfile; | |||
@@ -29,6 +28,7 @@ import org.sonar.api.utils.SonarException; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
/** | |||
@@ -51,7 +51,7 @@ public class RulesProfileWrapper extends RulesProfile { | |||
} | |||
public RulesProfileWrapper(RulesProfile profile) { | |||
this.profiles = Lists.newArrayList(profile); | |||
this.profiles = Collections.singletonList(profile); | |||
this.singleLanguageProfile = profile; | |||
} | |||
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.scanner.scan; | |||
import com.google.common.collect.Lists; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -79,7 +79,7 @@ public class ModuleSettings extends Settings { | |||
* From root to given project | |||
*/ | |||
static List<ProjectDefinition> getTopDownParentProjects(ProjectDefinition project) { | |||
List<ProjectDefinition> result = Lists.newArrayList(); | |||
List<ProjectDefinition> result = new ArrayList<>(); | |||
ProjectDefinition p = project; | |||
while (p != null) { | |||
result.add(0, p); |
@@ -20,9 +20,9 @@ | |||
package org.sonar.scanner.scan.filesystem; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import java.io.File; | |||
import java.nio.charset.Charset; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.CoreProperties; | |||
@@ -42,8 +42,8 @@ public class DefaultModuleFileSystem extends DefaultFileSystem { | |||
private FileIndexer indexer; | |||
private Settings settings; | |||
private List<File> sourceDirsOrFiles = Lists.newArrayList(); | |||
private List<File> testDirsOrFiles = Lists.newArrayList(); | |||
private List<File> sourceDirsOrFiles = new ArrayList<>(); | |||
private List<File> testDirsOrFiles = new ArrayList<>(); | |||
private boolean initialized; | |||
private Charset charset = null; | |||
@@ -20,9 +20,9 @@ | |||
package org.sonar.scanner.scan.filesystem; | |||
import com.google.common.base.Joiner; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Maps; | |||
import java.text.MessageFormat; | |||
import java.util.ArrayList; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
@@ -49,8 +49,8 @@ public class LanguageDetection { | |||
/** | |||
* Lower-case extension -> languages | |||
*/ | |||
private final Map<String, PathPattern[]> patternsByLanguage = Maps.newLinkedHashMap(); | |||
private final List<String> languagesToConsider = Lists.newArrayList(); | |||
private final Map<String, PathPattern[]> patternsByLanguage = new LinkedHashMap<>(); | |||
private final List<String> languagesToConsider = new ArrayList<>(); | |||
private final String forcedLanguage; | |||
public LanguageDetection(Settings settings, LanguagesRepository languages) { |
@@ -19,8 +19,8 @@ | |||
*/ | |||
package org.sonar.scanner.scan.filesystem; | |||
import com.google.common.collect.Lists; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.commons.io.FileUtils; | |||
import org.sonar.api.batch.ScannerSide; | |||
@@ -36,8 +36,8 @@ public class ModuleFileSystemInitializer { | |||
private File baseDir; | |||
private File workingDir; | |||
private List<File> sourceDirsOrFiles = Lists.newArrayList(); | |||
private List<File> testDirsOrFiles = Lists.newArrayList(); | |||
private List<File> sourceDirsOrFiles = new ArrayList<>(); | |||
private List<File> testDirsOrFiles = new ArrayList<>(); | |||
public ModuleFileSystemInitializer(ProjectDefinition module, TempFolder tempUtils, PathResolver pathResolver) { | |||
baseDir = module.getBaseDir(); |
@@ -19,9 +19,9 @@ | |||
*/ | |||
package org.sonar.scanner.scan.measure; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Maps; | |||
import java.util.Collection; | |||
import java.util.LinkedHashMap; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.sonar.api.measures.Metric; | |||
@@ -30,8 +30,8 @@ import org.sonar.scanner.repository.MetricsRepository; | |||
public final class DeprecatedMetricFinder implements MetricFinder { | |||
private Map<String, Metric> metricsByKey = Maps.newLinkedHashMap(); | |||
private Map<Integer, Metric> metricsById = Maps.newLinkedHashMap(); | |||
private Map<String, Metric> metricsByKey = new LinkedHashMap<>(); | |||
private Map<Integer, Metric> metricsById = new LinkedHashMap<>(); | |||
public DeprecatedMetricFinder(MetricsRepository metricsRepository) { | |||
for (Metric metric : metricsRepository.metrics()) { | |||
@@ -52,7 +52,7 @@ public final class DeprecatedMetricFinder implements MetricFinder { | |||
@Override | |||
public Collection<Metric> findAll(List<String> metricKeys) { | |||
List<Metric> result = Lists.newLinkedList(); | |||
List<Metric> result = new LinkedList<>(); | |||
for (String metricKey : metricKeys) { | |||
Metric metric = findByKey(metricKey); | |||
if (metric != null) { |
@@ -19,9 +19,10 @@ | |||
*/ | |||
package org.sonar.scanner.scan.report; | |||
import com.google.common.collect.Maps; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.EnumMap; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
@@ -40,13 +41,13 @@ import org.sonar.scanner.issue.tracking.TrackedIssue; | |||
public final class ResourceReport { | |||
private final InputComponent component; | |||
private final IssueVariation total = new IssueVariation(); | |||
private final Map<ReportRuleKey, RuleReport> ruleReportByRuleKey = Maps.newHashMap(); | |||
private final Map<ReportRuleKey, RuleReport> ruleReportByRuleKey = new HashMap<>(); | |||
private List<TrackedIssue> issues = new ArrayList<>(); | |||
private Map<Integer, List<TrackedIssue>> issuesPerLine = Maps.newHashMap(); | |||
private Map<Integer, List<TrackedIssue>> newIssuesPerLine = Maps.newHashMap(); | |||
private Map<Rule, AtomicInteger> issuesByRule = Maps.newHashMap(); | |||
private Map<RulePriority, AtomicInteger> issuesBySeverity = Maps.newHashMap(); | |||
private Map<Integer, List<TrackedIssue>> issuesPerLine = new HashMap<>(); | |||
private Map<Integer, List<TrackedIssue>> newIssuesPerLine = new HashMap<>(); | |||
private Map<Rule, AtomicInteger> issuesByRule = new HashMap<>(); | |||
private Map<RulePriority, AtomicInteger> issuesBySeverity = new EnumMap<>(RulePriority.class); | |||
public ResourceReport(InputComponent component) { | |||
this.component = component; |
@@ -19,13 +19,13 @@ | |||
*/ | |||
package org.sonar.scanner.source; | |||
import com.google.common.collect.Lists; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.InputStreamReader; | |||
import java.io.Reader; | |||
import java.nio.charset.Charset; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -62,7 +62,7 @@ public class CodeColorizers { | |||
* Used when no plugin is defining some CodeColorizerFormat | |||
*/ | |||
public CodeColorizers() { | |||
this(Lists.<CodeColorizerFormat>newArrayList()); | |||
this(new ArrayList<>()); | |||
} | |||
@CheckForNull |
@@ -19,10 +19,11 @@ | |||
*/ | |||
package org.sonar.scanner.source; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.Sets; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.function.Function; | |||
import java.util.stream.StreamSupport; | |||
import org.sonar.api.batch.Phase; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputFile; | |||
@@ -36,11 +37,11 @@ import org.sonar.api.batch.sensor.coverage.NewCoverage; | |||
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.utils.KeyValueFormat; | |||
import org.sonar.core.util.stream.Collectors; | |||
import org.sonar.scanner.scan.measure.MeasureCache; | |||
import org.sonar.scanner.sensor.coverage.CoverageExclusions; | |||
import static com.google.common.collect.Iterables.transform; | |||
import static com.google.common.collect.Sets.newHashSet; | |||
import com.google.common.collect.Sets; | |||
@Phase(name = Phase.Name.POST) | |||
public final class ZeroCoverageSensor implements Sensor { | |||
@@ -101,9 +102,10 @@ public final class ZeroCoverageSensor implements Sensor { | |||
} | |||
private boolean isCoverageMeasuresAlreadyDefined(InputFile f) { | |||
Set<String> metricKeys = newHashSet(transform(measureCache.byComponentKey(f.key()), new MeasureToMetricKey())); | |||
Set<String> metricKeys = StreamSupport.stream(measureCache.byComponentKey(f.key()).spliterator(), false) | |||
.map(new MeasureToMetricKey()).collect(Collectors.toSet()); | |||
Function<Metric, String> metricToKey = new MetricToKey(); | |||
Set<String> allCoverageMetricKeys = newHashSet(transform(CoverageType.UNIT.allMetrics(), metricToKey)); | |||
Set<String> allCoverageMetricKeys = CoverageType.UNIT.allMetrics().stream().map(metricToKey).collect(Collectors.toSet()); | |||
return !Sets.intersection(metricKeys, allCoverageMetricKeys).isEmpty(); | |||
} | |||
@@ -20,7 +20,6 @@ | |||
package org.sonar.scanner.storage; | |||
import com.google.common.base.Preconditions; | |||
import com.google.common.collect.Maps; | |||
import com.persistit.Exchange; | |||
import com.persistit.Persistit; | |||
import com.persistit.Value; | |||
@@ -28,6 +27,8 @@ import com.persistit.Volume; | |||
import com.persistit.encoding.CoderManager; | |||
import com.persistit.encoding.ValueCoder; | |||
import com.persistit.exception.PersistitException; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import org.picocontainer.Startable; | |||
@@ -35,7 +36,7 @@ import org.sonar.api.batch.ScannerSide; | |||
@ScannerSide | |||
public class Storages implements Startable { | |||
private final Map<String, Exchange> cacheMap = Maps.newHashMap(); | |||
private final Map<String, Exchange> cacheMap = new HashMap<>(); | |||
private Persistit persistit; | |||
private Volume volume; | |||
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.scanner.mediumtest; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.HashBasedTable; | |||
import com.google.common.collect.Table; | |||
import java.io.File; | |||
@@ -37,6 +36,8 @@ import java.util.LinkedList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
import java.util.function.Function; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.io.FileUtils; | |||
import org.sonar.api.CoreProperties; |
@@ -21,10 +21,8 @@ package org.sonar.scanner.repository; | |||
import org.sonar.scanner.WsTestUtil; | |||
import org.sonar.scanner.bootstrap.ScannerWsClient; | |||
import org.sonar.scanner.protocol.input.ScannerInput; | |||
import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; | |||
import org.sonar.scanner.repository.DefaultServerIssuesLoader; | |||
import com.google.common.base.Function; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import java.io.ByteArrayInputStream; | |||
@@ -33,6 +31,7 @@ import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.function.Function; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
@@ -61,13 +60,9 @@ public class DefaultServerIssuesLoaderTest { | |||
WsTestUtil.mockStream(wsClient, "/batch/issues.protobuf?key=foo", is); | |||
final List<ServerIssue> result = new ArrayList<>(); | |||
loader.load("foo", new Function<ScannerInput.ServerIssue, Void>() { | |||
@Override | |||
public Void apply(ServerIssue input) { | |||
result.add(input); | |||
return null; | |||
} | |||
loader.load("foo", issue -> { | |||
result.add(issue); | |||
return null; | |||
}); | |||
assertThat(result).extracting("key").containsExactly("ab1", "ab2"); |