Skip to content

Commit

Permalink
its not easy beeing green /style
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety committed Jan 30, 2024
1 parent 564bba0 commit 66a0cc8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ public static PathBasedAnalysisInputLocation create(
@Nonnull List<BodyInterceptor> bodyInterceptors,
@Nonnull Collection<Path> ignoredPaths) {

if(ignoredPaths.stream().anyMatch( ignoPath -> path.toString().startsWith(ignoPath.toString()) )){
throw new IllegalArgumentException("The Path for the AnalysisInputLocation is in the ignored paths.");
if (ignoredPaths.stream()
.anyMatch(ignoPath -> path.toString().startsWith(ignoPath.toString()))) {
throw new IllegalArgumentException(

Check warning on line 134 in sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocation.java

View check run for this annotation

Codecov / codecov/patch

sootup.java.bytecode/src/main/java/sootup/java/bytecode/inputlocation/PathBasedAnalysisInputLocation.java#L134

Added line #L134 was not covered by tests
"The Path for the AnalysisInputLocation is in the ignored paths.");
}

if (Files.isDirectory(path)) {
Expand Down Expand Up @@ -162,10 +164,11 @@ Collection<JavaSootClassSource> walkDirectory(
final String moduleInfoFilename = JavaModuleIdentifierFactory.MODULE_INFO_FILE + ".class";
try (final Stream<Path> walk = Files.walk(dirPath)) {
return walk.filter(
filePath -> PathUtils.hasExtension(filePath, handledFileType)
filePath ->
PathUtils.hasExtension(filePath, handledFileType)
&& !filePath.toString().endsWith(moduleInfoFilename)
&& ignoredPaths.stream().noneMatch(p -> filePath.toString().startsWith(p.toString()))
)
&& ignoredPaths.stream()
.noneMatch(p -> filePath.toString().startsWith(p.toString())))
.flatMap(
p -> {
final String fullyQualifiedName = fromPath(dirPath, p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -91,17 +90,15 @@ public void multiReleaseJar() {
"/de/upb/sse/multirelease/Main.class",
view_8.getClass(classType2).get().getClassSource().getSourcePath().toString());
// assert that method is correctly resolved to base
MethodSubSignature printBodyMethodSubSig = getIdentifierFactory()
MethodSubSignature printBodyMethodSubSig =
getIdentifierFactory()
.getMethodSubSignature(
"printVersion",
getIdentifierFactory().getType("void"),
Collections.emptyList());
"printVersion", getIdentifierFactory().getType("void"), Collections.emptyList());
Assert.assertTrue(
view_8
.getClass(classType)
.get()
.getMethod(
printBodyMethodSubSig)
.getMethod(printBodyMethodSubSig)
.get()
.getBody()
.toString()
Expand All @@ -128,8 +125,7 @@ public void multiReleaseJar() {
view_10
.getClass(classType)
.get()
.getMethod(
printBodyMethodSubSig)
.getMethod(printBodyMethodSubSig)
.get()
.getBody()
.toString()
Expand All @@ -151,16 +147,24 @@ public void multiReleaseJar() {
"/de/upb/sse/multirelease/Main.class",
view_max.getClass(classType2).get().getClassSource().getSourcePath().toString());


// getClasses
List<String> collectedClassesWPrintBody9 = view_9.getClasses().stream().map(c -> c.getMethod(printBodyMethodSubSig)).filter(Optional::isPresent).map(m -> m.get().getBody().toString()).collect(Collectors.toList());
List<String> collectedClassesWPrintBody9 =
view_9.getClasses().stream()
.map(c -> c.getMethod(printBodyMethodSubSig))
.filter(Optional::isPresent)
.map(m -> m.get().getBody().toString())
.collect(Collectors.toList());
assertEquals(1, collectedClassesWPrintBody9.size());
assertTrue(collectedClassesWPrintBody9.get(0).contains("java 9"));

List<String> collectedClassesWPrintBody10 = view_10.getClasses().stream().map(c -> c.getMethod(printBodyMethodSubSig)).filter(Optional::isPresent).map(m -> m.get().getBody().toString()).collect(Collectors.toList());
List<String> collectedClassesWPrintBody10 =
view_10.getClasses().stream()
.map(c -> c.getMethod(printBodyMethodSubSig))
.filter(Optional::isPresent)
.map(m -> m.get().getBody().toString())
.collect(Collectors.toList());
assertEquals(1, collectedClassesWPrintBody10.size());
assertTrue(collectedClassesWPrintBody10.get(0).contains("java 10"));

}

@Test
Expand Down

0 comments on commit 66a0cc8

Please sign in to comment.