terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.81k stars 246 forks source link

Make length a property of FileInfo #344

Closed luisfpereira closed 2 years ago

luisfpereira commented 2 years ago

Small simplification of FunctionInfo's length in order to not care about it anywhere else during the parsing process.

int(self.start_line != self.end_line) only for consistency with equal start and end lines.

terryyin commented 2 years ago

Smart idea. Thanks. Could you please add at least one test case? Because there is a new condition int(self.start_line != self.end_line) in the pull request.

luisfpereira commented 2 years ago

Probably the best way to go is to replace the condition int(self.start_line != self.end_line) by + 1. With this, functions that have same start and end lines will have length 1 (which I would say is consistent, as e.g.start_line=0 and end_line=1 leads to length=2 in the previous implementation).

Yesterday I chose to add the condition because some output tests were failing (as length was initialize with 0), but now that I think more deeply about it, I think we should simply correct that tests.

What do you think?

terryyin commented 2 years ago

Yes, I think correcting the test expectations is the right thing to do.