Skip to content

Commit 6767e59

Browse files
committed
suggestions applied
Signed-off-by: NucleonGodX <[email protected]>
1 parent 5fee298 commit 6767e59

File tree

8 files changed

+12
-16
lines changed

8 files changed

+12
-16
lines changed

docs/rest-api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Data:
493493
}
494494
}
495495
496-
.. _rest_api_clarity_compliance:
496+
.. _rest_api_license_clarity_compliance:
497497

498498
License Clarity Compliance
499499
^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/tutorial_license_policies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ in the project:
150150
> ERROR: 1
151151
cuckoo_filter-1.0.6.tar.gz-extract/cuckoo_filter-1.0.6/README.md
152152
[license clarity]
153-
> Alert Level: ERROR
153+
> ERROR
154154
155155
.. tip::
156156
In case of compliance alerts, the command returns a non-zero exit code which

scanpipe/api/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def compliance(self, request, *args, **kwargs):
482482
return Response({"compliance_alerts": compliance_alerts})
483483

484484
@action(detail=True, methods=["get"])
485-
def clarity_compliance(self, request, *args, **kwargs):
485+
def license_clarity_compliance(self, request, *args, **kwargs):
486486
"""
487487
Retrieve the license clarity compliance alert for a project.
488488

scanpipe/management/commands/check-compliance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def check_compliance(self, fail_level):
9090

9191
if has_clarity_issue:
9292
self.stderr.write("[license clarity]")
93-
self.stderr.write(f" > Alert Level: {clarity_alert.upper()}")
93+
self.stderr.write(f" > {clarity_alert.upper()}")
9494

9595
return total_issues > 0
9696

scanpipe/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,7 @@ def get_license_clarity_compliance_alert(self):
15191519
Return the license clarity compliance alert value for the project,
15201520
or None if not set.
15211521
"""
1522-
extra_data = self.extra_data or {}
1523-
return extra_data.get("license_clarity_compliance_alert")
1522+
return self.extra_data.get("license_clarity_compliance_alert")
15241523

15251524
def get_license_policy_index(self):
15261525
"""Return the policy license index for this project instance."""

scanpipe/pipes/license_clarity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def load_clarity_thresholds_from_file(file_path):
156156
file_path = Path(file_path)
157157

158158
if not file_path.exists():
159-
return None
159+
return
160160

161161
try:
162162
yaml_content = file_path.read_text(encoding="utf-8")
@@ -175,10 +175,10 @@ def get_project_clarity_thresholds(project):
175175
"""
176176
policies_dict = project.get_policies_dict()
177177
if not policies_dict:
178-
return None
178+
return
179179

180180
clarity_thresholds = policies_dict.get("license_clarity_thresholds")
181181
if not clarity_thresholds:
182-
return None
182+
return
183183

184184
return ClarityThresholdsPolicy(clarity_thresholds)

scanpipe/tests/test_commands.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,9 +1225,7 @@ def test_scanpipe_management_command_check_clarity_compliance_only(self):
12251225
call_command("check-compliance", *options, stderr=out)
12261226
self.assertEqual(cm.exception.code, 1)
12271227
out_value = out.getvalue().strip()
1228-
expected = (
1229-
"1 compliance issues detected.\n[license clarity]\n > Alert Level: ERROR"
1230-
)
1228+
expected = "1 compliance issues detected.\n[license clarity]\n > ERROR"
12311229
self.assertEqual(expected, out_value)
12321230

12331231
def test_scanpipe_management_command_check_both_compliance_and_clarity(self):
@@ -1250,7 +1248,7 @@ def test_scanpipe_management_command_check_both_compliance_and_clarity(self):
12501248
expected = (
12511249
"2 compliance issues detected."
12521250
"\n[packages]\n > ERROR: 1"
1253-
"\n[license clarity]\n > Alert Level: WARNING"
1251+
"\n[license clarity]\n > WARNING"
12541252
)
12551253
self.assertEqual(expected, out_value)
12561254

scanpipe/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,9 +1210,8 @@ def get_context_data(self, **kwargs):
12101210
)
12111211
context["compliance_alerts"] = compliance_alerts
12121212

1213-
extra_data = project.extra_data or {}
1214-
context["license_clarity_compliance_alert"] = extra_data.get(
1215-
"license_clarity_compliance_alert"
1213+
context["license_clarity_compliance_alert"] = (
1214+
project.get_license_clarity_compliance_alert()
12161215
)
12171216

12181217
return context

0 commit comments

Comments
 (0)