Code bad smell question

1Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    sonarcloud
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
    I find some bad smell describing problems like this
    (1)

    maybe some code comments are misidentified as code?
    Here is a wrong scanning result, this block is a comment, but one sentence is taken for a code line.
    URL:code small
    (2)

    Function pointers are scanned here as a parameter. How do I fix similar code? I don’t seem to have found a solution from your description of the solution.
    URL: Function pointer
  • steps to reproduce
    (1) sonarcloud
  • potential workaround

thanks

Hello @freeeyes,

About the comments being misidentified as code, it’s true: Our algorithm is currently a little too naive in that respect. We already have a ticket about it. Meanwhile, you should just ignore that issue of the rule.

About the second question, what about writing:

   m_objHashMessageLogicList.bind(CONSOLEMESSAHE_UNLOADMOUDLE, &DoMessage_UnLoadModule);

?

Thank you,

thanks,JolyLoic

About the second question:
you mean must used function pointer to a pointer?
this code is bind an event ID to the corresponding function pointer.
like this:

Exceptions

Callback functions are a common occurrence and are usually not passed with a preceding &. There is however little ambiguity so this rule ignores function identifiers when used as a parameter of a function call.

registerEvent(AnEvent, foo);

it may be compliance with exceptions?

You are right that this code should be accepted as being an exception.

I could see in your code that the reason why we do not detect this situation is because the function pointer is passed by const reference, and we forgot to test that situation. I created a ticket to solve this false positive. You can track its status to know when it will be solved. Thank you for your help!

Meanwhile, you should just ignore these violations, or modify the code as I suggested, it will also work and be more explicit.

thanks your help.
:slight_smile: