Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many warnings in XCode 9.0 when running the static analyzer (Product > Analyze) #186

Open
yoasha opened this issue Oct 19, 2017 · 13 comments

Comments

@yoasha
Copy link

yoasha commented Oct 19, 2017

The following warning appears in many files:
Converting a pointer value of type 'NSNumber * _Nullable' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue

@yoasha
Copy link
Author

yoasha commented Oct 19, 2017

image

@greg-db
Copy link
Contributor

greg-db commented Oct 19, 2017

Thanks for the report! I'll ask the team to get this cleaned up.

@yoasha
Copy link
Author

yoasha commented Apr 8, 2018

Running the static analyzer with latest version of Xcode (9.3) and latest version of Dropbox SDK via cocoapods (3.8.1 release) still generates many warnings that can potentially lead to bugs... (the code is checking for example for a positive value in NSNumber rather than in [NSNumber booleanValue]).

Can you produce these warnings on your side?

@scobbe
Copy link
Contributor

scobbe commented Apr 8, 2018

@yoasha: I'm not able to reproduce this on my end. Can you give a specific example of the warnings you're seeing?

I see a few places where we're missing != nil which isn't ideal, but I don't see any boolean correctness issues.

@yoasha
Copy link
Author

yoasha commented Apr 9, 2018

File:
/Pods/ObjectiveDropboxOfficial/Source/ObjectiveDropboxOfficial/Shared/Generated/ApiObjects/FileRequests/DBFileRequestsObjects.m:2231:7:

Method:
(BOOL)isEqualToUpdateFileRequestArgs:

Warning:
Converting a pointer value of type 'NSNumber * _Nullable' to a primitive boolean value; instead, either compare the pointer to nil or call -boolValue

Screenshot attached.
image

@yoasha yoasha closed this as completed Apr 9, 2018
@yoasha yoasha reopened this Apr 9, 2018
@yoasha
Copy link
Author

yoasha commented Apr 9, 2018

Sorry, I closed this issue by mistake.... I reopened it and added updated screenshot and warning details as requested.

@greg-db
Copy link
Contributor

greg-db commented Apr 9, 2018

Thanks for the additional information!

@yoasha
Copy link
Author

yoasha commented Apr 10, 2018

Can you reproduce it in your environment? Or is it a cocoa-pods config issue on my end that prevents me getting the latest and fixed code?

@greg-db
Copy link
Contributor

greg-db commented Apr 10, 2018

I just tried it, and I'm not able to reproduce it either. Do you have any non-default settings that may affect this?

It appears you have the latest version of the code. If pod update failed, you should see an error when you run it anyway.

@yoasha
Copy link
Author

yoasha commented Apr 11, 2018

I just looked into the source code directly on github and also confirmed that I have the latest code.

As far as I know, I have the default settings. Did you try to compile your project or did you explicitly select Xcode > Product > Analyze? Note that with standard compile the warnings are not appearing for me, but only when selecting the "Analyze" command.

Also note the following:

  • In the method isEqualToUpdateFileRequestArgs there is a code of if (self.open). However, the open property is defined as NSNumber *, so the analyzer warning (regardless of any environment configuration) is correctly alerting for a potential bug.

IMHO, the correct code regardless of any warnings appearing on Xcode would be if (self.open.boolValue)

This of course applies to all instances of this issue and not only to this method.

@greg-db
Copy link
Contributor

greg-db commented Apr 11, 2018

Thanks! Yes, I tried Product > Analyze specifically.

Anyway, this is open with the team. We'll follow up if/when we have an update for this.

@scobbe
Copy link
Contributor

scobbe commented Apr 11, 2018

@yoasha: The if (self.open) check in isEqualToUpdateFileRequestArgs is for nullability, not for a boolean value.

But of course if (self.open != nil) would be better. I'll try and fix it when I get the chance.

@yoasha
Copy link
Author

yoasha commented Apr 12, 2018

@scobbe : thanks for clarifying that check is for nullability. Changing this to if (self.open != nil) would surely remove some confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants