Skip to content

Commit

Permalink
jpmorganchase#108 Resolved 14 Minor Sonar issues
Browse files Browse the repository at this point in the history
Resolved 14 minor Sonar issues that only required very minor changes.
No calls between classes were altered and no new methods were introduced.
  • Loading branch information
jimbethancourt committed May 27, 2020
1 parent 1fea2b8 commit 65d2503
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.sandboni.core.engine.filter;

import java.util.HashMap;
import java.util.EnumMap;

public class VertexFilterFactory {

public enum VertexFilterTypes {REFLECTION_SRC}

private static HashMap<VertexFilterTypes, VertexFilter> filters = new HashMap<>();
private static EnumMap<VertexFilterTypes, VertexFilter> filters = new EnumMap<>(VertexFilterTypes.class);

static {
filters.put(VertexFilterTypes.REFLECTION_SRC, new ReflectionSrcVertexFilter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class RunWithAnnotationProcessorFactory {

private static final String CUCUMBER_RUNNER_CLASS = "cucumber/api/junit/Cucumber";

private final static Map<String, Supplier<RunWithAnnotationProcessor>> map = new HashMap<>();
private static final Map<String, Supplier<RunWithAnnotationProcessor>> map = new HashMap<>();

private static final String DEFAULT_IMPL = "Default";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consume

Map<String, Set<File>> locationFiles = new HashMap<>();
Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations);
locationToFilesFound.forEach(map -> {
map.forEach(locationFiles::put);
});
locationToFilesFound.forEach(map -> map.forEach(locationFiles::put));

logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ public void connect(Context context) {
Set<Vertex> tests = context.getLinks().filter(l -> l.getLinkType() == LinkType.ENTRY_POINT).map(Link::getCallee).collect(Collectors.toSet());
Set<Vertex> allTestSuiteVertices = context.getLinks().filter(l -> l.getLinkType() == LinkType.TEST_SUITE).map(Link::getCallee).collect(Collectors.toSet());
// connect test suite to relevant test (if applicable):
tests.parallelStream().forEach(t -> {
// check if we have a related suite class
allTestSuiteVertices.stream().filter(tsv -> tsv instanceof TestSuiteVertex && ((TestSuiteVertex)tsv).getRelatedTestClasses().contains(t.getActor())).forEach(ts -> {
// create a link: testSuite -> testVertex, type:TEST_SUITE
context.addLink(LinkFactory.createInstance(context.getApplicationId(), ts, t, LinkType.TEST_SUITE));
});
});
tests.parallelStream().forEach(t ->
// check if we have a related suite class
allTestSuiteVertices.stream().filter(tsv -> tsv instanceof TestSuiteVertex &&
((TestSuiteVertex) tsv).getRelatedTestClasses().contains(t.getActor())).forEach(ts ->
// create a link: testSuite -> testVertex, type:TEST_SUITE
context.addLink(LinkFactory.createInstance(context.getApplicationId(), ts, t, LinkType.TEST_SUITE))
)
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;

public class CliChangeScopeResolver extends JGitChangeScopeResolver implements ChangeScopeResolver {

final static String NON_EXISTING_FILE = "/dev/null";
private final static Function<String, String> trimFileName = t -> t.startsWith("a/") || t.startsWith("b/") ? t.substring(2) : t;
private final static Function<RawText, String> rawTextToString = t -> t.getString(0, t.size(), false);
static final String NON_EXISTING_FILE = "/dev/null";
private static final UnaryOperator<String> trimFileName = t -> t.startsWith("a/") || t.startsWith("b/") ? t.substring(2) : t;
private static final Function<RawText, String> rawTextToString = t -> t.getString(0, t.size(), false);

private static final Logger log = LoggerFactory.getLogger(CliChangeScopeResolver.class);

Expand Down Expand Up @@ -98,7 +99,7 @@ private Map<ChangeType, Set<Integer>> getChangesFromHunk(Hunk hunk) {
Range fromFileRange = hunk.getFromFileRange();
int currentLine = Math.max(fromFileRange.getLineStart(), 1); // for new files, hunk line will start with 0
List<Integer> pendingLines = new LinkedList<>();
Map<ChangeType, Set<Integer>> changes = new HashMap<>();
Map<ChangeType, Set<Integer>> changes = new EnumMap<>(ChangeType.class);

List<Line> lines = hunk.getLines();
for (Line line : lines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public class SCMChangeBuilder{

Expand All @@ -32,21 +32,21 @@ private Optional<FileExtensions> getFileExt(String filePath){
if (!tmp.isPresent())
return Optional.empty();

String ext = tmp.get().toString();
String ext = tmp.get();
FileExtensions fe = FileExtensions.fromText(ext);

if (Objects.isNull(fe)) return Optional.empty();
return Optional.of(fe);
}

private final Function<String, Boolean> isPropertyFile = filePath -> {
private final Predicate<String> isPropertyFile = filePath -> {
Optional<FileExtensions> extensions = getFileExt(filePath);
return extensions.map(fileExtensions ->
fileExtensions.in(FileExtensions.PROPERTIES, FileExtensions.PROPS, FileExtensions.YML))
.orElse(false);
};

private final Function<String, Boolean> isBuildFile = filePath ->
private final Predicate<String> isBuildFile = filePath ->
filePath.toLowerCase().endsWith(FileNames.POM.fileName());

public SCMChangeBuilder with(Consumer<SCMChangeBuilder> function){
Expand All @@ -59,10 +59,10 @@ public Change build() {

if (changeType == ChangeType.DELETE) {
change = new SCMChange(path, changedLines, changeType);
} else if (isPropertyFile.apply(path)){
} else if (isPropertyFile.test(path)){
Set<String> keys = RawUtil.grepKeys(fileContent, changedLines);
change = new SCMChangeInProperties(path, changedLines, keys, changeType);
} else if (isBuildFile.apply(path)) {
} else if (isBuildFile.test(path)) {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = null;
try {
Expand Down

0 comments on commit 65d2503

Please sign in to comment.