Cannot disable Drupal rule

Why can I not disable this Drupal-only rule in my custom rules for my custom profile?
Use of namespaces should be preferred to "include" or "require" functions

This is clearly not useful, and it destroys my quality rating.
I work with WP, not with Drupal, and I have my own rules.
I expect this to be removable… but it is not, it says it is “inherited” (of course, because it comes from the “Sonar way” profile which is a parent to my own custom profile)

Hey there.

This is as designed. You might want to chime in on this post:

This leaves you with two options:

  • Stop inheriting from the default Sonar Way
  • Excluding the rule entirely just for your project using Ignore Issues on Multiple Criteria (and setting a wildcard pattern for all files)

And, I’ll flag this for attention for someone to review whether it should be in the default profile or not. It would be great if you could give an example where it is clearly not useful, outside of Drupal code (where an issue is raised for you)

That rule is the only one Drupal rule (or at least the only one named with Drupal) present the the “Sonar way”, and I feel a little uncomfortable that the “Sonar Way” for PHP should suddenly start using Drupal rules.
WordPress is used in approximately 40 times the amount of website worldwide versus Drupal, and uses PHP too… so this really does not add up to me why a default PHP scan would include an almost unused CMS’s rules

This rule might be useful for modern, new code. But about 90% of all plugins and themes, WP itself, does not use namespaces, at all.
It is also quite overkill for most applications (small functional plugins), and newcomers are totally overwhelmed
Thus I do not think this rule is particularly useful, specially since require language constructs are perfectly fine to use. They do what they are designed for.

Stopping to inherit is not an option, we would lose all the “goodies” from the “parent”, I believe.
I will try the second option until the rule hopefully gets removed from the sonar way.

Thank you!

Thanks for all the feedback. And I understand your point about not wanting to stop inheriting from the built-in Sonar Way (I wouldn’t want to either).

Somebody from the right team should chime in soon!

1 Like