From f54b84c751a263dc6652e4288f1a24945f5e5f24 Mon Sep 17 00:00:00 2001 From: Ryan Rhee Date: Fri, 23 Sep 2016 11:26:52 -0700 Subject: [PATCH] [componentkit][test] Move mock CK imports to own .h file Reviewed By: dulmarod Differential Revision: D3909240 fbshipit-source-id: 66e8b71 --- .../componentkit/FakeComponentKitHeader.h | 26 +++++++++++++++++++ .../objcpp/linters/componentkit/Test.mm | 23 +--------------- .../codetoanalyze/objcpp/linters/issues.exp | 16 ++++++------ 3 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 infer/tests/codetoanalyze/objcpp/linters/componentkit/FakeComponentKitHeader.h diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/FakeComponentKitHeader.h b/infer/tests/codetoanalyze/objcpp/linters/componentkit/FakeComponentKitHeader.h new file mode 100644 index 000000000..e43200079 --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/linters/componentkit/FakeComponentKitHeader.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#import + +// Mimic importing CKComponnet +@interface CKComponent : NSObject +@end + +// Mimic importing CKCompositeComponnet +@interface CKCompositeComponent : CKComponent ++ (instancetype)newWithComponent:(CKComponent*)component; +@end + +// Mimic importing CKLabelComponent +typedef struct { NSString* string; } LabelAttributes; + +typedef struct { int thisStructIsEmpty; } ViewAttributes; + +typedef struct { int thisStructIsEmpty; } CKSize; diff --git a/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm b/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm index 03d332b0e..1767c8f3e 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm +++ b/infer/tests/codetoanalyze/objcpp/linters/componentkit/Test.mm @@ -9,28 +9,7 @@ #import -// Mimic importing CKComponnet -@interface CKComponent : NSObject -@end -@implementation CKComponent -@end - -// Mimic importing CKCompositeComponnet -@interface CKCompositeComponent : CKComponent -+ (instancetype)newWithComponent:(CKComponent*)component; -@end -@implementation CKCompositeComponent -+ (instancetype)newWithComponent:(CKComponent*)component { - return nil; -} -@end - -// Mimic importing CKLabelComponent -typedef struct { NSString* string; } LabelAttributes; - -typedef struct { int thisStructIsEmpty; } ViewAttributes; - -typedef struct { int thisStructIsEmpty; } CKSize; +#import "FakeComponentKitHeader.h" @interface CKLabelComponent : CKCompositeComponent + (instancetype)newWithLabelAttributes:(LabelAttributes)labelAttributes diff --git a/infer/tests/codetoanalyze/objcpp/linters/issues.exp b/infer/tests/codetoanalyze/objcpp/linters/issues.exp index 0a98866c6..17830b106 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/issues.exp +++ b/infer/tests/codetoanalyze/objcpp/linters/issues.exp @@ -1,11 +1,11 @@ -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 +componentkit/Test.mm, BarComponent_new, 82, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, BarComponent_new, 84, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 48, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 53, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 55, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 59, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, FooComponent_newWithString:, 64, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE +componentkit/Test.mm, SomeClass_init, 37, 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, Linters_dummy_method, 30, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL