File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -90,14 +90,15 @@ def _find_copyright(
9090 """Match the line for the copyright_regex"""
9191 copyright_match = re .search (copyright_regex , line )
9292 if copyright_match :
93- return (
94- True ,
95- CopyrightMatch (
96- creation_year = copyright_match .group (2 ),
97- modification_year = copyright_match .group (3 ),
98- company = copyright_match .group (4 ),
99- ),
100- )
93+ if copyright_match .group (2 ) and copyright_match .group (4 ):
94+ return (
95+ True ,
96+ CopyrightMatch (
97+ creation_year = copyright_match .group (2 ),
98+ modification_year = copyright_match .group (3 ),
99+ company = copyright_match .group (4 ),
100+ ),
101+ )
101102 return False , None
102103
103104
Original file line number Diff line number Diff line change @@ -73,6 +73,14 @@ def test_find_copyright(self):
7373 "# This program is free software: "
7474 "you can redistribute it and/or modify"
7575 )
76+ not_a_copyright_line = """
77+ package product
78+
79+ type FooProduct struct {
80+ Version string `json:"version"`
81+ SPDXLicenseID string `json:"spdx-license-identifier"`
82+ Copyright string `json:"copyright"`
83+ """ # noqa: E501
7684
7785 # Full match
7886 found , match = find_copyright (
@@ -101,6 +109,13 @@ def test_find_copyright(self):
101109 self .assertFalse (found )
102110 self .assertIsNone (match )
103111
112+ # Looks like a copyright, but isn't
113+ found , match = find_copyright (
114+ copyright_regex = self .regex , line = not_a_copyright_line
115+ )
116+ self .assertFalse (found )
117+ self .assertIsNone (match )
118+
104119 def test_find_spdx_copyright (self ):
105120 test_line = "# SPDX-FileCopyrightText: 1995-2021 Greenbone AG"
106121 test2_line = "# SPDX-FileCopyrightText: 1995 Greenbone AG"
You can’t perform that action at this time.
0 commit comments