RE: Ignoring blocks of code..?

"Mark Webb" <[email protected]> Thu, 14 Apr 2005 11:22:30 -0400
Newsgroups gmane.comp.java.simian.user
Message-ID <ECE66FDC2D185F40A7E8B6E66F4C894206CC56A7@msgusaemb01.autodesk.com>
Simon

Thanks for the prompt reply.

I noticed the #region support, but given that our code is mainly (about
95+%) C++, the remainder being C# or some other language this doesn't
work for us yet.
On the subject of regions, does this switch ignore ALL regioned code? Is
it possible to ignore regions with specific names?
The reason I ask, is that we region all of our C# code into logical
blocks to ease code reading.=20

The ideal would be to find a language agnostic solution.
Maybe an option like...
 -ignoreblock "// START ignore dupes" "// END ignore dupes"
Or for VB this might read
 -ignoreblock "' START ignore dupes" "' END ignore dupes"

So that we can mark the code in anyway we see fit, and Simian can be
passed the appropriate markers.

I am not so keen on the solution of a file containing file and line
numbers. As you say this is volatile and would need to maintained as the
code base changes.

BTW, I have to say Simian is an excellent tool and has already helped us
significantly reduce code duplication. Once we can get a clean run (i.e.
we have filtered out 'good' duplicates, and fixed 'bad' duplicates) we
hope to use it as a policing tool to automatically catch the Copy-Paste
offenders :)

Cheers,
Mark

-----Original Message-----
From: Simon Harris [mailto:[email protected]]=20
Sent: Thursday, April 14, 2005 11:12 AM
To: [email protected]
Subject: Re: [simian-user] Ignoring blocks of code..?

Hi Mark,

This is an interesting and ongoing debate in the simian user community;
ie what to do about duplicates that you wish to ignore.

There are a few options. One would be to mark-up the source code. If you
are using C#, this is already possible as #region #endregion markers are
already supported.

If this doesn't work for you, or you are using some other language,
another option would be to come up with some other kind of tag to
indicate that simian should ignore it.

Yet another possible solution would be have a file containing code
fragments that are consider "legal" duplicates.

And one final, yet somewhat volatile, approach would be to have a file
containing files and line number ranges of code blocks to ignore.

One thing that has come up occasionally is that duplicate blocks that
one considers to be "legal" may well be candidates for code generation
- thought his doesn't sound like it's the case in your situation. Or
even template methods - though I have a general disdain for these.

Any and all of these are possible, it's really a matter of what you
think would work for you.

Regards,

Simon

On 15/04/2005, at 12:19 AM, Mark Webb wrote:

>
>
> Is there any way to ignore blocks of code from parsing?
>
> We have a number of code snippets that are flagged as duplicates, but=20
> really are not (about a half dozen over 4million lines of code).
>
> It would be useful if there were either a directive I can put in the=20
> code, or a flag I can pass to Simian that can ignore all code segments

> that I have validated manually.
>
> If not, might this be something that can be added in a future version?
>
> Cheers
>  Mark
>

--
Simon Harris
RedHill Consulting, Pty. Ltd.
12/55-67 Batman Street
West Melbourne VIC 3003
http://www.redhillconsulting.com.au
mob: +61 417 505 611
yahoo/skype: haruki_zaemon