Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add line_to_ccn={line:ccn} #306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def __init__(self, name, filename, start_line=0, ccn=1):
self.fan_in = 0
self.fan_out = 0
self.general_fan_out = 0
self.line_to_ccn = {}

@property
def name_in_space(self):
Expand Down Expand Up @@ -463,6 +464,10 @@ def push_new_function(self, name):

def add_condition(self, inc=1):
self.current_function.cyclomatic_complexity += inc
if self.current_function.line_to_ccn.__contains__(self.current_line):
self.current_function.line_to_ccn[self.current_line] += inc
else:
self.current_function.line_to_ccn[self.current_line] = 1

def add_to_long_function_name(self, app):
self.current_function.add_to_long_name(app)
Expand Down
7 changes: 4 additions & 3 deletions lizard_ext/csvoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def csv_output(result, options):
for caption in extension_captions:
extension_caption = "{},{}".format(extension_caption, caption)
print("NLOC,CCN,token,PARAM,length,location,file,function," +
"long_name,start,end{}".format(extension_caption))
"long_name,start,end{},{{line:ccn}}".format(extension_caption))

for source_file in result:
if source_file:
Expand All @@ -49,7 +49,7 @@ def csv_output(result, options):
extension_string = '{},{}'.\
format(extension_string,
source_function.__getattribute__(variable))
print('{},{},{},{},{},"{}","{}","{}","{}",{},{}{}'.format(
print('{},{},{},{},{},"{}","{}","{}","{}",{},{}{},"{}"'.format(
source_function.nloc,
source_function.cyclomatic_complexity,
source_function.token_count,
Expand All @@ -66,5 +66,6 @@ def csv_output(result, options):
source_function.long_name.replace("\"", "'"),
source_function.start_line,
source_function.end_line,
extension_string
extension_string,
str(source_function.line_to_ccn)
))