git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [GSoC] [PATCH] travis-ci: added clang static analysis
@ 2018-03-05 20:04 SiddharthaMishra
  2018-03-06  1:27 ` Junio C Hamano
  2018-03-12 10:19 ` Lars Schneider
  0 siblings, 2 replies; 9+ messages in thread
From: SiddharthaMishra @ 2018-03-05 20:04 UTC (permalink / raw)
  To: git; +Cc: SiddharthaMishra

Added a job to run clang static code analysis on the master and maint branch

Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
---
 .travis.yml               | 17 ++++++++++++++++-
 ci/run-static-analysis.sh |  9 ++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 4684b3f4f..9b891d182 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,7 +48,7 @@ matrix:
       before_install:
       before_script:
       script: ci/run-linux32-docker.sh
-    - env: jobname=StaticAnalysis
+    - env: jobname=CocciStaticAnalysis
       os: linux
       compiler:
       addons:
@@ -59,6 +59,21 @@ matrix:
       before_script:
       script: ci/run-static-analysis.sh
       after_failure:
+    - if: branch IN (master, maint)
+      env: jobname=ClangStaticAnalysis
+      os: linux
+      compiler:
+      add_ons:
+        apt:
+          sources:
+          - ubuntu-toolchain-r-test
+          - llvm-toolchain-trusty
+          packages:
+          - clang
+      before_install:
+      before_script:
+      script: ci/run-static-analysis.sh
+      after_failure:
     - env: jobname=Documentation
       os: linux
       compiler:
diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh
index fe4ee4e06..6ae032f54 100755
--- a/ci/run-static-analysis.sh
+++ b/ci/run-static-analysis.sh
@@ -5,6 +5,13 @@
 
 . ${0%/*}/lib-travisci.sh
 
-make coccicheck
+case "$jobname" in
+ClangStaticAnalysis)
+	scan-build -analyze-headers --status-bugs make
+	;;
+CocciStaticAnalysis)
+	make coccicheck
+	;;
+esac
 
 save_good_tree
-- 
2.16.2.248.ge2408a6f7.dirty


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-05 20:04 [GSoC] [PATCH] travis-ci: added clang static analysis SiddharthaMishra
@ 2018-03-06  1:27 ` Junio C Hamano
  2018-03-06  8:34   ` Siddhartha Mishra
  2018-03-12 10:19 ` Lars Schneider
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2018-03-06  1:27 UTC (permalink / raw)
  To: SiddharthaMishra; +Cc: git

SiddharthaMishra <sidm1999@gmail.com> writes:

> Added a job to run clang static code analysis on the master and maint branch
>
> Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
> ---

Why on 'master' and 'maint' and not others?  Quite frankly, I find
this choice of branches rather odd, as these two branches are not
where the real development happens.  If we do not want to increase
the number of jobs and limit the test only to a single branch, I
would probably pick 'next', and if we can afford two, probably
'pu' and 'next'.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-06  1:27 ` Junio C Hamano
@ 2018-03-06  8:34   ` Siddhartha Mishra
  2018-03-07 13:16     ` Johannes Schindelin
  0 siblings, 1 reply; 9+ messages in thread
From: Siddhartha Mishra @ 2018-03-06  8:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, Mar 6, 2018 at 6:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
> SiddharthaMishra <sidm1999@gmail.com> writes:
>
>> Added a job to run clang static code analysis on the master and maint branch
>>
>> Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
>> ---
>
> Why on 'master' and 'maint' and not others?  Quite frankly, I find
> this choice of branches rather odd, as these two branches are not
> where the real development happens.  If we do not want to increase
> the number of jobs and limit the test only to a single branch, I
> would probably pick 'next', and if we can afford two, probably
> 'pu' and 'next'.

I might have been misinterpreting it, but I did so because that's what
it said in the microproject description. Thinking about it, I guess it
does makes more sense to work on the other two branches instead. Are
there any other glaring issues you see in the code?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-06  8:34   ` Siddhartha Mishra
@ 2018-03-07 13:16     ` Johannes Schindelin
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2018-03-07 13:16 UTC (permalink / raw)
  To: Siddhartha Mishra; +Cc: Junio C Hamano, git

Hi,

On Tue, 6 Mar 2018, Siddhartha Mishra wrote:

> Are there any other glaring issues you see in the code?

The rest looks good to me!

Ciao,
Johannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-05 20:04 [GSoC] [PATCH] travis-ci: added clang static analysis SiddharthaMishra
  2018-03-06  1:27 ` Junio C Hamano
@ 2018-03-12 10:19 ` Lars Schneider
  2018-03-13 17:45   ` Siddhartha Mishra
  1 sibling, 1 reply; 9+ messages in thread
From: Lars Schneider @ 2018-03-12 10:19 UTC (permalink / raw)
  To: SiddharthaMishra; +Cc: Git List, Johannes Schindelin

Hi,

That looks interesting but I agree with Dscho that we should not limit
this to master/maint.

I assume you did run this on TravisCI already? Can you share a link?
I assume you did find errors? Can we fix them or are there too many?
If there are existing errors, how do we define a "successful" build?

Thanks for working on this,
Lars

> On 05 Mar 2018, at 21:04, SiddharthaMishra <sidm1999@gmail.com> wrote:
> 
> Added a job to run clang static code analysis on the master and maint branch
> 
> Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
> ---
> .travis.yml               | 17 ++++++++++++++++-
> ci/run-static-analysis.sh |  9 ++++++++-
> 2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index 4684b3f4f..9b891d182 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -48,7 +48,7 @@ matrix:
>       before_install:
>       before_script:
>       script: ci/run-linux32-docker.sh
> -    - env: jobname=StaticAnalysis
> +    - env: jobname=CocciStaticAnalysis
>       os: linux
>       compiler:
>       addons:
> @@ -59,6 +59,21 @@ matrix:
>       before_script:
>       script: ci/run-static-analysis.sh
>       after_failure:
> +    - if: branch IN (master, maint)
> +      env: jobname=ClangStaticAnalysis
> +      os: linux
> +      compiler:
> +      add_ons:
> +        apt:
> +          sources:
> +          - ubuntu-toolchain-r-test
> +          - llvm-toolchain-trusty
> +          packages:
> +          - clang
> +      before_install:
> +      before_script:
> +      script: ci/run-static-analysis.sh
> +      after_failure:
>     - env: jobname=Documentation
>       os: linux
>       compiler:
> diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh
> index fe4ee4e06..6ae032f54 100755
> --- a/ci/run-static-analysis.sh
> +++ b/ci/run-static-analysis.sh
> @@ -5,6 +5,13 @@
> 
> . ${0%/*}/lib-travisci.sh
> 
> -make coccicheck
> +case "$jobname" in
> +ClangStaticAnalysis)
> +	scan-build -analyze-headers --status-bugs make
> +	;;
> +CocciStaticAnalysis)
> +	make coccicheck
> +	;;
> +esac
> 
> save_good_tree
> -- 
> 2.16.2.248.ge2408a6f7.dirty
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-12 10:19 ` Lars Schneider
@ 2018-03-13 17:45   ` Siddhartha Mishra
  2018-03-13 17:52     ` Siddhartha Mishra
  2018-04-01 14:39     ` Lars Schneider
  0 siblings, 2 replies; 9+ messages in thread
From: Siddhartha Mishra @ 2018-03-13 17:45 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git List, Johannes Schindelin

On Mon, Mar 12, 2018 at 3:49 PM, Lars Schneider
<larsxschneider@gmail.com> wrote:
> Hi,
>
> That looks interesting but I agree with Dscho that we should not limit
> this to master/maint.
>
> I assume you did run this on TravisCI already? Can you share a link?
> I assume you did find errors? Can we fix them or are there too many?
> If there are existing errors, how do we define a "successful" build?
>
> Thanks for working on this,
> Lars
>

Thanks for the reply,

I assume there will be false positives in the code which we can't fix
by making small modifications to the code as recommended in the FAQ
(https://clang-analyzer.llvm.org/faq.html). According to the FAQ,
there is no solid mechanism for suppressing a specific warning, so are
options are limited. Some of the things which might help reduce the
noise are:

1) To add specific tags in our source code to tell the analyzer to
ignore the code. This is probably a bad idea since it is intrusive and
forces changes to the actual source code which only affect one task.

2) Count the number of bugs in the previous pushed build and fail the
build if the number of bugs increases. It doesn't help remove the
noise from the error log but it does tell you if you've added more
bugs. However if you add a bug and remove one, it'll pass the job and
might mislead you into thinking that the code is correct.

3) Write a script to check the diff of the error log from that of the
previous pushed build(ignoring the line numbers). I haven't thought
about how exactly it would be implemented so I'm not commenting on it.

Is there a better solution that I'm missing or should I try coming up
with a script to come up the diff?

Thanks for the time,
Siddhartha

On Mon, Mar 12, 2018 at 3:49 PM, Lars Schneider
<larsxschneider@gmail.com> wrote:
> Hi,
>
> That looks interesting but I agree with Dscho that we should not limit
> this to master/maint.
>
> I assume you did run this on TravisCI already? Can you share a link?
> I assume you did find errors? Can we fix them or are there too many?
> If there are existing errors, how do we define a "successful" build?
>
> Thanks for working on this,
> Lars
>
>> On 05 Mar 2018, at 21:04, SiddharthaMishra <sidm1999@gmail.com> wrote:
>>
>> Added a job to run clang static code analysis on the master and maint branch
>>
>> Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
>> ---
>> .travis.yml               | 17 ++++++++++++++++-
>> ci/run-static-analysis.sh |  9 ++++++++-
>> 2 files changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/.travis.yml b/.travis.yml
>> index 4684b3f4f..9b891d182 100644
>> --- a/.travis.yml
>> +++ b/.travis.yml
>> @@ -48,7 +48,7 @@ matrix:
>>       before_install:
>>       before_script:
>>       script: ci/run-linux32-docker.sh
>> -    - env: jobname=StaticAnalysis
>> +    - env: jobname=CocciStaticAnalysis
>>       os: linux
>>       compiler:
>>       addons:
>> @@ -59,6 +59,21 @@ matrix:
>>       before_script:
>>       script: ci/run-static-analysis.sh
>>       after_failure:
>> +    - if: branch IN (master, maint)
>> +      env: jobname=ClangStaticAnalysis
>> +      os: linux
>> +      compiler:
>> +      add_ons:
>> +        apt:
>> +          sources:
>> +          - ubuntu-toolchain-r-test
>> +          - llvm-toolchain-trusty
>> +          packages:
>> +          - clang
>> +      before_install:
>> +      before_script:
>> +      script: ci/run-static-analysis.sh
>> +      after_failure:
>>     - env: jobname=Documentation
>>       os: linux
>>       compiler:
>> diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh
>> index fe4ee4e06..6ae032f54 100755
>> --- a/ci/run-static-analysis.sh
>> +++ b/ci/run-static-analysis.sh
>> @@ -5,6 +5,13 @@
>>
>> . ${0%/*}/lib-travisci.sh
>>
>> -make coccicheck
>> +case "$jobname" in
>> +ClangStaticAnalysis)
>> +     scan-build -analyze-headers --status-bugs make
>> +     ;;
>> +CocciStaticAnalysis)
>> +     make coccicheck
>> +     ;;
>> +esac
>>
>> save_good_tree
>> --
>> 2.16.2.248.ge2408a6f7.dirty
>>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-13 17:45   ` Siddhartha Mishra
@ 2018-03-13 17:52     ` Siddhartha Mishra
  2018-04-01 14:39     ` Lars Schneider
  1 sibling, 0 replies; 9+ messages in thread
From: Siddhartha Mishra @ 2018-03-13 17:52 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git List, Johannes Schindelin

I'm extremely sorry, I forgot to attach my travis-ci job build with my
previous message. Here it is :
https://travis-ci.org/SiddharthaMishra/git/jobs/349478746#L1204.

I also apologize for not trimming the email properly in the previous message.

Sorry for the inconvenience,
Siddhartha

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-03-13 17:45   ` Siddhartha Mishra
  2018-03-13 17:52     ` Siddhartha Mishra
@ 2018-04-01 14:39     ` Lars Schneider
  2018-04-02 20:08       ` Siddhartha Mishra
  1 sibling, 1 reply; 9+ messages in thread
From: Lars Schneider @ 2018-04-01 14:39 UTC (permalink / raw)
  To: Siddhartha Mishra; +Cc: Git List, Johannes Schindelin


> On 13 Mar 2018, at 18:45, Siddhartha Mishra <sidm1999@gmail.com> wrote:
> 
> On Mon, Mar 12, 2018 at 3:49 PM, Lars Schneider
> <larsxschneider@gmail.com> wrote:
>> Hi,
>> 
>> That looks interesting but I agree with Dscho that we should not limit
>> this to master/maint.
>> 
>> I assume you did run this on TravisCI already? Can you share a link?
>> I assume you did find errors? Can we fix them or are there too many?
>> If there are existing errors, how do we define a "successful" build?
>> 
>> Thanks for working on this,
>> Lars
>> 
> 
> Thanks for the reply,
> 
> I assume there will be false positives in the code which we can't fix
> by making small modifications to the code as recommended in the FAQ
> (https://clang-analyzer.llvm.org/faq.html). According to the FAQ,
> there is no solid mechanism for suppressing a specific warning, so are
> options are limited. Some of the things which might help reduce the
> noise are:
> 
> 1) To add specific tags in our source code to tell the analyzer to
> ignore the code. This is probably a bad idea since it is intrusive and
> forces changes to the actual source code which only affect one task.
> 
> 2) Count the number of bugs in the previous pushed build and fail the
> build if the number of bugs increases. It doesn't help remove the
> noise from the error log but it does tell you if you've added more
> bugs. However if you add a bug and remove one, it'll pass the job and
> might mislead you into thinking that the code is correct.
> 
> 3) Write a script to check the diff of the error log from that of the
> previous pushed build(ignoring the line numbers). I haven't thought
> about how exactly it would be implemented so I'm not commenting on it.
> 
> Is there a better solution that I'm missing or should I try coming up
> with a script to come up the diff?

That's a good summary and I don't see a better solution. While (3)
sounds nice, I think (2) is the fastest/most pragmatic solution.

We already use the Travis cache [1]. You could use that mechanism to 
store a file with the latest number of bugs in the cache directory 
$HOME/travis-cache

If the "number of bugs" file does not exist, then create it and don't
complain. If the file exists and the previous number of bugs is higher
or equal, then don't complain either. If the file exists and the previous
number of bugs is lower, then let the build fail.

Do you think that could work?

Cheers,
Lars 

[1] https://docs.travis-ci.com/user/caching/


> 
> Thanks for the time,
> Siddhartha
> 
> On Mon, Mar 12, 2018 at 3:49 PM, Lars Schneider
> <larsxschneider@gmail.com> wrote:
>> Hi,
>> 
>> That looks interesting but I agree with Dscho that we should not limit
>> this to master/maint.
>> 
>> I assume you did run this on TravisCI already? Can you share a link?
>> I assume you did find errors? Can we fix them or are there too many?
>> If there are existing errors, how do we define a "successful" build?
>> 
>> Thanks for working on this,
>> Lars
>> 
>>> On 05 Mar 2018, at 21:04, SiddharthaMishra <sidm1999@gmail.com> wrote:
>>> 
>>> Added a job to run clang static code analysis on the master and maint branch
>>> 
>>> Signed-off-by: SiddharthaMishra <sidm1999@gmail.com>
>>> ---
>>> .travis.yml               | 17 ++++++++++++++++-
>>> ci/run-static-analysis.sh |  9 ++++++++-
>>> 2 files changed, 24 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/.travis.yml b/.travis.yml
>>> index 4684b3f4f..9b891d182 100644
>>> --- a/.travis.yml
>>> +++ b/.travis.yml
>>> @@ -48,7 +48,7 @@ matrix:
>>>      before_install:
>>>      before_script:
>>>      script: ci/run-linux32-docker.sh
>>> -    - env: jobname=StaticAnalysis
>>> +    - env: jobname=CocciStaticAnalysis
>>>      os: linux
>>>      compiler:
>>>      addons:
>>> @@ -59,6 +59,21 @@ matrix:
>>>      before_script:
>>>      script: ci/run-static-analysis.sh
>>>      after_failure:
>>> +    - if: branch IN (master, maint)
>>> +      env: jobname=ClangStaticAnalysis
>>> +      os: linux
>>> +      compiler:
>>> +      add_ons:
>>> +        apt:
>>> +          sources:
>>> +          - ubuntu-toolchain-r-test
>>> +          - llvm-toolchain-trusty
>>> +          packages:
>>> +          - clang
>>> +      before_install:
>>> +      before_script:
>>> +      script: ci/run-static-analysis.sh
>>> +      after_failure:
>>>    - env: jobname=Documentation
>>>      os: linux
>>>      compiler:
>>> diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh
>>> index fe4ee4e06..6ae032f54 100755
>>> --- a/ci/run-static-analysis.sh
>>> +++ b/ci/run-static-analysis.sh
>>> @@ -5,6 +5,13 @@
>>> 
>>> . ${0%/*}/lib-travisci.sh
>>> 
>>> -make coccicheck
>>> +case "$jobname" in
>>> +ClangStaticAnalysis)
>>> +     scan-build -analyze-headers --status-bugs make
>>> +     ;;
>>> +CocciStaticAnalysis)
>>> +     make coccicheck
>>> +     ;;
>>> +esac
>>> 
>>> save_good_tree
>>> --
>>> 2.16.2.248.ge2408a6f7.dirty
>>> 
>> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [GSoC] [PATCH] travis-ci: added clang static analysis
  2018-04-01 14:39     ` Lars Schneider
@ 2018-04-02 20:08       ` Siddhartha Mishra
  0 siblings, 0 replies; 9+ messages in thread
From: Siddhartha Mishra @ 2018-04-02 20:08 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git List, Johannes Schindelin

On Sun, Apr 1, 2018, 8:10 PM Lars Schneider <larsxschneider@gmail.com> wrote:

>
> That's a good summary and I don't see a better solution. While (3)
> sounds nice, I think (2) is the fastest/most pragmatic solution.
>
> We already use the Travis cache [1]. You could use that mechanism to
> store a file with the latest number of bugs in the cache directory
> $HOME/travis-cache
>
> If the "number of bugs" file does not exist, then create it and don't
> complain. If the file exists and the previous number of bugs is higher
> or equal, then don't complain either. If the file exists and the previous
> number of bugs is lower, then let the build fail.
>
> Do you think that could work?

Apologies for having sent this message twice, the last one wasn't in
plain text and were therefore not properly forwarded to the mail
group.

If we only consider the number of bugs in the last pushed commit, a
situation might happen that a commit creates a lot of bugs. If a
subsequent commit then fixes only a few of the previously created bugs
the build would still pass since the number of bugs from the last
commit has decreased.

Should this be the intended behaviour or should adding the number of
allowed bugs be a more deliberate process?

Thanks,
Siddhartha

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-02 20:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 20:04 [GSoC] [PATCH] travis-ci: added clang static analysis SiddharthaMishra
2018-03-06  1:27 ` Junio C Hamano
2018-03-06  8:34   ` Siddhartha Mishra
2018-03-07 13:16     ` Johannes Schindelin
2018-03-12 10:19 ` Lars Schneider
2018-03-13 17:45   ` Siddhartha Mishra
2018-03-13 17:52     ` Siddhartha Mishra
2018-04-01 14:39     ` Lars Schneider
2018-04-02 20:08       ` Siddhartha Mishra

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).