Skipping old code from code validation in sonar

早过忘川 提交于 2019-12-11 09:36:35

问题


We have a scenario where we got a .net project and it has some old code.

Now, we started implementing sonar code validation on this and unfortunately we got many validation issues from old code which is not written by us.

So, as per the agreement we are not supposed tho fix those issues.

Old and current code is available in SVN repository.

Is there any posssiblity to skip the old code based on SVN revision and performing the code validation only on the top of baseline changes?


回答1:


The only good way to do that for the moment is to:

  • analyze your existing code base in SonarQube
  • set a version on it (in "Project Configuration > History"), e.g. "BASE_LINE"
  • specify this version in the differential periods so that all your upcoming analyses are compared to this baseline



回答2:


This page from the SonarQube documentation might help http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus




回答3:


Actually we have tried to baseline the code and remove the existing issues by marking the issues as false positing using the following queries. USE XYZ

                SELECT [id]
,[kee]
        ,[component_id]
,[root_component_id]      
        ,[status]
,[resolution]        
                 FROM [XYZ].[dbo].[issues] where  [root_component_id]= 64421 and  status = 'OPEN' 
                 GO

Update query

USE XYZ

go begin transaction

UPDATE [XYZ].[dbo].[issues] SET
[status] = 'RESOLVED' ,[resolution] = 'FALSE-POSITIVE'

WHERE [root_component_id]= 64421 and status='OPEN' rollback transaction
GO


UPDATE [XYZ].[dbo].[issues] SET
[status] = 'RESOLVED' ,[resolution] = 'FALSE-POSITIVE'

WHERE [root_component_id]= 64421 and status='OPEN'


This will make all the records status as 'RESOLVED' and resolution as 'FALSE-POSITIVE'.

However, if the old file is modified, instead of doing code coverage for the new code, it is publishing the issues for old code as well in that file.

So, I think there would be another way to baseline the code, so that even though the old files are modified, it will perform the code coverage only on top of baseline. Is there any alternate way available using SVN revision numbers and baselining the code.



来源:https://stackoverflow.com/questions/26053453/skipping-old-code-from-code-validation-in-sonar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!