Skip to content

Commit 0c94bb9

Browse files
Fix end_line incorrectly assigned from start_line in CSV output #4785
In flatten_scan(), the end_line field for copyrights, holders, and authors was assigned copyr['start_line'] instead of copyr['end_line']. This caused the end_line column in CSV output to always equal start_line, losing the actual end line information. Signed-off-by: codewithfourtix <codewithfourtix@gmail.com>
1 parent d320c97 commit 0c94bb9

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/formattedcode/output_csv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,23 @@ def collect_keys(mapping, key_group):
185185
inf = dict(path=path)
186186
inf['copyright'] = copyr['copyright']
187187
inf['start_line'] = copyr['start_line']
188-
inf['end_line'] = copyr['start_line']
188+
inf['end_line'] = copyr['end_line']
189189
collect_keys(inf, 'copyright')
190190
yield inf
191191

192192
for copyr in scanned_file.get('holders', []):
193193
inf = dict(path=path)
194194
inf['holder'] = copyr['holder']
195195
inf['start_line'] = copyr['start_line']
196-
inf['end_line'] = copyr['start_line']
196+
inf['end_line'] = copyr['end_line']
197197
collect_keys(inf, 'copyright')
198198
yield inf
199199

200200
for copyr in scanned_file.get('authors', []):
201201
inf = dict(path=path)
202202
inf['author'] = copyr['author']
203203
inf['start_line'] = copyr['start_line']
204-
inf['end_line'] = copyr['start_line']
204+
inf['end_line'] = copyr['end_line']
205205
collect_keys(inf, 'copyright')
206206
yield inf
207207

tests/formattedcode/data/csv/flatten_scan/full.json-expected

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,19 +3717,19 @@
37173717
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37183718
"copyright": "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Python Software Foundation",
37193719
"start_line": 93,
3720-
"end_line": 93
3720+
"end_line": 94
37213721
},
37223722
{
37233723
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37243724
"copyright": "Copyright (c) 1995-2001 Corporation for National Research Initiatives",
37253725
"start_line": 194,
3726-
"end_line": 194
3726+
"end_line": 195
37273727
},
37283728
{
37293729
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37303730
"copyright": "Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, The Netherlands",
37313731
"start_line": 254,
3732-
"end_line": 254
3732+
"end_line": 255
37333733
},
37343734
{
37353735
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -3741,19 +3741,19 @@
37413741
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37423742
"copyright": "Copyright (c) 1990-2005 Sleepycat Software",
37433743
"start_line": 331,
3744-
"end_line": 331
3744+
"end_line": 332
37453745
},
37463746
{
37473747
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37483748
"copyright": "Copyright (c) 1990, 1993, 1994, 1995 The Regents of the University of California",
37493749
"start_line": 366,
3750-
"end_line": 366
3750+
"end_line": 367
37513751
},
37523752
{
37533753
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37543754
"copyright": "Copyright (c) 1995, 1996 The President and Fellows of Harvard University",
37553755
"start_line": 394,
3756-
"end_line": 394
3756+
"end_line": 395
37573757
},
37583758
{
37593759
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -3777,13 +3777,13 @@
37773777
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37783778
"copyright": "copyrighted by the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation",
37793779
"start_line": 554,
3780-
"end_line": 554
3780+
"end_line": 556
37813781
},
37823782
{
37833783
"path": "samples/commoncode/src/commoncode/python.LICENSE",
37843784
"copyright": "copyrighted by the Regents of the University of California, Sun Microsystems, Inc.",
37853785
"start_line": 597,
3786-
"end_line": 597
3786+
"end_line": 598
37873787
},
37883788
{
37893789
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -3801,7 +3801,7 @@
38013801
"path": "samples/commoncode/src/commoncode/python.LICENSE",
38023802
"holder": "Stichting Mathematisch Centrum Amsterdam, The Netherlands",
38033803
"start_line": 254,
3804-
"end_line": 254
3804+
"end_line": 255
38053805
},
38063806
{
38073807
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -3849,13 +3849,13 @@
38493849
"path": "samples/commoncode/src/commoncode/python.LICENSE",
38503850
"holder": "the Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState Corporation",
38513851
"start_line": 554,
3852-
"end_line": 554
3852+
"end_line": 556
38533853
},
38543854
{
38553855
"path": "samples/commoncode/src/commoncode/python.LICENSE",
38563856
"holder": "the Regents of the University of California, Sun Microsystems, Inc.",
38573857
"start_line": 597,
3858-
"end_line": 597
3858+
"end_line": 598
38593859
},
38603860
{
38613861
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -3873,13 +3873,13 @@
38733873
"path": "samples/commoncode/src/commoncode/python.LICENSE",
38743874
"author": "Eric Young (eay@cryptsoft.com)",
38753875
"start_line": 485,
3876-
"end_line": 485
3876+
"end_line": 486
38773877
},
38783878
{
38793879
"path": "samples/commoncode/src/commoncode/python.LICENSE",
38803880
"author": "Tim Hudson (tjh@cryptsoft.com)",
38813881
"start_line": 486,
3882-
"end_line": 486
3882+
"end_line": 487
38833883
},
38843884
{
38853885
"path": "samples/commoncode/src/commoncode/python.LICENSE",
@@ -5073,7 +5073,7 @@
50735073
"path": "samples/JGroups/licenses/apache-1.1.txt",
50745074
"author": "the Apache Software Foundation (http://www.apache.org/)",
50755075
"start_line": 21,
5076-
"end_line": 21
5076+
"end_line": 22
50775077
},
50785078
{
50795079
"path": "samples/JGroups/licenses/apache-1.1.txt",
@@ -7245,13 +7245,13 @@
72457245
"path": "samples/zlib/iostream2/zstream.h",
72467246
"copyright": "Copyright (c) 1997 Christian Michelsen Research AS Advanced Computing",
72477247
"start_line": 3,
7248-
"end_line": 3
7248+
"end_line": 5
72497249
},
72507250
{
72517251
"path": "samples/zlib/iostream2/zstream.h",
72527252
"holder": "Christian Michelsen Research AS Advanced Computing",
72537253
"start_line": 4,
7254-
"end_line": 4
7254+
"end_line": 5
72557255
},
72567256
{
72577257
"path": "samples/zlib/iostream2/zstream.h",

0 commit comments

Comments
 (0)