RE: Ignoring blocks of code..?

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

I know all about those late nighters... :)

I mostly agree about the idea of ignoring blocks, and it's potential for
abuse.

The hacky alternative I considered is for use to inject comment blocks
every so often (under the threshold level) or reorder the code itself so
that they no longer look alike to Simian. This is, IMO much worse and
could affect the readability of the code, or worse introduce bugs
immediately.

As far as our development process goes, we actually have a bunch of perl
scripts that execute after our nightly build that look for 'bad things'
in the projects and the code
 (for example we keep track of developers TODO comments etc, to make
sure they don't get out of hand)=20
If we added the ability to ignore blocks with the mechanism I described
below, we would also add a script to check for these regions after every
build so that we can police it's use.

In otherwords, we trust our developers, especially because we are
watching them very very closely :)

I think the option would be a useful addition, and if you added it you
might just want to document it as use at your own risk, e.g.  "Only use
this option under extreme circumstance. Make sure there is no way to
refactor the code prior to ignoring it."

Thanks again
Mark

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

Mark,

It's 1.30am here but I've been awake writing (or at least attempting to
write) so your email was a nice distraction :)

I have to admit that I'm not a great fan of ignoring blocks myself. I
feel it is far too easy to abuse. I do however concede that it may
sometimes be necessary to use.

Along the same lines, when someone told me about the use of
#region/#endregion in C# I was a little take aback as it seemed to be
that the code was being polluted by constructs designed solely for the
tool. But again, I concede that the reality is most people code within
the tool anyway.

Thanks for the kind words too by the way. Always nice to know people are
finding Simian useful.

Oh, the #region/#reqion stuff really does just ignore all regions.=20
Someone asked for it a while ago, back before I even knew what they were
for :)

Anyway, I guess it comes down to how much you trust your developers not
to subvert the process by simply marking up the code. As the customer,
I'm more than happy to do what you think is going to help improve your
code quality.

Besides, I honestly haven't come up with a better alternative. hehe.

Maybe it's an option we just have to have?

Simon

On 15/04/2005, at 1:22 AM, Mark Webb wrote:

>
> Simon
>
> Thanks for the prompt reply.
>
> I noticed the #region support, but given that our code is mainly=20
> (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?=20
> Is
> it possible to ignore regions with specific names?
> The reason I ask, is that we region all of our C# code into logical=20
> blocks to ease code reading.
>
> 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=20
> passed the appropriate markers.
>
> I am not so keen on the solution of a file containing file and line=20
> numbers. As you say this is volatile and would need to maintained as=20
> the code base changes.
>
> BTW, I have to say Simian is an excellent tool and has already helped=20
> us significantly reduce code duplication. Once we can get a clean run=20
> (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=20
> Copy-Paste offenders :)
>
> Cheers,
> Mark
>
> -----Original Message-----
> From: Simon Harris [mailto:[email protected]]
> 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=20
> 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=20
> you are using C#, this is already possible as #region #endregion=20
> markers are already supported.
>
> If this doesn't work for you, or you are using some other language,=20
> another option would be to come up with some other kind of tag to=20
> indicate that simian should ignore it.
>
> Yet another possible solution would be have a file containing code=20
> 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=20
> 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=20
> 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=20
> 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

>> 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=20
>> 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
>
>
>
>

--
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