Skip to content

Some parts of the code look strange ==> refactoring might be needed #3

@dodikk

Description

@dodikk

1). Obsolete AND with true with no reason or value
https://github.com/jivesoftware/JiveAuthenticatingHTTPProtocol/blob/master/Source/JiveAuthenticatingHTTPProtocol/JAHPAuthenticatingHTTPProtocol.m#L256

shouldAccept = YES && [scheme isEqual:@"http"];

This is equivalent to shouldAccept = [scheme isEqual:@"http"]; according to the boolean algebra theory.

2). _cmd can be used for most delegate method forwarding.
https://github.com/jivesoftware/JiveAuthenticatingHTTPProtocol/blob/master/Source/JiveAuthenticatingHTTPProtocol/JAHPAuthenticatingHTTPProtocol.m#L527

3). "Pure C" assert() function used in objective-c methods instead of NSAssert() or NSParameterAssert() that provide better error messages and crash dumps.

4). Retain cycles and possibly memory leaks. No single "weakify" statement across the entire project.
For example :

    [self performOnThread:nil
                    modes:nil
                    block:^void()
    {
        // `self` captured by the block 
        //  `self` cannot be destroyed while the block "lives" (in the queue, for instance)
        //  both might live forever if not dismissed properly
        //
        [self mainThreadDidReceiveAuthenticationChallenge:challenge
                                        completionHandler:completionHandler];
    }];

If such lifetime behaviour is desired, some memory management related comments are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions