SonarQubeCommunity / sonar-erlang

12 stars 23 forks source link

Handle -sonar_ignores attribute declared in erlang code #47

Closed tothlac closed 3 years ago

tothlac commented 3 years ago

In some cases it is not easy to translate a not tail recursive function into its tail recursive implementation. Theoretically it is always possible but sometimes the tail recursive version will be much uglier and longer and even less efficient. Besides that it is not always a problem to have not tail recursive functions if we know the recursion is not infinite.

For java code it is possible to indicate it in the source code that the given function should not be validated by sonar checks. https://stackoverflow.com/questions/24058137/sonarqube-suppress-warnings-on-function-level

It would be good to implement something in the erlang plugin which works similarly. People should be able to indicate that the given function/check implemented by the plugin should be suppressed. Something similar like ignore warnings option for dialyzer.

-dialyzer([{nowarn_function, [f/0]}, no_improper_lists]).

For instance:

-sonar_ignores([{no_tail_recursive_call, [f1/0, 
                                          f2/1]},
                {depth_of_cases, [f2/1,
                                  f3/1]},
                {indentation_size, [f2/1]}]).
kalidasya commented 3 years ago

hey, I do not maintain the project anymore, you can either create a MR or I would suggest create an issue at: https://github.com/evolution-gaming/sonar-erlang where you can find a more recent version of the plugin.