Skip to content

Commit 0e4a279

Browse files
committed
Set run_order field on plugins #3377
Signed-off-by: Jono Yang <[email protected]>
1 parent 06e9ac5 commit 0e4a279

18 files changed

+27
-4
lines changed

src/cluecode/plugin_copyright.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CopyrightScanner(ScanPlugin):
2828
('authors', attr.ib(default=attr.Factory(list))),
2929
])
3030

31+
run_order = 6
3132
sort_order = 6
3233

3334
options = [

src/cluecode/plugin_email.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class EmailScanner(ScanPlugin):
2525
"""
2626
resource_attributes = dict(emails=attr.ib(default=attr.Factory(list)))
2727

28+
run_order = 7
2829
sort_order = 7
2930

3031
options = [

src/cluecode/plugin_filter_clues.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class RedundantCluesFilter(PostScanPlugin):
4141
Filter redundant clues (copyrights, authors, emails, and urls) that are
4242
already contained in a matched license text.
4343
"""
44+
run_order = 1
4445
sort_order = 1
4546

4647
options = [

src/cluecode/plugin_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class UrlScanner(ScanPlugin):
2626

2727
resource_attributes = dict(urls=attr.ib(default=attr.Factory(list)))
2828

29+
run_order = 8
2930
sort_order = 8
3031

3132
options = [

src/licensedcode/licenses_reference.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class LicenseReference(PostScanPlugin):
4848
)
4949

5050
# TODO: send to the tail of the scan, after files
51+
run_order = 1000
5152
sort_order = 1000
5253

5354
options = [

src/licensedcode/plugin_license.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class LicenseScanner(ScanPlugin):
7171
license_detections=attr.ib(default=attr.Factory(list)),
7272
)
7373

74+
run_order = 4
7475
sort_order = 4
7576

7677
options = [

src/licensedcode/plugin_license_policy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class LicensePolicy(PostScanPlugin):
5151

5252
resource_attributes = dict(license_policy=attr.ib(default=attr.Factory(list)))
5353

54+
run_order = 9
5455
sort_order = 9
5556

5657
options = [
@@ -100,8 +101,8 @@ def process_codebase(self, codebase, license_policy, **kwargs):
100101
if key == policy.get('license_key'):
101102
# Apply the policy to the Resource
102103
license_policies.append(policy)
103-
104-
resource.license_policy = sorted(license_policies, key=lambda d: d['license_key'])
104+
105+
resource.license_policy = sorted(license_policies, key=lambda d: d['license_key'])
105106
codebase.save_resource(resource)
106107

107108

src/packagedcode/plugin_package.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class PackageScanner(ScanPlugin):
134134

135135
required_plugins = ['scan:licenses']
136136

137+
run_order = 3
137138
sort_order = 3
138139

139140
options = [

src/scancode/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,12 @@ def run_codebase_plugins(
10591059
if verbose and plugins:
10601060
echo_func(stage_msg % locals(), fg='green')
10611061

1062+
# Sort plugins by run_order, from low to high
1063+
sorted_plugins = sorted(plugins, key=lambda x: x.run_order)
1064+
10621065
success = True
10631066
# TODO: add progress indicator
1064-
for plugin in plugins:
1067+
for plugin in sorted_plugins:
10651068
name = plugin.name
10661069
plugin_start = time()
10671070

src/scancode/plugin_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class InfoScanner(ScanPlugin):
3838
('is_script', attr.ib(default=False, type=bool, repr=False)),
3939
])
4040

41+
run_order = 0
4142
sort_order = 0
4243

4344
options = [

0 commit comments

Comments
 (0)