mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Java: Inline expectation should have space after $
This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
This commit is contained in:
@@ -11,48 +11,48 @@ public class FunctionalTest {
|
||||
void test() {
|
||||
Optional<String> o = Optional.of(source());
|
||||
o.ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
o.ifPresentOrElse(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
}, () -> {
|
||||
// no-op
|
||||
});
|
||||
o.map(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
return v;
|
||||
}).ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
o.flatMap(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
return Optional.of(v);
|
||||
}).ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
o.flatMap(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
return Optional.of("safe");
|
||||
}).ifPresent(v -> {
|
||||
sink(v); // no value flow
|
||||
});
|
||||
o.filter(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
return true;
|
||||
}).ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
Optional.of("safe").map(v -> {
|
||||
sink(v); // no value flow
|
||||
return v;
|
||||
}).or(() -> o).ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
Optional<String> safe = Optional.of("safe");
|
||||
o.or(() -> safe).ifPresent(v -> {
|
||||
sink(v); // $hasValueFlow
|
||||
sink(v); // $ hasValueFlow
|
||||
});
|
||||
String value = safe.orElseGet(() -> source());
|
||||
sink(value); // $hasValueFlow
|
||||
sink(value); // $ hasValueFlow
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,35 +19,35 @@ public class Test {
|
||||
Optional<Object> out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.filter(null);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
sink(getElement(out)); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;get;;;Element of Argument[this];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.get();
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;of;;;Argument[0];Element of ReturnValue;value;manual"
|
||||
Optional<Object> out = null;
|
||||
Object in = (Object)source();
|
||||
out = Optional.of(in);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
sink(getElement(out)); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;ofNullable;;;Argument[0];Element of ReturnValue;value;manual"
|
||||
Optional<Object> out = null;
|
||||
Object in = (Object)source();
|
||||
out = Optional.ofNullable(in);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
sink(getElement(out)); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;or;;;Element of Argument[this];Element of ReturnValue;value;manual"
|
||||
Optional<Object> out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.or(null);
|
||||
sink(getElement(out)); // $hasValueFlow
|
||||
sink(getElement(out)); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;orElse;;;Argument[0];ReturnValue;value;manual"
|
||||
@@ -55,44 +55,44 @@ public class Test {
|
||||
Object in = (Object)source();
|
||||
Optional<Object> instance = null;
|
||||
out = instance.orElse(in);
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;orElse;;;Element of Argument[this];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.orElse(null);
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;orElseGet;;;Element of Argument[this];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.orElseGet(null);
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;orElseThrow;;;Element of Argument[this];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.orElseThrow(null);
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;orElseThrow;;;Element of Argument[this];ReturnValue;value;manual"
|
||||
Object out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.orElseThrow();
|
||||
sink(out); // $hasValueFlow
|
||||
sink(out); // $ hasValueFlow
|
||||
}
|
||||
{
|
||||
// "java.util;Optional;false;stream;;;Element of Argument[this];Element of ReturnValue;value;manual"
|
||||
Stream<Object> out = null;
|
||||
Optional<Object> in = newWithElement(source());
|
||||
out = in.stream();
|
||||
sink(getStreamElement(out)); // $hasValueFlow
|
||||
sink(getStreamElement(out)); // $ hasValueFlow
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user