Skip to content

Commit

Permalink
refactor: Operator wrapping on end of line
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne committed Sep 21, 2024
1 parent 3e97fc3 commit 6996576
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ public J visitNewClass(J.NewClass newClass, P p) {
}

private <M extends MethodCall> Optional<J.Identifier> visitMethodCall(M methodCall, Function<M, Expression> parentDirExtractor) {
if (methodCall.getArguments().stream().anyMatch(taintedSinks::contains)
&& Dataflow.startingAt(getCursor()).findSinks(new FileOrPathCreationToVulnerableUsageLocalFlowSpec()).isSome()) {
if (methodCall.getArguments().stream().anyMatch(taintedSinks::contains) &&
Dataflow.startingAt(getCursor()).findSinks(new FileOrPathCreationToVulnerableUsageLocalFlowSpec()).isSome()) {
J.Block firstEnclosingBlock = getCursor().firstEnclosingOrThrow(J.Block.class);
@SuppressWarnings("SuspiciousMethodCalls")
Statement enclosingStatement = getCursor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
isWeakSeed = true;
} else if (arg instanceof J.MethodInvocation) {
J.MethodInvocation argMi = (J.MethodInvocation) arg;
if (SYSTEM_TIME_MATCHER.matches(arg) || SYSTEM_NANO_TIME_MATCHER.matches(argMi)
|| (STRING_BYTES_MATCHER.matches(argMi) && argMi.getSelect() instanceof J.Literal)) {
if (SYSTEM_TIME_MATCHER.matches(arg) || SYSTEM_NANO_TIME_MATCHER.matches(argMi) ||
(STRING_BYTES_MATCHER.matches(argMi) && argMi.getSelect() instanceof J.Literal)) {
isWeakSeed = true;
} else if (argMi.getMethodType() != null
&& (TypeUtils.isAssignableTo(dateType, argMi.getMethodType().getDeclaringType()))) {
} else if (argMi.getMethodType() != null &&
(TypeUtils.isAssignableTo(dateType, argMi.getMethodType().getDeclaringType()))) {
isWeakSeed = true;
maybeRemoveImport("java.util.Date");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ private static class SecureTempDirectoryCreation<P> extends JavaIsoVisitor<P> {
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, P p) {
J.MethodInvocation m = method;
if (CREATE_TEMP_FILE_MATCHER.matches(m)) {
if (m.getArguments().size() == 2
|| (m.getArguments().size() == 3 && m.getArguments().get(2).getType() == JavaType.Primitive.Null)) {
if (m.getArguments().size() == 2 ||
(m.getArguments().size() == 3 && m.getArguments().get(2).getType() == JavaType.Primitive.Null)) {
// File.createTempFile(String prefix, String suffix)
m = maybeAutoFormat(m, twoArg.apply(
getCursor(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ public TreeVisitor<?, ExecutionContext> getScanner(AtomicBoolean acc) {
return new TreeVisitor<>() {
@Override
public @Nullable Tree visit(@Nullable Tree tree, ExecutionContext ctx) {
if (!acc.get()
&& new IsLikelyNotTest().getVisitor().visit(tree, ctx) != tree
&& new SecureTempFileCreation().getVisitor().visit(tree, ctx) != tree) {
if (!acc.get() &&
new IsLikelyNotTest().getVisitor().visit(tree, ctx) != tree &&
new SecureTempFileCreation().getVisitor().visit(tree, ctx) != tree) {
acc.set(true);
}
return tree;
Expand Down

0 comments on commit 6996576

Please sign in to comment.