On Dec 15, 2006, at 10:22 PM, Matisse Enzer wrote:

On Dec 15, 2006, at 7:52 AM, Chris Dolan wrote:


That can't be right.  Negation does not contribute to complexity.

I think it is fair to say, that to a human, negation *can* increase complexity:

   if ( $foo ) {
      # do something
   }

is a little bit easier to understand than:

   if ( ! $foo ) {
      # do something
   }


Instead, I believe it is the for loop and the exit points that are increasing your count.

It certainly is possible to create a better, more sophisticated measure of cyclomatic complexity - and I think you are probably right, or at least "more right" in the way you are suggesting complexity be counted. Perl::Metrics::Simple simply gives one "point" for each of the following:

  qw( ! && || ||= &&= or and xor not ? <<= >>= );
  qw( for foreach goto if else elsif last next unless until while );

See the    measure_complexity()  method in
  Perl::Metrics::Simple::Analysis::File

OK, I see. Perhaps I was distracted from your main point by mention of cyclomatic complexity, which has a rather specific definition.

Chris

--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf



Reply via email to