Skip to content

Commit

Permalink
fix grammer
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Nov 8, 2024
1 parent de9b563 commit 04473cd
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public void strictModeTest() {
.withDependency("Dep")
.withSourceFile("Dep.java", "analysismode/Dep.java")
.withExpectedReports(
// Resolves 6 errors locally and all errors on downstream dependencies can be resolved
// with no new triggered error, therefore the effect is -6. The fix triggers no error
// in downstream dependencies, should be approved.
// Resolves 6 errors locally, and all errors on downstream dependencies can be resolved
// with no new triggered error; therefore, the effect is -6.
// The fix triggers no error in downstream dependencies, should be approved.
new TReport(
new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE),
// Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot
// be resolved, therefore the effect is -5. The fix triggers 1 error in downstream
// dependencies, should be rejected.
// be resolved; therefore, the effect is -5.
// The fix triggers 1 error in downstream dependencies, should be rejected.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -5, REJECT))
.setPredicate(
(expected, found) ->
Expand Down Expand Up @@ -105,8 +105,8 @@ public void upperBoundModeTest() {
new TReport(
new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE),
// Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot
// be resolved, one of the triggered fixes in the tree, triggers an error in downstream
// dependency, the overall effect is -6 + 1 + 1 = -4 in upper bound mode.
// be resolved; one of the triggered fixes in the tree, triggers an error in downstream
// dependency; the overall effect is -6 + 1 + 1 = -4 in upper-bound mode.
new TReport(
new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -4, APPROVE))
.setPredicate(
Expand All @@ -129,14 +129,14 @@ public void strictModeWithSuppressRemainingErrorsTest() {
.withDependency("Dep")
.withSourceFile("Dep.java", "analysismode/Dep.java")
.withExpectedReports(
// Resolves 6 errors locally and all errors on downstream dependencies can be resolved
// with no new triggered error, therefore the effect is -6. The fix triggers no error
// in downstream dependencies, should be approved.
// Resolves 6 errors locally, and all errors on downstream dependencies can be resolved
// with no new triggered error; therefore, the effect is -6.
// The fix triggers no error in downstream dependencies, should be approved.
new TReport(
new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE),
// Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot
// be resolved, therefore the effect is -5. The fix triggers 1 error in downstream
// dependencies, should be rejected.
// be resolved; therefore, the effect is -5.
// The fix triggers 1 error in downstream dependencies, should be rejected.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -5, REJECT))
.setPredicate(
(expected, found) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ConfigurationTest {
@Before
public void init() {
testDir = temporaryFolder.getRoot().toPath();
// Make dummy config paths for 5 targets
// Make fake config paths for 5 targets
try (OutputStream os = new FileOutputStream(testDir.resolve("paths.tsv").toFile())) {
for (int i = 0; i < 5; i++) {
String row = i + "nullaway.xml" + "\t" + i + "scanner.xml" + "\n";
Expand Down Expand Up @@ -303,9 +303,9 @@ private Config makeConfigWithFlags(List<CLIFlag> flags) {

/**
* Helper method for reading value of a node located at /key_1/key_2/.../key_n (in the form of
* {@code Xpath} query) from a xml document at the given path.
* {@code Xpath} query) from an XML document at the given path.
*
* @param path Path to xml file.
* @param path Path to an XML file.
* @param key Key to locate the value, can be nested in the form of {@code Xpath} query (e.g.
* /key1/key2/.../key_n).
* @return The value in the specified keychain as {@code String}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public void fieldNoInitialization() {
// effect is -1 + 1 (triggered error on this.f = foo()) = 0.
new OnMethod("A.java", "test.A", "foo()"),
-2,
// adding @Nullable on f will resolve the triggered error by foo() and also resolves
// Adding @Nullable on f will resolve the triggered error by foo() and also resolves
// the initialization error on A() as well.
// Therefore, the combined effect is -1 + (-1) = -2. It resolves all existing
// errors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void publicMethodWithDownstreamDependencyEnabled() {
// DepA by 0, DepB by 1 and DepC by 0. Hence, the total effect is: -4.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), -4),
// Change increases errors on target by 1, and also increases them in downstream
// dependency DepA by 1. Hence , the total effect is: 2.
// dependency DepA by 1.Hence, the total effect is: 2.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 2))
.setPredicate(
(expected, found) ->
Expand Down Expand Up @@ -108,21 +108,21 @@ public void publicFieldWithDownstreamDependencyEnabled() {
.withSourceFile("DepC.java", "downstreamDependencyFieldCheck/DepC.java")
.withExpectedReports(
// Effect on target is -1, Effect on DepA is 0 and on DepB and DepC is 1 ->
// Lower bound is 2. And overall effect is -1 + 2 = 1. Effect is greater than 0 and
// triggers unresolved errors on downstream dependencies, hence the tree should be
// tagged as REJECT.
// Lower bound is 2. And overall effect is -1 + 2 = 1.
// The Effect is greater than 0 and triggers unresolved errors on downstream
// dependencies, hence the tree should be tagged as REJECT.
new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f")), 1, REJECT),
// Effect on target is -2. Root is on f1, but it triggers making f @Nullable as well.
// Fix tree containing both fixes resolves two errors leaving no remaining error, effect
// on target is -2. But f creates 2 errors on downstream dependencies, hence the lower
// bound is 2. Overall effect is -2 + 2 = 0. Since f creates unresolved errors on
// Fix a tree containing both fixes resolves two errors leaving no remaining error,
// effect on target is -2. But f creates 2 errors on downstream dependencies, hence the
// lower bound is 2. Overall effect is -2 + 2 = 0. Since f creates unresolved errors on
// downstream dependencies, the tree should be tagged as REJECT even though the overall
// effect is not greater than 0.
new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f1")), 0, REJECT),
// Effect on target is -1. Root is on f2, but it triggers making f3 @Nullable through an
// assignment in DepA and the tree is extended to include the corresponding fix. Since,
// assignment in DepA and the tree is extended to include the corresponding fix. Since
// f2 creates a resolvable error in downstream dependencies that the corresponding fix
// is present in the fix tree, the lower bound effect is 0. Overall effect is -1 + 0 =
// is present in the fix tree, the lower-bound effect is 0. Overall effect is -1 + 0 =
// -1. Since the overall effect is less than 0, with no error in downstream
// dependencies, the tree should be tagged as APPROVE.
new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f2")), -1, APPROVE))
Expand Down Expand Up @@ -158,8 +158,8 @@ public void lowerBoundComputationTest() {
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableBad(int)"), 10),
// Only returnNullableGood triggers new errors in this fix chain (+1), lower bound is 1.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), 1),
// Root fix triggers 1 error on downstream dependency but returnNullableBad is
// present in the fix tree, therefore the lower bound effect for the tree should be 10.
// Root fix triggers 1 error on downstream dependency, but returnNullableBad is
// present in the fix tree, therefore, the lower-bound effect for the tree should be 10.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 10))
.setPredicate(
(expected, found) ->
Expand Down Expand Up @@ -191,8 +191,8 @@ public void upperBoundComputationTest() {
// should be 1
new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), 1),
// Root fix triggers 1 error on downstream dependency and returnNullableBad is
// present in the fix tree and triggers 10 errors on downstream dependency, therefore
// the upper bound effect for the tree should be 11.
// present in the fix tree and triggers 10 errors on downstream dependency, therefore,
// the upper-bound effect for the tree should be 11.
new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 11))
.setPredicate(
(expected, found) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void regionComputationOnFieldParallelProcessingEnables() {
"class Main {",
" Object f;",
" public Object m1(){",
" return getF();", // Should be error
" return getF();", // Should be an error
" }",
" public Object m2(){",
" return getF();", // Should be error
" return getF();", // Should be an error
" }",
"}")
.withExpectedReports(
Expand All @@ -80,15 +80,15 @@ public void rejectOnFieldForGeneratedGetterInDownstreamDependencies() {
"package test;",
"class Dep {",
" public Object returnNullable(){",
" return new Main().getF();", // Should be error
" return new Main().getF();", // Should be an error
" }",
"}")
.withExpectedReports(
new TReport(
new OnField("Main.java", "test.Main", Collections.singleton("f")),
0,
// The copied annotation on the getF creates an unresolvable error in downstream
// dependency, hence, the tree should be rejected.
// dependency; hence, the tree should be rejected.
Report.Tag.REJECT))
.setPredicate(
(expected, found) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void nullableFlowDetectionEnabledTest() {
"Foo.java", "test.target.Foo", "bar1(java.lang.Object,java.lang.Object)")),
Collections.emptySet()),
// Change creates two errors on downstream dependencies (1 resolvable) and resolves one
// error locally, therefore the overall effect is 0.
// error locally; therefore, the overall effect is 0.
new TReport(
new OnMethod("Foo.java", "test.target.Foo", "getNull()"),
0,
Expand Down Expand Up @@ -141,7 +141,6 @@ public void nullableFlowToUpstreamThroughFieldWriteTest() {
new TReport(
new OnField("Bar.java", "test.Bar", Set.of("foo")),
-1,
// fixes in tree:
Set.of(
new OnMethod("Bar.java", "test.Bar", "getFoo(String)"),
// coming from flow of nullable back to target through a field write.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void removeAnnotationOn(String... fields) {
.collect(Collectors.toSet()));
}

/** Verifies if the calculated offsets matches the original offsets. */
/** Verifies if the calculated offsets match the original offsets. */
private void verifyCalculatedOffsets() {
try {
String content = Files.readString(root.resolve("benchmark.java"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public void onFieldMultiLineSuppressWarningTest() {
.expectOutput(
"package com.edu;",
"public class Super {",
// Google java format will convert annot below into multi line format if needed.
// Google java format will convert annot below into multi-line format if needed.
" @SuppressWarnings({ \"InvalidThrowsLink\", \"MalformedInlineTag\", \"unchecked\", \"NullAway.Init\" })",
" Object h = new Object();",
" public void test(Object f) {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void customNullableExists() {
@Test
public void customEndingWithNullableExists() {
// Custom annot ending with Nullable exists, the import declaration should be added since we
// only skip if the simple name is exactly is Nullable.
// only skip if the simple name is exactly Nullable.
injectorTestHelper
.addInput(
"Main.java",
Expand Down

0 comments on commit 04473cd

Please sign in to comment.