Skip to content

Commit 76131bb

Browse files
committed
Refactor '_license_diff()' #29
* Modified definitions of 'new_licenses' and 'old_licenses' to delete "or []" -- appears not to be needed. * Modified test for "license info added"/"license info removed" where relevant score(s) < 'cutoff_score'. Signed-off-by: John M. Horan <johnmhoran@gmail.com>
1 parent 0f97600 commit 76131bb

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/deltacode/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,13 @@ def _license_diff(self, cutoff_score=50):
181181
'license info removed', 'license info added' or 'license change' if
182182
there has been a license change and depending on the nature of that change.
183183
"""
184-
new_licenses = self.new_file.licenses or []
185-
old_licenses = self.old_file.licenses or []
184+
new_licenses = self.new_file.licenses
185+
old_licenses = self.old_file.licenses
186186

187-
if len(new_licenses) != len(old_licenses):
188-
if len(new_licenses) == 0:
189-
self.category = 'license info removed'
190-
elif len(old_licenses) == 0:
191-
self.category = 'license info added'
187+
if new_licenses and not old_licenses:
188+
self.category = 'license info added'
189+
if not new_licenses and old_licenses:
190+
self.category = 'license info removed'
192191

193192
new_keys = set(l.key for l in new_licenses if l.score >= cutoff_score)
194193
old_keys = set(l.key for l in old_licenses if l.score >= cutoff_score)

0 commit comments

Comments
 (0)