Added a lint for namespace

Reviewed By: dulmarod

Differential Revision: D5103566

fbshipit-source-id: 4092e73
master
Dino Distefano 8 years ago committed by Facebook Github Bot
parent 741e527826
commit e77ca182a5

@ -8,13 +8,14 @@
TESTS_DIR = ../../..
ANALYZER = linters
CLANG_OPTIONS = -x objective-c -fobjc-arc -c
INFER_OPTIONS = --linters-def-file linters_example.al --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed
CLANG_OPTIONS = -fobjc-arc -c
INFER_OPTIONS = --cxx --linters-def-file linters_example.al --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed
INFERPRINT_OPTIONS = --issues-tests
SOURCES = \
$(wildcard *.m) \
$(wildcard */*.m) \
$(wildcard *.mm) \
$(wildcard *.c) \
include $(TESTS_DIR)/clang.make

@ -1,6 +1,7 @@
codetoanalyze/objc/linters-for-test-only/implicit_cast.c, main, 10, TEST_VAR_TYPE_CHECK, []
codetoanalyze/objc/linters-for-test-only/implicit_cast.c, main, 11, TEST_IMPLICIT_CAST_CHECK, []
codetoanalyze/objc/linters-for-test-only/implicit_cast.c, main, 11, TEST_VAR_TYPE_CHECK, []
codetoanalyze/objc/linters-for-test-only/namespace.mm, Linters_dummy_method, 9, TEST_NAMESPACE_NAME, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo:, 13, TEST_BUILTIN_TYPE, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo:, 13, TEST_RETURN_METHOD, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, A_foo:, 19, TEST_BUILTIN_TYPE, []

@ -178,8 +178,19 @@ DEFINE-CHECKER TEST_NTH_PARAM_TYPE_CHECK = {
SET report_when =
WHEN
objc_method_has_nth_parameter_of_type("2", "REGEXP('This.+')*")
HOLDS-IN-NODE ObjCMethodDecl;
HOLDS-IN-NODE ObjCMethodDecl;
SET message = "Found a method with nth parameter of type....";
};
DEFINE-CHECKER TEST_NAMESPACE_NAME = {
SET report_when =
WHEN
declaration_has_name(REGEXP("FirstNam*"))
HOLDS-IN-NODE NamespaceDecl;
SET message = "Found a namespace with name....";
};

@ -0,0 +1,16 @@
/*
* Copyright (c) 2017 - 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.
*/
namespace FirstNameSpace {
namespace SecodNameSpace {
class C {
void m();
};
}
void SecodNameSpace::C::m() {}
}
Loading…
Cancel
Save