False Positive NS_ENUM Syntax in Obective-C

This is a valid expression in Objective-C in order to expose the usage to Swift language when we bridging to Swift files.

SonarQube version: 8.9.6


I’m not understanding the problem. Both of the issues shown in your screenshot are about naming conventions. The issues don’t indicate that the expression is invalid; just that the names in it don’t conform to your own organization’s naming requirements.

Is there something I’m not understanding?


The NS_ENUM is a macro in Objective-C allow you to define an enum. Which will enable the Swift language to understand the code.

Then the CommandType is suppose be a class name so when Swift language read this file and it will understand that is a class name.

The problem is that SonarQube think this NS_ENUM is a function but sonarQube should recognize this keyword and should not follow the same rule as function.


So you’re saying there’s no other way these things could viably be named. And is there some way the Objective-C analysis should have recognized this as exposing the usage to Swift? I.e. is there syntax that should have flagged the rule not to fire on this particular syntax?


NS_ENUM and some others such as NS_OPTIONS are pre-defined macro keywords that should be recognized by SonarQube and not to fire this rule.

Here is a document from Apple: Adopting Modern Objective-C

1 Like

Hello @RedDragonJ,

Thanks a lot for your detailed explanation and for reporting the issue.
Indeed, you are right: we should not raise issues here. I have created two tickets to fix these false positives: CPP-3737 and CPP-3736.

Have a nice day

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.