Ignoring Violations by line/file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Ignoring Violations by line/file

Florian Hopf
Hi,
 
we currently switched to Sonar 4.0 for our project. We are working with a larger code base that is initially generated but will be modified by our team. The coding conventions of the generated code do not match our Sonar settings and as the generated code base is quite large we can't fix all violations in advance.
 
We were planning to exclude all the violations of the generated code by querying the API and then set the result to be ignored by file and line. The intention is that once the file is touched by a developer the lines will change and the violations are then shown again. This way we can make sure that all the violations need to be fixed once a file is touched.
 
This used to be possible with the Switch Off Violations Plugin as described at http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html but doesn't seem to be possible anymore with the new features in Sonar 4.
 
Is there any way to do something similar or is it planned to add the possibility to ignore violations by file and line again? Also I would be interested how other people handle those situations when it comes to legacy code that you can't clean up in one step.
 
Regards and thanks
Florian
Reply | Threaded
Open this post in threaded view
|

Re: Ignoring Violations by line/file

David Racodon-2
Hi Florian,

This used to be possible with the Switch Off Violations Plugin as described at http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html but doesn't seem to be possible anymore with the new features in Sonar 4.
 
I confirm that this approach is no longer possible with SonarQube 4.0.


We were planning to exclude all the violations of the generated code by querying the API and then set the result to be ignored by file and line. The intention is that once the file is touched by a developer the lines will change and the violations are then shown again. This way we can make sure that all the violations need to be fixed once a file is touched.

I'm not convinced at all by this approach... Why fixing generated code once a file is touched? Why not only care of the code added or modified by the developer on this generated file? Why would you like to clean up the entire file? Meaning retesting all the features that are cleaned up as well.

 
is it planned to add the possibility to ignore violations by file and line again?

No. Because, aside from your very particular approach, this feature is useless.

Regards, 


David RACODON | SonarSource
Senior Consultant

---------------------------------------------
  Sign up to our newsletter here!
---------------------------------------------


On Tue, Jan 7, 2014 at 12:51 PM, wp11011936-mailinglists <[hidden email]> wrote:
Hi,
 
we currently switched to Sonar 4.0 for our project. We are working with a larger code base that is initially generated but will be modified by our team. The coding conventions of the generated code do not match our Sonar settings and as the generated code base is quite large we can't fix all violations in advance.
 
We were planning to exclude all the violations of the generated code by querying the API and then set the result to be ignored by file and line. The intention is that once the file is touched by a developer the lines will change and the violations are then shown again. This way we can make sure that all the violations need to be fixed once a file is touched.
 
This used to be possible with the Switch Off Violations Plugin as described at http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html but doesn't seem to be possible anymore with the new features in Sonar 4.
 
Is there any way to do something similar or is it planned to add the possibility to ignore violations by file and line again? Also I would be interested how other people handle those situations when it comes to legacy code that you can't clean up in one step.
 
Regards and thanks
Florian

Reply | Threaded
Open this post in threaded view
|

RE: Ignoring Violations by line/file

mattadamson

Also to add to that the emphasis with Sonar and technical debt in general is making sure you reduce violations over time. Always leave the camp ground cleaner than you left it. You shouldn’t focus on removing all violations on a single file as soon as its changed rather encourage developers to remove a few violations from each file they change.  Sonar will show this as lots of green rather than red when you are adding to your technical debt.

 

i.e. don’t get so hung up on how many violations you have rather make sure your differential trends are on a downward spiral J

 

From: David Racodon [mailto:[hidden email]]
Sent: 07 January 2014 16:14
To: [hidden email]
Subject: Re: [sonar-user] Ignoring Violations by line/file

 

Hi Florian,

 

This used to be possible with the Switch Off Violations Plugin as described at http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html but doesn't seem to be possible anymore with the new features in Sonar 4.

 

I confirm that this approach is no longer possible with SonarQube 4.0.

 

 

We were planning to exclude all the violations of the generated code by querying the API and then set the result to be ignored by file and line. The intention is that once the file is touched by a developer the lines will change and the violations are then shown again. This way we can make sure that all the violations need to be fixed once a file is touched.

 

I'm not convinced at all by this approach... Why fixing generated code once a file is touched? Why not only care of the code added or modified by the developer on this generated file? Why would you like to clean up the entire file? Meaning retesting all the features that are cleaned up as well.

 

 

is it planned to add the possibility to ignore violations by file and line again?

 

No. Because, aside from your very particular approach, this feature is useless.

 

Regards, 


 

David RACODON | SonarSource
Senior Consultant

 

---------------------------------------------

  Sign up to our newsletter here!

---------------------------------------------

 

On Tue, Jan 7, 2014 at 12:51 PM, wp11011936-mailinglists <[hidden email]> wrote:

Hi,

 

we currently switched to Sonar 4.0 for our project. We are working with a larger code base that is initially generated but will be modified by our team. The coding conventions of the generated code do not match our Sonar settings and as the generated code base is quite large we can't fix all violations in advance.

 

We were planning to exclude all the violations of the generated code by querying the API and then set the result to be ignored by file and line. The intention is that once the file is touched by a developer the lines will change and the violations are then shown again. This way we can make sure that all the violations need to be fixed once a file is touched.

 

This used to be possible with the Switch Off Violations Plugin as described at http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html but doesn't seem to be possible anymore with the new features in Sonar 4.

 

Is there any way to do something similar or is it planned to add the possibility to ignore violations by file and line again? Also I would be interested how other people handle those situations when it comes to legacy code that you can't clean up in one step.

 

Regards and thanks

Florian

 

Reply | Threaded
Open this post in threaded view
|

Re: Ignoring Violations by line/file

Florian Hopf
David and Matthew,

thanks a lot for your feedback, appreciated.

Our intention was to make sure that the code will be in a consistent
form over time. As the generated code will be a part of our project we
want to have it in the same style we are using when developing new code.

Nevertheless I see that we can't go this way so we will use the trends
to make sure that we are going in the right direction.

Thanks again
Florian

On 07.01.2014 21:44, Adamson, Matthew wrote:> Also to add to that the
emphasis with Sonar and technical debt in
 > general is making sure you reduce violations over time. Always leave the
 > camp ground cleaner than you left it. You shouldn’t focus on removing
 > all violations on a single file as soon as its changed rather encourage
 > developers to remove a few violations from each file they change.  Sonar
 > will show this as lots of green rather than red when you are adding to
 > your technical debt.
 >
 > i.e. don’t get so hung up on how many violations you have rather make
 > sure your differential trends are on a downward spiral J
 >
 > *From:*David Racodon [mailto:[hidden email]]
 > *Sent:* 07 January 2014 16:14
 > *To:* [hidden email]
 > *Subject:* Re: [sonar-user] Ignoring Violations by line/file
 >
 > Hi Florian,
 >
 >     This used to be possible with the Switch Off Violations Plugin as
 >     described at
 >
http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html
 >     but doesn't seem to be possible anymore with the new features in
 >     Sonar 4.
 >
 > I confirm that this approach is no longer possible with SonarQube 4.0.
 >
 >     We were planning to exclude all the violations of the generated code
 >     by querying the API and then set the result to be ignored by file
 >     and line. The intention is that once the file is touched by a
 >     developer the lines will change and the violations are then shown
 >     again. This way we can make sure that all the violations need to be
 >     fixed once a file is touched.
 >
 > I'm not convinced at all by this approach... Why fixing generated code
 > once a file is touched? Why not only care of the code added or modified
 > by the developer on this generated file? Why would you like to clean up
 > the entire file? Meaning retesting all the features that are cleaned up
 > as well.
 >
 >     is it planned to add the possibility to ignore violations by file
 >     and line again?
 >
 > No. Because, aside from your very particular approach, this feature is
 > useless.
 >
 > Regards,
 >
 >
 > *David RACODON | **SonarSource
 > */Senior Consultant/
 >
 > http://sonarsource.com <http://sonarsource.com/>
 >
 > ---------------------------------------------
 >
 >    Sign up to our newsletter here
 > <http://www.sonarsource.com/company/news/newsletter/>!
 >
 > ---------------------------------------------
 >
 > On Tue, Jan 7, 2014 at 12:51 PM, wp11011936-mailinglists
 > <[hidden email] <mailto:[hidden email]>>
wrote:
 >
 > Hi,
 >
 > we currently switched to Sonar 4.0 for our project. We are working with
 > a larger code base that is initially generated but will be modified by
 > our team. The coding conventions of the generated code do not match our
 > Sonar settings and as the generated code base is quite large we can't
 > fix all violations in advance.
 >
 > We were planning to exclude all the violations of the generated code by
 > querying the API and then set the result to be ignored by file and line.
 > The intention is that once the file is touched by a developer the lines
 > will change and the violations are then shown again. This way we can
 > make sure that all the violations need to be fixed once a file is
touched.
 >
 > This used to be possible with the Switch Off Violations Plugin as
 > described at
 >
http://blog.florian-hopf.de/2013/10/switch-off-legacy-code-violations-in.html 

 > but doesn't seem to be possible anymore with the new features in Sonar 4.
 >
 > Is there any way to do something similar or is it planned to add the
 > possibility to ignore violations by file and line again? Also I would be
 > interested how other people handle those situations when it comes to
 > legacy code that you can't clean up in one step.
 >
 > Regards and thanks
 >
 > Florian
 >


--
Florian Hopf
Freelance Software Developer

http://blog.florian-hopf.de

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email