Reviewed By: jberdine Differential Revision: D3877153 fbshipit-source-id: a0efb3cmaster
parent
da01c2b94a
commit
fe21442d47
@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2016 - present Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD style license found in the
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
include ../../Makefile.clang
|
||||
|
||||
OPTIONS = -x objective-c -fobjc-arc -c
|
||||
|
||||
ANALYZER = linters
|
||||
|
||||
FILES = \
|
||||
**.m \
|
||||
*/*.m \
|
||||
|
||||
compile:
|
||||
clang $(OPTIONS) $(FILES)
|
||||
|
||||
analyze:
|
||||
$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets all --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt
|
||||
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
|
@ -0,0 +1,31 @@
|
||||
assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 18, ASSIGN_POINTER_WARNING
|
||||
assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 20, ASSIGN_POINTER_WARNING
|
||||
assign_pointer.m, frontend_checks_006677034375a1c7e7ccfd3694390282, 22, ASSIGN_POINTER_WARNING
|
||||
atomic_prop.m, A_bla, 98, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
atomic_prop.m, A_bla, 99, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
atomic_prop.m, A_readP, 77, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
atomic_prop.m, A_readQ, 86, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
atomic_prop.m, A_writeQ:, 82, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
atomic_prop.m, __objc_anonymous_block_______1, 114, DIRECT_ATOMIC_PROPERTY_ACCESS
|
||||
badpointer.m, bad1, 17, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad10, 139, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad2, 26, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad3, 33, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad4, 85, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad5, 99, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad6, 106, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad7, 121, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad8, 128, BAD_POINTER_COMPARISON
|
||||
badpointer.m, bad9, 135, BAD_POINTER_COMPARISON
|
||||
nsnumber.m, bad1, 13, BAD_POINTER_COMPARISON
|
||||
nsnumber.m, bad2, 18, BAD_POINTER_COMPARISON
|
||||
nsnumber.m, bad3, 23, BAD_POINTER_COMPARISON
|
||||
nsnumber.m, bad4, 43, BAD_POINTER_COMPARISON
|
||||
registered_observer/Person.m, frontend_checks_e09ed2cbfd6c3584b50a5fd5783367c9, 80, REGISTERED_OBSERVER_BEING_DEALLOCATED
|
||||
registered_observer/Person.m, frontend_checks_e09ed2cbfd6c3584b50a5fd5783367c9, 97, REGISTERED_OBSERVER_BEING_DEALLOCATED
|
||||
registered_observer/ViewController3.m, frontend_checks_6eb87af45b67f4c5dda049872d80dc43, 14, REGISTERED_OBSERVER_BEING_DEALLOCATED
|
||||
strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 15, STRONG_DELEGATE_WARNING
|
||||
strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 19, STRONG_DELEGATE_WARNING
|
||||
strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 21, STRONG_DELEGATE_WARNING
|
||||
strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 23, STRONG_DELEGATE_WARNING
|
||||
strong_delegate.m, frontend_checks_40af2f421be894c3b6306d2942a2c8b7, 25, STRONG_DELEGATE_WARNING
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"enable_checks": [
|
||||
"GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL"
|
||||
],
|
||||
"skip_translation": [
|
||||
{
|
||||
"language": "Java",
|
||||
"source_contains": "_SHOULD_BE_SKIPPED_"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
# Copyright (c) 2016 - present Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD style license found in the
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
include ../../Makefile.clang
|
||||
|
||||
OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c
|
||||
|
||||
ANALYZER = linters
|
||||
|
||||
FILES = \
|
||||
*/*.mm \
|
||||
|
||||
compile:
|
||||
clang $(OPTIONS) $(FILES)
|
||||
|
||||
analyze:
|
||||
$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets all --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt
|
||||
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
|
@ -0,0 +1,13 @@
|
||||
componentkit/Test.mm, BarComponent_new, 103, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, BarComponent_new, 105, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, FooComponent_newWithString:, 69, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, FooComponent_newWithString:, 74, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, FooComponent_newWithString:, 76, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, FooComponent_newWithString:, 80, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, FooComponent_newWithString:, 85, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
componentkit/Test.mm, SomeClass_init, 58, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE
|
||||
cxx_reference_in_block/block.mm, A_foo3:param2:, 37, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK
|
||||
cxx_reference_in_block/block.mm, A_foo:, 20, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK
|
||||
global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 30, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
|
||||
global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 32, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
|
||||
global-var/B.mm, frontend_checks_a1a4821f6afe8cbd5bde0f8905d6f284, 34, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class AssignPointerTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objc/linters/assign_pointer.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String ASSIGN_POINTER_WARNING = "ASSIGN_POINTER_WARNING";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain the correct " + ASSIGN_POINTER_WARNING,
|
||||
inferResults,
|
||||
containsOnlyLines(
|
||||
new int[]{
|
||||
18,
|
||||
20,
|
||||
22
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class AtomicPropertyTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objc/linters/atomic_prop.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String DIRECT_ATOMIC_PROPERTY_ACCESS = "DIRECT_ATOMIC_PROPERTY_ACCESS";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain the correct " + DIRECT_ATOMIC_PROPERTY_ACCESS,
|
||||
inferResults,
|
||||
containsOnlyLines(
|
||||
new int[]{
|
||||
77,
|
||||
82,
|
||||
86,
|
||||
98,
|
||||
99,
|
||||
114
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
tests_dependencies = [
|
||||
'//infer/lib/java/android:android',
|
||||
'//dependencies/java/guava:guava',
|
||||
'//dependencies/java/junit:hamcrest',
|
||||
'//dependencies/java/jackson:jackson',
|
||||
'//dependencies/java/jsr-305:jsr-305',
|
||||
'//dependencies/java/junit:junit',
|
||||
'//dependencies/java/opencsv:opencsv',
|
||||
'//infer/tests/utils:utils',
|
||||
]
|
||||
|
||||
objc_linters_test_sources = glob(['*.java'])
|
||||
objc_linters_test_deps = []
|
||||
for test_source in objc_linters_test_sources:
|
||||
target_name = test_source.replace("/", "_")[:-len(".java")]
|
||||
objc_linters_test_deps.append(target_name)
|
||||
|
||||
java_test(
|
||||
name=target_name,
|
||||
srcs=[test_source],
|
||||
deps=tests_dependencies,
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
source='7',
|
||||
target='7',
|
||||
)
|
||||
|
||||
java_test(
|
||||
name='linters',
|
||||
deps=[':' + x for x in objc_linters_test_deps],
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
)
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class NSNumber2Test {
|
||||
|
||||
public static final String NSNUMBER_FILE =
|
||||
"infer/tests/codetoanalyze/objc/linters/badpointer.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String BAD_POINTER_COMPARISON = "BAD_POINTER_COMPARISON";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommand(
|
||||
folder,
|
||||
NSNUMBER_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void badNSNumberPointerComparisonShouldBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain " + BAD_POINTER_COMPARISON,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{17, 26, 33, 85, 99, 106, 121, 128, 135, 139}));
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class NSNumberTest {
|
||||
|
||||
public static final String NSNUMBER_FILE =
|
||||
"infer/tests/codetoanalyze/objc/linters/nsnumber.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String BAD_POINTER_COMPARISON = "BAD_POINTER_COMPARISON";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommand(
|
||||
folder,
|
||||
NSNUMBER_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void badNSNumberPointerComparisonShouldBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain " + BAD_POINTER_COMPARISON,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{13, 18, 23, 43})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class RegisteredObserver {
|
||||
|
||||
public static final String VCFile =
|
||||
"infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommandSimple(
|
||||
folder,
|
||||
VCFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisteredObserverShouldBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
String[] methods = {
|
||||
//"fooError", "barError"
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + REGISTERED_OBSERVER,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
REGISTERED_OBSERVER,
|
||||
VCFile,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class RegisteredObserver2 {
|
||||
|
||||
public static final String VCFile2 =
|
||||
"infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommandSimple(
|
||||
folder,
|
||||
VCFile2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisteredObserverShouldNotBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
String[] methods = {};
|
||||
assertThat(
|
||||
"Results should contain " + REGISTERED_OBSERVER,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
REGISTERED_OBSERVER,
|
||||
VCFile2,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class RegisteredObserver3 {
|
||||
|
||||
public static final String VCFile3 =
|
||||
"infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
|
||||
inferCmd = InferRunner.createObjCLintersCommandSimple(
|
||||
folder,
|
||||
VCFile3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisteredObserverShouldBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
String[] methods = {
|
||||
"frontendChecks"
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + REGISTERED_OBSERVER,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{14}));
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class RegisteredObserver4 {
|
||||
|
||||
public static final String VCFile =
|
||||
"infer/tests/codetoanalyze/objc/linters/registered_observer/Person.m";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String REGISTERED_OBSERVER = "REGISTERED_OBSERVER_BEING_DEALLOCATED";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCLintersCommandSimple(
|
||||
folder,
|
||||
VCFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RegisteredObserverShouldBeFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain " + REGISTERED_OBSERVER,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[] {80, 97})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objc.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class StrongDelegateTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objc/linters/strong_delegate.m";
|
||||
|
||||
private static ImmutableList<String> inferCmdFraction;
|
||||
|
||||
public static final String STRONG_DELEGATE_WARNING = "STRONG_DELEGATE_WARNING";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmdFraction = InferRunner.createObjCLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnStrongDelegate()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction);
|
||||
assertThat(
|
||||
"Results should contain " + STRONG_DELEGATE_WARNING,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{15, 19, 21, 23, 25}));
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
tests_dependencies = [
|
||||
'//infer/lib/java/android:android',
|
||||
'//dependencies/java/guava:guava',
|
||||
'//dependencies/java/junit:hamcrest',
|
||||
'//dependencies/java/jackson:jackson',
|
||||
'//dependencies/java/jsr-305:jsr-305',
|
||||
'//dependencies/java/junit:junit',
|
||||
'//dependencies/java/opencsv:opencsv',
|
||||
'//infer/tests/utils:utils',
|
||||
]
|
||||
|
||||
objcpp_linters_test_sources = glob(['*.java'])
|
||||
objcpp_linters_test_deps = []
|
||||
for test_source in objcpp_linters_test_sources:
|
||||
target_name = test_source.replace("/", "_")[:-len(".java")]
|
||||
objcpp_linters_test_deps.append(target_name)
|
||||
|
||||
java_test(
|
||||
name=target_name,
|
||||
srcs=[test_source],
|
||||
deps=tests_dependencies,
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
source='7',
|
||||
target='7',
|
||||
)
|
||||
|
||||
java_test(
|
||||
name='componentkit',
|
||||
deps=[':' + x for x in objcpp_linters_test_deps],
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
)
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objcpp.componentkit;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsLinesOfError;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class MutableLocalVariableInNonComponentTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objcpp/componentkit/Test2.mm";
|
||||
private static ImmutableList<String> inferCmd;
|
||||
public static final String MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE =
|
||||
"MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCPPLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
@Test
|
||||
public void MLVsInComponentFile()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should not contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE,
|
||||
inferResults,
|
||||
not(containsLinesOfError(new int[]{38}, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE)));
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objcpp.componentkit;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class MutableLocalVariableTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objcpp/componentkit/Test.mm";
|
||||
private static ImmutableList<String> inferCmd;
|
||||
public static final String MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE =
|
||||
"MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCPPLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MLVsInComponentFile()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{58, 69, 74, 76, 80, 85, 103, 105}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MLVsInNewWithString()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain " + MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE,
|
||||
inferResults,
|
||||
contains(MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, FILE, "newWithString:"));
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
tests_dependencies = [
|
||||
'//infer/lib/java/android:android',
|
||||
'//dependencies/java/guava:guava',
|
||||
'//dependencies/java/junit:hamcrest',
|
||||
'//dependencies/java/jackson:jackson',
|
||||
'//dependencies/java/jsr-305:jsr-305',
|
||||
'//dependencies/java/junit:junit',
|
||||
'//dependencies/java/opencsv:opencsv',
|
||||
'//infer/tests/utils:utils',
|
||||
]
|
||||
|
||||
objcpp_linters_test_sources = glob(['*.java'])
|
||||
objcpp_linters_test_deps = []
|
||||
for test_source in objcpp_linters_test_sources:
|
||||
target_name = test_source.replace("/", "_")[:-len(".java")]
|
||||
objcpp_linters_test_deps.append(target_name)
|
||||
|
||||
java_test(
|
||||
name=target_name,
|
||||
srcs=[test_source],
|
||||
deps=tests_dependencies,
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
source='7',
|
||||
target='7',
|
||||
)
|
||||
|
||||
java_test(
|
||||
name='linters',
|
||||
deps=[':' + x for x in objcpp_linters_test_deps],
|
||||
visibility=[
|
||||
'PUBLIC',
|
||||
],
|
||||
)
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objcpp.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class BlockCaptureCXXRefTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String REFERENCE_CAPTURED = "CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createObjCPPLintersCommand(folder, FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmd);
|
||||
assertThat(
|
||||
"Results should contain the correct " + REFERENCE_CAPTURED,
|
||||
inferResults,
|
||||
containsOnlyLines(
|
||||
new int[]{
|
||||
20,
|
||||
37
|
||||
}));
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.objcpp.linters;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsLineNumbers.containsOnlyLines;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class GlobalVarTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/objcpp/linters/global-var/B.mm";
|
||||
|
||||
private static ImmutableList<String> inferCmdFraction;
|
||||
|
||||
public static final String GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL =
|
||||
"GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmdFraction = InferRunner.createObjCPPLintersCommand(
|
||||
folder,
|
||||
FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsGlobalVar()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferObjC(inferCmdFraction);
|
||||
assertThat(
|
||||
"Results should contain " + GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL,
|
||||
inferResults,
|
||||
containsOnlyLines(new int[]{30, 32, 34}));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue