Srdjan Todorovic | 2 Nov 2009 16:35

CRAP for C++ ?

Hello,

I noticed an interesting Java project called CRAP4J (www.crap4j.org),
to detect code that smells. While this seems really neat, there's no
C++ support currently.

The first 3 pages of Google results seem to only be talking/ranting
about C++ *being* crap - and this is obviously not what I'm looking
for.

Does anyone know of any CRAP frameworks for C++?

Apologies for cross-posting - I am not sure which of the two lists is
more concerned with this topic, however this shouldn't be off-topic to
either.

Specifically, my problem is that I'm adding unit tests and refactoring
legacy code, but have no automated way to tell me how much of the
project has test coverage and what the quality of the test coverage is
like.

Thank you,
Srdjan

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/
(Continue reading)

Mirko Stocker | 2 Nov 2009 17:27
Picon
Favicon
Gravatar

Re: CRAP for C++ ?

Hello

On Monday 02 November 2009 16:35:29 Srdjan Todorovic wrote:
> Does anyone know of any CRAP frameworks for C++?

I don't think this qualifies as a CRAP framework, but PMD has as tool to detect 
duplicated code [1], maybe that's a start..

[1] http://pmd.sourceforge.net/cpd.html

Regards

Mirko

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:refactoring-digest <at> yahoogroups.com 
(Continue reading)

Adam Sroka | 2 Nov 2009 19:11
Picon
Gravatar

Re: CRAP for C++ ?

AFAIK, crap4j is the only widely adopted implementation, written by
the guys who invented the metric. There was talk of someone creating a
C# port. However, you can implement it yourself. All you need is
coverage and cyclomatic complexity. Then, apply the formula:

CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)

where comp(m) is cyclomatic complexity and cov(m) is test coverage.

On Mon, Nov 2, 2009 at 8:27 AM, Mirko Stocker <me <at> misto.ch> wrote:
>
>
>
> Hello
>
> On Monday 02 November 2009 16:35:29 Srdjan Todorovic wrote:
> > Does anyone know of any CRAP frameworks for C++?
>
> I don't think this qualifies as a CRAP framework, but PMD has as tool to detect
> duplicated code [1], maybe that's a start..
>
> [1] http://pmd.sourceforge.net/cpd.html
>
> Regards
>
> Mirko
> 

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

(Continue reading)

Richard | 2 Nov 2009 23:06
Favicon
Gravatar

Re: CRAP for C++ ?


In article <a59829110911020735w29bb6a9fv9adb6200c8cc0510 <at> mail.gmail.com>,
    Srdjan Todorovic <todorovic.s <at> googlemail.com>  writes:

> I noticed an interesting Java project called CRAP4J (www.crap4j.org),
> to detect code that smells. While this seems really neat, there's no
> C++ support currently.

The main problem is measuring test coverage.  With languages that
contain reflection and dynamic code construction you can reflect over
the code and rewrite the code to emit coverage instrumentation in a
transparent manner.

SourceMonitor does a great job of measuring cyclomatic complexity for
many languages, including C++.  That will get you the complexity
measurements.  Simian does a great job of measuring code duplication,
which while not a part of the "crap" metric is still useful.

I recently saw mention of an interesting tool that instruments C++ by
having you feed it the preprocessed source which it then instruments
and feeds to the C++ compiler.  That was an interesting approach that
I hadn't considered before.  See <http://covtool.sourceforge.net/>
--

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
 <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>

      Legalize Adulthood! <http://legalizeadulthood.wordpress.com>

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

(Continue reading)

Kaleb Pederson | 2 Nov 2009 23:19
Picon
Gravatar

Re: CRAP for C++ ?

On Mon, Nov 2, 2009 at 2:06 PM, Richard <legalize <at> xmission.com> wrote:
>
> In article <a59829110911020735w29bb6a9fv9adb6200c8cc0510 <at> mail.gmail.com>,
>    Srdjan Todorovic <todorovic.s <at> googlemail.com>  writes:
>
>> I noticed an interesting Java project called CRAP4J (www.crap4j.org),
>> to detect code that smells. While this seems really neat, there's no
>> C++ support currently.
>
> The main problem is measuring test coverage.  With languages that
> contain reflection and dynamic code construction you can reflect over
> the code and rewrite the code to emit coverage instrumentation in a
> transparent manner.
>
> SourceMonitor does a great job of measuring cyclomatic complexity for
> many languages, including C++.  That will get you the complexity
> measurements.  Simian does a great job of measuring code duplication,
> which while not a part of the "crap" metric is still useful.
>
> I recently saw mention of an interesting tool that instruments C++ by
> having you feed it the preprocessed source which it then instruments
> and feeds to the C++ compiler.  That was an interesting approach that
> I hadn't considered before.  See <http://covtool.sourceforge.net/>

Richard has a good point about code coverage.  If you have legacy code
(bad code?) then it's unlikely that you'll obtain high code coverage
nor that it will be easy to add tests and obtain a high level of code
coverage.

I've used Bullseye Coverage for all of my C++ Code Coverage needs.  It
(Continue reading)

Srdjan Todorovic | 3 Nov 2009 14:35

Re: CRAP for C++ ?

Hello,

On 02/11/2009, Adam Sroka <adam.sroka <at> gmail.com> wrote:
> AFAIK, crap4j is the only widely adopted implementation, written by
> the guys who invented the metric. There was talk of someone creating a
> C# port. However, you can implement it yourself. All you need is
> coverage and cyclomatic complexity. Then, apply the formula:
>
> CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)
>
> where comp(m) is cyclomatic complexity and cov(m) is test coverage.

Yes but I'd need some way of automatically obtaining the test coverage
and cyclomatic complexity.

Regards,
Srdjan

> On Mon, Nov 2, 2009 at 8:27 AM, Mirko Stocker <me <at> misto.ch> wrote:
>>
>>
>>
>> Hello
>>
>> On Monday 02 November 2009 16:35:29 Srdjan Todorovic wrote:
>> > Does anyone know of any CRAP frameworks for C++?
>>
>> I don't think this qualifies as a CRAP framework, but PMD has as tool to
>> detect
>> duplicated code [1], maybe that's a start..
(Continue reading)

Ron Jeffries | 3 Nov 2009 14:56
Picon
Favicon
Gravatar

Re: CRAP for C++ ?

Hello, Srdjan.  On Tuesday, November 3, 2009, at 8:35:22 AM, you
wrote:

> Yes but I'd need some way of automatically obtaining the test coverage
> and cyclomatic complexity.

Perhaps you mean "Yes, and ..."?

Ron Jeffries
www.XProgramming.com
www.xprogramming.com/blog
Some things are impossible. And some things people say are
impossible -- because they don't know how to do them. -- Ron Loyd

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:refactoring-digest <at> yahoogroups.com 
(Continue reading)

Srdjan Todorovic | 3 Nov 2009 15:12

Re: CRAP for C++ ?

On 03/11/2009, Ron Jeffries <ronjeffries <at> acm.org> wrote:
> Hello, Srdjan.  On Tuesday, November 3, 2009, at 8:35:22 AM, you
> wrote:
>
>> Yes but I'd need some way of automatically obtaining the test coverage
>> and cyclomatic complexity.
>
> Perhaps you mean "Yes, and ..."?

Yes that's what I meant. Sorry for my poor choice of words.

Regards,
Srdjan

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:refactoring-digest <at> yahoogroups.com 
(Continue reading)

Adam Sroka | 3 Nov 2009 19:21
Picon
Gravatar

Re: CRAP for C++ ?

On Tue, Nov 3, 2009 at 5:35 AM, Srdjan Todorovic
<todorovic.s <at> googlemail.com> wrote:
>
>
>
> Hello,
>
> On 02/11/2009, Adam Sroka <adam.sroka <at> gmail.com> wrote:
> > AFAIK, crap4j is the only widely adopted implementation, written by
> > the guys who invented the metric. There was talk of someone creating a
> > C# port. However, you can implement it yourself. All you need is
> > coverage and cyclomatic complexity. Then, apply the formula:
> >
> > CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m)
> >
> > where comp(m) is cyclomatic complexity and cov(m) is test coverage.
>
> Yes but I'd need some way of automatically obtaining the test coverage
> and cyclomatic complexity.
>

Here are some to start with:

http://covtool.sourceforge.net/
http://cccc.sourceforge.net/

However, as with anything in C/C++ it depends. What platform are you
developing on? What platform are you targeting? What IDE and/or
toolchain do you use? Does it need to be open source? (The two I
mentioned are.) How much do you want to pay? If you know the answers
(Continue reading)

Stephen | 3 Nov 2009 20:14

Re: CRAP for C++ ?


--- In refactoring <at> yahoogroups.com, Srdjan Todorovic <todorovic.s <at> ...> wrote:
>
> Hello,
> 
> I noticed an interesting Java project called CRAP4J (www.crap4j.org),
> to detect code that smells. While this seems really neat, there's no
> C++ support currently.
> 
> The first 3 pages of Google results seem to only be talking/ranting
> about C++ *being* crap - and this is obviously not what I'm looking
> for.
> 
> Does anyone know of any CRAP frameworks for C++?
> 
> Apologies for cross-posting - I am not sure which of the two lists is
> more concerned with this topic, however this shouldn't be off-topic to
> either.
> 
> Specifically, my problem is that I'm adding unit tests and refactoring
> legacy code, but have no automated way to tell me how much of the
> project has test coverage and what the quality of the test coverage is
> like.
You haven't mentioned what platform or compiler you're using, but gcc has a great coverage system - simply
feed the parameter -fprofile-arcs to each compile, run your tests then run the 'gcov' tool to analyse the results.

--
Steve

------------------------------------
(Continue reading)


Gmane