Adding some our specific coding rules to Cfamily

Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
I am using Sonarqube * Enterprise Edition * Version 8.9.3 (build 48735)

What are you trying to achieve
I am trying to add some our specific coding rule for C
Actually beside common rule as in Built-in rule of Cfamily plugin we need to add some specific rule to scan our source code. So I just have some below questions:

  1. Is it possible to create/write new own rules and add to the built-in rule or we can ask someone for helping us to do that

  2. In case possible please let me know steps to do that

I would like to give you an example to help you understand better my mean.
Below example I want my function should return our internal defined return value my_status_t instead of normal return value true/false

// Don't do:
bool do_something()
{
  my_status_t my_status;
  // [...]
  my_status = do_anything(var);
  // [...]
  if (my_status == STATUS_OK) {
    return true;
  } else {
    return false;
  }
}


// Instead do:
my_status_t do_something()
{
  my_status_t my_status;
  // [...]
  my_status = do_anything(var);
  // [...]
  return my_status;
}

Thank you !

Hello @thanhngo91,

We don’t support user implemented rules in the CFamily analyzer.
We try to implement the useful rules suggested by our users instead.
If you have ideas, please create a post per rule under “suggest new feature” specifying the rule ideas that you are looking for and we will take that into considerations.
(Note that these new rules are usually added to latested non-LTS SQ versions and sonarcloud first so the process might be long for you if you are sticking with LTS)

Thanks,

1 Like

Thank you @Abbas_Sabra for sharing information.

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