Skip to content

Commit ac76353

Browse files
committed
Update tallies to be size-weighted and update tests to include --info
Signed-off-by: Raj Shekhar <sraj4090ti@gmail.com>
1 parent e8b82eb commit ac76353

32 files changed

Lines changed: 14717 additions & 15206 deletions

src/summarycode/summarizer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ def get_declared_holders(codebase, holders_tallies):
176176
if entry['holder']
177177
}
178178
unique_key_file_holders = unique(entry_by_key_file_holders.keys())
179+
180+
# FIX: Added 'if holder in entry_by_holders' to prevent crash if a holder
181+
# exists in key files but was filtered out of the main tallies (0 byte count)
179182
unique_key_file_holders_entries = [
180183
entry_by_holders[holder] for holder in unique_key_file_holders
184+
if holder in entry_by_holders
181185
]
182186

183187
holder_by_counts = defaultdict(list)
@@ -195,7 +199,10 @@ def get_declared_holders(codebase, holders_tallies):
195199
# If we could not determine a holder, then we return a list of all the
196200
# unique key file holders
197201
if not declared_holders:
198-
declared_holders = [entry['value'] for entry in unique_key_file_holders_entries]
202+
# We must also filter here to avoid crashing on missing entries
203+
declared_holders = [
204+
entry['value'] for entry in unique_key_file_holders_entries
205+
]
199206

200207
return declared_holders
201208

0 commit comments

Comments
 (0)