<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:59:38 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Whamcloud Community JIRA</title>
    <link>https://jira.whamcloud.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.4.14</version>
        <build-number>940014</build-number>
        <build-date>05-12-2023</build-date>
    </build-info>


<item>
            <title>[LU-6372] cppcheck to statically verify change in Gerrit</title>
                <link>https://jira.whamcloud.com/browse/LU-6372</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;As discussed on LWG meeting in Livermore we want to integrate cppcheck to check patches for community.&lt;/p&gt;

&lt;p&gt;At Seagate we found this very useful. Feedback to get that for community at LWG was positive.&lt;/p&gt;

&lt;p&gt;So here our first try:&lt;br/&gt;
&lt;a href=&quot;http://review.whamcloud.com/#/c/14087/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#/c/14087/&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://54.164.238.188/job/lustre_release_cppcheck/16/CppCheck_Report/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_release_cppcheck/16/CppCheck_Report/&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://54.164.238.188/job/lustre_release_cppcheck/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_release_cppcheck/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we would debug it and check that reports are clear.&lt;br/&gt;
Meanwhile please review and provide any feedback.&lt;br/&gt;
Also please consider new user to get it more friendly.&lt;/p&gt;</description>
                <environment></environment>
        <key id="29124">LU-6372</key>
            <summary>cppcheck to statically verify change in Gerrit</summary>
                <type id="3" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11318&amp;avatarType=issuetype">Task</type>
                                            <priority id="4" iconUrl="https://jira.whamcloud.com/images/icons/priorities/minor.svg">Minor</priority>
                        <status id="5" iconUrl="https://jira.whamcloud.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="wc-triage">WC Triage</assignee>
                                    <reporter username="denis_kondratenko">Denis Kondratenko</reporter>
                        <labels>
                    </labels>
                <created>Tue, 17 Mar 2015 16:03:07 +0000</created>
                <updated>Tue, 5 Dec 2017 05:07:02 +0000</updated>
                            <resolved>Tue, 5 Dec 2017 05:07:02 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>9</watches>
                                                                            <comments>
                            <comment id="109893" author="ryg_" created="Tue, 17 Mar 2015 19:23:31 +0000"  >&lt;p&gt;we need &quot;Stream Events&quot; permission for deep integration. may be it is good idea to use non-interactive user for it.&lt;/p&gt;</comment>
                            <comment id="109942" author="adilger" created="Wed, 18 Mar 2015 01:00:22 +0000"  >&lt;p&gt;Hi Denis, this is definitely an interesting project.  We&apos;ve been doing static code analysis with a different tool, but only manually so far because it doesn&apos;t allow the output to be generated easily.  I suspect there are different bugs to be found by cppcheck or clang.  Our current process for fixing these minor issues is to file a separate bug for each release (e.g. one for 2.8.0 so that it can be marked with &quot;Fix Version&quot; for that release and closed as part of the release) and then push multiple patches for the various issues found by static analysis.&lt;/p&gt;

&lt;p&gt;If you want to take it a step further, it would be possible to add static analysis for all new patches submitted to Gerrit in a similar manner to HPDD Checkpatch, which is using the Gerrit REST API from a remote system to add comments for individual lines in patches.  The script to implement the parsing of the &lt;tt&gt;checkpatch.pl&lt;/tt&gt; output and posting as per-line comments to Gerrit is in &lt;tt&gt;contrib/scripts/gerrit_checkpatch.py&lt;/tt&gt;.  If this of interest to you, we can create a separate Gerrit account for this kind of automated analysis (e.g. &quot;Seagate CPPCheck&quot; or whatever you want).  I think that would be more useful than referencing a remote website, since it puts the comments into context on the patch itself, and makes it easier to verify that the issues have been fixed when the patch is refreshed.&lt;/p&gt;</comment>
                            <comment id="110001" author="denis_kondratenko" created="Wed, 18 Mar 2015 15:55:09 +0000"  >&lt;p&gt;Hi Andreas,&lt;/p&gt;

&lt;p&gt;we need some &lt;b&gt;Static Analyzer&lt;/b&gt; Gerrit account for this activity to get events from Gerrit.&lt;/p&gt;

&lt;p&gt;&amp;gt;Our current process for fixing these minor issues&lt;br/&gt;
OK. That is good for planned work - run - file and fix.&lt;br/&gt;
Goal of this one - find issues that were introduced by patch.&lt;/p&gt;

&lt;p&gt;But problem is that cppcheck is not accurate. The scope of static analyzer could be wider than changes. Like you remove variable from the expression and static analyzer would fire up error in the beginning of the file.&lt;br/&gt;
So maybe commenting in each line is not good idea as it would comment code that wasn&apos;t touched by patch itself ...&lt;/p&gt;

&lt;p&gt;What probably could be done if needed is to store issues that cppcheck found for the file and report only issues that are different with a patch.&lt;/p&gt;

&lt;p&gt;So we need find out right process for this tool. Because looking to number of comments inside Gerrit - it is really easy to miss that report.&lt;/p&gt;

&lt;p&gt;Also it might be a good process to fix all issues from static analyzer even if they aren&apos;t related to patch itself - that would allow to progress faster with smaller portions without opening new ticket.&lt;/p&gt;

&lt;p&gt;How we could get a user?&lt;br/&gt;
What your suggestion about the process ?&lt;/p&gt;</comment>
                            <comment id="110003" author="denis_kondratenko" created="Wed, 18 Mar 2015 15:58:34 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.whamcloud.com/secure/ViewProfile.jspa?name=morrone&quot; class=&quot;user-hover&quot; rel=&quot;morrone&quot;&gt;morrone&lt;/a&gt; can you also suggest something?&lt;/p&gt;</comment>
                            <comment id="110034" author="adilger" created="Wed, 18 Mar 2015 19:23:48 +0000"  >&lt;p&gt;Denis, I think you should be able to create the account for this yourself, just by registering a new email address and naming it what you want (you probably don&apos;t want to use your regular email address, since it could be added to hundreds of patches).  I&apos;d recommend something more specific than &quot;Static Analyzer&quot; because there may be multiple tools like this in the future.  Instead, I&apos;d recommend &quot;Seagate CPPCheck&quot; or &quot;CPPCheck Static Analyzer&quot; or similar.  If you have problems with this, please let me know.&lt;/p&gt;

&lt;p&gt;I agree that cppcheck is not completely accurate, which is why this tool should NOT automatically mark a patch with +/-1, but only add comments to the patch, as is done with HPDD Checkpatch.  Before the tool is run automatically on every new patch, the majority of existing defects should be fixed and/or excluded via separate series of patches, so that only issues related to each new patch are flagged.  Otherwise, it could cause the scope of a patch to continue to grow as more issues are fixed.  One option is to run cppcheck on the whole file, but only include errors within the scope (e.g. &lt;tt&gt;&amp;#64;&amp;#64; &amp;#45;3979,6 +3979,10 &amp;#64;&amp;#64;&lt;/tt&gt; ) of each patch hunk.  That would allow finding and fixing existing defects within code that is being modified without including all the defects in the whole file.&lt;/p&gt;

&lt;p&gt;As for Stream Events permission - we don&apos;t even use this for HPDD Checkpatch, because events can be missed if the reviewing machine can&apos;t communicate with Gerrit for some reason or if the script is stopped, crashes, whatever.  Instead, the script polls Gerrit for new changes that have not been reviewed, which doesn&apos;t impose any significant overhead.  The &lt;tt&gt;contrib/scripts/gerrit-checkpatch.py&lt;/tt&gt; script is fairly well written and easily understood, so I&apos;d recommend using it as a starting point for integration once you get that far. It is already designed to parse the output from other tools, so it may be a trivial matter to adapt it to run against the cppcheck output.&lt;/p&gt;</comment>
                            <comment id="110036" author="jhammond" created="Wed, 18 Mar 2015 19:42:53 +0000"  >&lt;p&gt;&amp;gt; Denis, I think you should be able to create the account for this yourself, just by registering a new email address and naming it what you want (you probably don&apos;t want to use your regular email address, since it could be added to hundreds of patches). I&apos;d recommend something more specific than &quot;Static Analyzer&quot; because there may be multiple tools like this in the future. Instead, I&apos;d recommend &quot;Seagate CPPCheck&quot; or &quot;CPPCheck Static Analyzer&quot; or similar. If you have problems with this, please let me know.&lt;/p&gt;

&lt;p&gt;The last time I looked at this I couldn&apos;t figure out how to authenticate with gerrit (to use the REST API) except to use password authentication. Setting up a password for an account will require the help of a gerrit administrator. You need to create the account first.&lt;/p&gt;

&lt;p&gt;&amp;gt; I agree that cppcheck is not completely accurate, which is why this tool should NOT automatically mark a patch with +/-1, but only add comments to the patch, as is done with HPDD Checkpatch. Before the tool is run automatically on every new patch, the majority of existing defects should be fixed and/or excluded via separate series of patches, so that only issues related to each new patch are flagged. Otherwise, it could cause the scope of a patch to continue to grow as more issues are fixed. One option is to run cppcheck on the whole file, but only include errors within the scope (e.g. @@ -3979,6 +3979,10 @@ ) of each patch hunk. That would allow finding and fixing existing defects within code that is being modified without including all the defects in the whole file.&lt;/p&gt;

&lt;p&gt;Any approach that requires us to first fix all known issues then start adding warnings will never catch up. Perhaps just filter the warning to those within 15 lines of a changed line. Or to the same function if that can be done easily. It&apos;s not perfect but it&apos;s something.&lt;/p&gt;</comment>
                            <comment id="110147" author="ryg_" created="Thu, 19 Mar 2015 19:36:51 +0000"  >&lt;p&gt;Few comments about current implementation:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;cppcheck is oriented to work with full files. current steps are:
	&lt;ul&gt;
		&lt;li&gt;checkout gerrit revision&lt;/li&gt;
		&lt;li&gt;select touched files&lt;/li&gt;
		&lt;li&gt;run cppcheck on selected files and store results&lt;/li&gt;
		&lt;li&gt;checkout previous commit&lt;/li&gt;
		&lt;li&gt;do cppcheck on same file set, save results&lt;/li&gt;
		&lt;li&gt;get only new results for report generation&lt;br/&gt;
 Decreasing context for code analyzers is not so good and I prefer to keep current schema.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Current algorithm decreases number of warnings and often developer see 0-5 warnings, so there is no issue &quot;first fix all known issue&quot;&lt;/li&gt;
	&lt;li&gt;Next improving is smart calculation of changes include code line(or code line hash) for avoid including warnings after code insertion/removing&lt;/li&gt;
&lt;/ol&gt;


&lt;blockquote&gt;
&lt;p&gt;Stream Events permission - we don&apos;t even use this for HPDD Checkpatch, because events can be missed if the reviewing machine can&apos;t communicate with Gerrit for some reason or if the script is stopped, crashes, whatever.&lt;/p&gt;&lt;/blockquote&gt; 
&lt;p&gt;I agree, that outages could be issue.  But it is not very important service and may be we could start integration step-by-step and start REST usage when we observe how outage disturb us? Now we use from jenkins not only notification about event but also cloned repo with checkout-ed revision.&lt;/p&gt;</comment>
                            <comment id="110198" author="denis_kondratenko" created="Fri, 20 Mar 2015 11:04:55 +0000"  >&lt;p&gt;Who could grant &quot;Stream Events&quot; capability to this user:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Username    cppcheck
Full Name    CPPCheck
Account ID    489
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;?&lt;/p&gt;</comment>
                            <comment id="110230" author="morrone" created="Fri, 20 Mar 2015 17:38:31 +0000"  >&lt;p&gt;I like that your script is running CPPCheck on the before and after versions of the file, and only reporting the new issues that were caused by the patch.&lt;/p&gt;</comment>
                            <comment id="110454" author="denis_kondratenko" created="Tue, 24 Mar 2015 11:15:24 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.whamcloud.com/secure/ViewProfile.jspa?name=jhammond&quot; class=&quot;user-hover&quot; rel=&quot;jhammond&quot;&gt;jhammond&lt;/a&gt; who could help us with Gerrit permissions ?&lt;/p&gt;</comment>
                            <comment id="110455" author="pjones" created="Tue, 24 Mar 2015 11:22:41 +0000"  >&lt;p&gt;Denis&lt;/p&gt;

&lt;p&gt;I have made the request to out sysadmin team. This request will need to be balanced against other requests.&lt;/p&gt;

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="110456" author="denis_kondratenko" created="Tue, 24 Mar 2015 11:59:53 +0000"  >&lt;p&gt;Thanks Peter!&lt;/p&gt;</comment>
                            <comment id="110838" author="denis_kondratenko" created="Fri, 27 Mar 2015 15:09:36 +0000"  >&lt;p&gt;Hi @pjones , sorry for disturbing , is there any progress to get permissions? we have Roman to work on this now so we could get it done before he is gone...&lt;/p&gt;</comment>
                            <comment id="110950" author="pjones" created="Sat, 28 Mar 2015 13:23:43 +0000"  >&lt;p&gt;Hi Denis&lt;/p&gt;

&lt;p&gt;I am afraid that I do not have an update yet but I will certainly update here as soon as I hear something. If Roman is anxious to start work on this then perhaps it makes sense to use an interim solution like periodically polling the repository (hourly, say).&lt;/p&gt;

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="111637" author="denis_kondratenko" created="Tue, 7 Apr 2015 08:49:54 +0000"  >&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;any news on getting permissions?&lt;/p&gt;

&lt;p&gt;Meanwhile Roman did full, regular report from cppcheck:&lt;br/&gt;
&lt;a href=&quot;http://54.164.238.188/job/lustre_master_regular_cppcheck/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_master_regular_cppcheck/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Denis&lt;/p&gt;</comment>
                            <comment id="114437" author="adilger" created="Wed, 6 May 2015 21:53:09 +0000"  >&lt;p&gt;I&apos;m looking into enabling the stream-events permission for your account.  There was some uncertainty about what events would be visible with this permission, because we have both public and private projects hosted in Gerrit.&lt;/p&gt;

&lt;p&gt;I looked at the reports available at &lt;a href=&quot;http://54.164.238.188/job/lustre_master_regular_cppcheck/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_master_regular_cppcheck/&lt;/a&gt; and they are definitely interesting. It seems you are connecting a full Jenkins instance for the cppcheck?  It looks like you are polling on 10min intervals already?  It seems that one useful view for each build would be available from the URL:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://54.164.238.188/job/lustre_master_regular_cppcheck/61/cppcheckResult/source.all/?before=5&amp;amp;after=5&amp;amp;states=new&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_master_regular_cppcheck/61/cppcheckResult/source.all/?before=5&amp;amp;after=5&amp;amp;states=new&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;since we want to focus on new problems, but it would be nice to also see existing problems in the area of code being modified.  Unfortunately, it looks like the &quot;unchanged&quot; state shows all of the issues in the tree and not just those related to the patch.&lt;/p&gt;

&lt;p&gt;How do you plan to post the output from cppcheck back into Gerrit for each patch?  Using per-line annotations like &lt;tt&gt;contrib/scripts/gerrit_checkpatch.py&lt;/tt&gt; (which is also sent to patch watchers via email like all Gerrit comments) is definitely preferable to just having a URL to the test output.  I suspect many developers won&apos;t actually go to the cppcheck site each time if they don&apos;t have to, but any issues will be clearly visible to both the patch submitter and the reviewers if they are inline comments in the patch.&lt;/p&gt;</comment>
                            <comment id="115002" author="ryg_" created="Tue, 12 May 2015 09:57:12 +0000"  >&lt;p&gt;Hi Andreas,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;full Jenkins instance for the cppcheck&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;yes, it comparable simple and allows to just copy our internal setup for community needs&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;it looks like you are polling on 10min intervals already&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;yes, current setup checks new commit in master branch every 10 minutes. gerrit pre-commit changes are not observing&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;one useful view for each build would be available from the URL:&lt;br/&gt;
&lt;a href=&quot;http://54.164.238.188/job/lustre_master_regular_cppcheck/61/cppcheckResult/source.all/?before=5&amp;amp;after=5&amp;amp;states=new&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://54.164.238.188/job/lustre_master_regular_cppcheck/61/cppcheckResult/source.all/?before=5&amp;amp;after=5&amp;amp;states=new&lt;/a&gt;&lt;br/&gt;
since we want to focus on new problems, but it would be nice to also see existing problems in the area of code being modified&lt;br/&gt;
Unfortunately, it looks like the &quot;unchanged&quot; state shows all of the issues in the tree and not just those related to the patch.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;It&apos;s master branch check report. We agreed with Denis that master check just shows high level picture about full project, and warning diffs are not goal there( from my vision diff is especially interesting on pre-commit stage). I could add diff view also for master branches.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt; Using per-line annotations like contrib/scripts/gerrit_checkpatch.py (which is also sent to patch watchers via email like all Gerrit comments) ...  visible to both the patch submitter and the reviewers if they are inline comments in the patch.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I&apos;m planing to implement this workflow in near time.&lt;/p&gt;</comment>
                            <comment id="115311" author="denis_kondratenko" created="Thu, 14 May 2015 10:22:04 +0000"  >&lt;p&gt;Hi Andreas,&lt;/p&gt;

&lt;p&gt;from your comment about events I didn&apos;t understand - could it be done or should we seek for other approaches?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Denis&lt;/p&gt;</comment>
                            <comment id="115363" author="morrone" created="Thu, 14 May 2015 18:22:44 +0000"  >&lt;p&gt;They do not yet know if events will be enabled.  Andreas was just explaining why gerrit events need to be investigated before they can tell us if it is possible.  More time is needed to do that investigation.&lt;/p&gt;</comment>
                            <comment id="140262" author="mdiep" created="Wed, 27 Jan 2016 18:55:41 +0000"  >&lt;p&gt;Hi Denis,&lt;/p&gt;

&lt;p&gt;I have granted username &apos;cppcheck&apos; streaming permission. Please check and let me know how it goes.&lt;/p&gt;</comment>
                            <comment id="215281" author="adilger" created="Tue, 5 Dec 2017 05:07:02 +0000"  >&lt;p&gt;The required streaming permission was granted to the &quot;cppcheck&quot; user, but I don&apos;t think anything was ever done with this.  At least there has not been anything shared publicly.&lt;/p&gt;

&lt;p&gt;For future reference, the page &lt;a href=&quot;http://wiki.lustre.org/Simple_Gerrit_Builder_Howto&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://wiki.lustre.org/Simple_Gerrit_Builder_Howto&lt;/a&gt; describes a simple polling mechanism to track patches in Gerrit that can be used by any user without special permissions, and is currently in use for the &lt;tt&gt;HPDD Checkpatch&lt;/tt&gt; and &lt;tt&gt;Misc Code Checks Robot&lt;/tt&gt; static analysis tools.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="17451">LU-2753</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_10890" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzx8on:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>