terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.81k stars 246 forks source link

Process error with Objective-C block #365

Open kingsword opened 1 year ago

kingsword commented 1 year ago
@implementation TestLizard
+ (UIImage *)sgb_imageWithSize:(CGSize)size drawBlock:(void (^)(CGContextRef context))drawBlock {
    if (!drawBlock) return nil;
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    if (!context) return nil;
    drawBlock(context);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
@end

deal with the code above, and get result:

Function name -> `sgb_imageWithSize: drawBlock: CGContextRef.image`,
Cyclomatic complexity -> 1
LOC -> 2

but in fact,

function name -> `sgb_imageWithSize: drawBlock:`
Cyclomatic complexity -> 3
LOC -> 10

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html